Error: Please specify `upload_port`

I get this error even though I have specified it in platformio.ini.


Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, 
olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
=============================== [FAILED] Took 8.69 seconds ===============================


platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
	adafruit/Adafruit SSD1306@^2.5.1
	adafruit/Adafruit GFX Library@^1.10.13
	adafruit/Adafruit BusIO@^1.11.1
upload_protocol = esptool
upload_port = COM[1]

Are you sure you want to use this regex expression that can only match COM1?

Also, COM1 sounds like a motherboard COM port, and not a USB-serial adapter from a dev board. What does the windows device manager say about the available ports?

It’s one of the USB port on the front of my PC. Device Manager shows COM1 and Silicon Labs CP210x and that is all right now. It has worked before with COM1. I connected the esp32 but it did not pop-up another Com port in DevMan. I tried with COM[1234] to no avail.

Maybe PlatformIO has special logic to detect COM1 as a motherboard COM, because that’s usually the case. You can use the Windows device manager to change the COM port number to something higher, say, COM6. After doing that, I would recommend removing the upload_port = .. directive and retrying without it.

Thanks maxgerhardt for your help
I’ve been experimenting a bit but finally I changed COM1 to COM6 but it doesn’t help. When I connect esp32 it picks up the Silicon Labs CP210x (COM4) which has a different driver (silabser.sys) than standard COM ports (serenum.sys, serial.sys) Could it still be correct? When I upload it asks for COM3. Where does it get COM3?

Uploading .pio\build\esp32dev\firmware.bin v3.1
Serial port COM3

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header    
*** [upload] Error 2

Yes that can be correct. Can you download & instlall the CP210x universal windows drivers from CP210x USB to UART Bridge VCP Drivers - Silicon Labs? Then set upload_port = ... specifically to the COM port created by the CP210x chip?

I had the universal driver already installed. I put in COM[4] and connected esp32 and the upload was successful. If it’s not connected the upload fails. I thought it would come out and say “… connect device within 60 seconds” or something to that effect but it needed to be connected.

No, that’s not implemented in PlatformIO or PlatformIO checks available serial devices at upload-button-press time (or uses the pre-provided one via upload_port) and forwards it as --port <device> to Neither of these programs have the capability to wait for a new serial port connection in the ESP32 case.

When I worked with the ATTiny85 breakout board I’m sure I saw that message and when I connected the board the upload started/continued.

Correct, the digistump bootloader / upload tool has this “please plug in device” behavior. That’s also the only case I know of that has this behavior. But that’s then programmed in the uploader tool (micronucleus).

OK, so that was an exception. Interesting. Thanks again.