Esptool.py cannot connect to my board: Wrong boot mode detected (0x13)

Hi,
I’am new to Platform IO. I switched from Arduino IDE because PIO build faster.

The Setup:
I have a laptop with Windows 10, and a ESP32-DevKitC-VE with WROVER-E N8R8. I installed VSCode and then added Platform IO extension. I also updated the esptool.py to the latest version (v4.8.1). I installed the CP210x_VCP_Windows drivers and the board is successfully detected on COM3. The board is original from Espressif and it has auto-upload capabilities (using DTR/RTS). If I try to program the board from Arduino IDE, everything works fine !

The problem:
I cannot convince the esptool.py to connect to my board when I press the Upload button from PlatformIO. Or if I run in PlatformIO CLI the command "python <path_to>esptool.py --port COM3 --baud 115200 flash_id. I receive the same error. There were a few times when the connection succeeded, but most of the time it doesn’t work.

The error:

esptool.py v4.8.1
Serial port COM3
Connecting......................................
A fatal error occurred: Failed to connect to Espressif device: Wrong boot mode detected (0x13)! The chip needs to be in download mode.

But If I manualy press the BOOT button from the board, the connection succeeds every time ! So, It seems that the esptool cannot put the board in download mode by itself. But why it works fine if esptool is executed from Arduino IDE ? It is the same version ! I don’t want to press the BOOT button everytime I upload, because I switched to PIO because Arduino IDE was slow. Pressing the BOOT button everytime is even slower… :roll_eyes:

My platformio.ini:

[env:esp32dev]
platform = espressif32
platform_packages = tool-esptoolpy @ 1.40801.0
board = esp32dev
framework = arduino
upload_port = COM3
upload_speed = 921600
monitor_speed = 115200
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
board_build.flash_mode = qio
board_build.partitions = default_8MB.csv
board_upload.flash_size = 8MB
build_flags =
  -DBOARD_HAS_PSRAM
  -mfix-esp32-psram-cache-issue
  -DCORE_DEBUG_LEVEL=3

Esptool command lines uesed by:

Arduino IDE


"C:\Users\Marus\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.9.dev3/esptool.exe"
--chip esp32 --port "COM3" --baud 921600 --before default_reset --after hard_reset write_flash -z 
--flash_mode keep --flash_freq keep --flash_size keep 
0x1000 "C:\Users\Marus\AppData\Local\arduino\sketches\1D792A9CE841D1DB0E6D4E382C64C4AF/BluetoothAudio.ino.bootloader.bin" 
0x8000 "C:\Users\Marus\AppData\Local\arduino\sketches\1D792A9CE841D1DB0E6D4E382C64C4AF/BluetoothAudio.ino.partitions.bin" 
0xe000 "C:\Users\Marus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0/tools/partitions/boot_app0.bin" 
0x10000 "C:\Users\Marus\AppData\Local\arduino\sketches\1D792A9CE841D1DB0E6D4E382C64C4AF/BluetoothAudio.ino.bin"

Platform IO


"C:\Users\Marus\.platformio\penv\Scripts\python.exe" "C:\Users\Marus\.platformio\packages\tool-esptoolpy\esptool.py"
--chip esp32 --port "COM3" --baud 921600 --before default_reset --after hard_reset write_flash -z 
--flash_mode dio --flash_freq 80m --flash_size 8MB 
0x1000 "D:\ESP Audio\Soft\Bluetooth Audio PIO\.pio\build\esp32dev\bootloader.bin" 
0x8000 "D:\ESP Audio\Soft\Bluetooth Audio PIO\.pio\build\esp32dev\partitions.bin" 
0xe000 "C:\Users\Marus\.platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin" 
0x10000 .pio\build\esp32dev\firmware.bin

I put a 1uF capacitor between the EN pin and ground and now it works perfectly (Arduino IDE, Platform IO, command line, web, anywhere…) :grinning: