Cannot upload code to ESP32 unsing Platformio on VS code

Hello. I have downloaded platformio extension for ESP32 and have weird issue trying to upload code to my ESP32 device. My esp32 device is on COM 11. I can easily program it on Arduino IDE without issues.

However, on the vscode, I am able to build the project, but I have problems uploading. It complains with the error message:

> Executing task: C:\Users\Lukas\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (1.11.1) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-arduinoespressif32 2.10004.191002 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 26 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.7% (used 15436 bytes from 327680 bytes)
Flash: [==        ]  16.5% (used 216635 bytes from 1310720 bytes)
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 1.54 seconds ==============================================================================================The terminal process "C:\Users\Lukas\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

My platformio.ini file contains :


;   Build options: build flags, source filter

;   Upload options: custom upload port, speed and extra flags

;   Library options: dependencies, extra library storages

;   Advanced options: extra scripting


; Please visit documentation for the other options and examples



platform = espressif32

board = esp32dev

framework = arduino

upload_port = COM[11]

Just leave it out or say COM11.

What a stupid mistake… The guide that I was looking showed COM[11] :smiley:

However, It is still not fully clear to me how does it select default port for uploading program to the device. I have my usb plugged in which connects to ESP32 device. It is COM11. I have also something else at COM3 ( I have no idea what is it ).

The only other things I have plugged in my pc is keyboard, mouse and headphones, so perhaps it is one of those? Anyways, is there any way to make the platformio upload devices to COM11 without changing platformio.ini

The autodetect logic looks for a COM port device which has a hardware ID (that is, USB PID and VID) matching the ones in the board manifest, if available, or the last one in the system if not. See discussion in Monitor port autodetection based on VID:PID · Issue #3349 · platformio/platformio-core · GitHub.

You can also list available devices in the Windows device manager to see what it might get confused with.

(here I have one motherboard COM port, an ESP8266 and an ESP32 connected)

There is no global option as far as I know.

Okay so for every project I have to manually change the platformio.ini configuration. If I dont add upload_port = COM11, for some reason it auto detects COM3 to upload.

Can you see what device COM3 coresponds to? Because a motherboard’s UART shouldn’t be detected. Maybe you have another USB device that has a USB-serial adapter attached to the computer, then PIO can’t tell the difference.

I have unplugged everything from my computer except the ESP32 usb module that I use which is COM11. I have unplugged the keyboard, mouse and all the other cables. The COM3 still persists. I have no clue what it is:

o_O. Well it’s definitely a USB-serial converter from Microchip, maybe a MCP2200 or one of those… Maybe placed on the motherboard on connected via USB after all, and not via older conventional peripheral chips? Is there a COM port on the motherboad backplane? Maybe there’s some BIOS settings to disable that if that’s the case.

Otherwise you can maybe open a feature-request issue in Issues · platformio/platformio-core · GitHub asking for some global way to ignore certain serial ports.