ESP32 through esp-prog fails when flashing or debugging

Hi, guys!

I’m trying to upload and debug firmware through through the esp-prog. My board is esp32devkit_v1 .
I successfully installed all the drivers (FTDI + D2XX) and it seems that it’s flashing, but verifying procedure fails. In fact the firmware not getting uploads too.
I’ve got the same output from PIO in VSCode on macOS 10.14.6 (my main system ) and also the same on another PC running on Windows 10.

My platformio.ini:
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
upload_protocol = esp-prog
debug_tool = esp-prog

PlatformIO output:
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION:
PLATFORM: Espressif 32 1.11.1 > DOIT ESP32 DEVKIT V1
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)
PACKAGES: toolchain-xtensa32 2.50200.80 (5.2.0), framework-arduinoespressif32 2.10004.191002 (1.0.4), tool-esptoolpy 1.20600.0 (2.6.0), tool-openocd-esp32 1.1000.20190708 (10.0), tool-mkspiffs 2.230.0 (2.30)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 26 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Linking .pio\build\esp32doit-devkit-v1\firmware.elf
Building .pio\build\esp32doit-devkit-v1\firmware.bin
Retrieving maximum program size .pio\build\esp32doit-devkit-v1\firmware.elf
Checking size .pio\build\esp32doit-devkit-v1\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 4.5% (used 14700 bytes from 327680 bytes)
Flash: [== ] 16.0% (used 209799 bytes from 1310720 bytes)
esptool.py v2.6
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 = esp-prog
Uploading .pio\build\esp32doit-devkit-v1\firmware.bin
Open On-Chip Debugger v0.10.0-esp32-20190708 (2019-07-08-11:04)
Licensed under GNU GPL v2
For bug reports, read

debug_level: 1
none separate
adapter speed: 20000 kHz
esp32 interrupt mask on
** Programming Started **
auto erase enabled
wrote 212992 bytes from file .pio\build\esp32doit-devkit-v1\firmware.bin in 1.895478s (109.735 KiB/s)
** Programming Finished **
** Verify Started **
read 209920 bytes from file .pio\build\esp32doit-devkit-v1\firmware.bin and flash bank 0 at offset 0x00010000 in 1.344282s (152.498 KiB/s)
contents differ
diff 0 address 0x00010005. Was 0x1e instead of 0x0f
diff 1 address 0x0001001c. Was 0x2c instead of 0xe4
diff 2 address 0x0001001d. Was 0x5a instead of 0xb0
diff 3 address 0x0001001e. Was 0x02 instead of 0x00
diff 4 address 0x00010021. Was 0x04 instead of 0x00
diff 5 address 0x00010022. Was 0x4d instead of 0x00
diff 6 address 0x00010023. Was 0x51 instead of 0x00
diff 7 address 0x00010024. Was 0x54 instead of 0x00
diff 8 address 0x00010025. Was 0x54 instead of 0x00
diff 9 address 0x00010026. Was 0x04 instead of 0x00
diff 10 address 0x00010027. Was 0x00 instead of 0x80
diff 11 address 0x00010028. Was 0x12 instead of 0x00
diff 12 address 0x00010029. Was 0x4b instead of 0x00
diff 13 address 0x0001002a. Was 0x0d instead of 0x00
diff 14 address 0x0001002b. Was 0x40 instead of 0xa0
diff 15 address 0x0001002c. Was 0x8e instead of 0x00
diff 16 address 0x0001002d. Was 0x4a instead of 0x00
diff 17 address 0x0001002e. Was 0x0d instead of 0x00
diff 18 address 0x0001002f. Was 0x40 instead of 0xc0
diff 19 address 0x00010030. Was 0xec instead of 0x00
diff 20 address 0x00010031. Was 0x4a instead of 0x00
diff 21 address 0x00010032. Was 0x0d instead of 0x00
diff 22 address 0x00010033. Was 0x40 instead of 0xe0
diff 23 address 0x00010034. Was 0x12 instead of 0x14
diff 24 address 0x00010035. Was 0x4b instead of 0x14
diff 25 address 0x00010036. Was 0x0d instead of 0x14
diff 26 address 0x00010037. Was 0x40 instead of 0x07
diff 27 address 0x00010038. Was 0x35 instead of 0x00
diff 28 address 0x00010039. Was 0x4b instead of 0xff
diff 29 address 0x0001003a. Was 0x0d instead of 0xff
diff 30 address 0x0001003b. Was 0x40 instead of 0x00
diff 31 address 0x0001003c. Was 0x58 instead of 0x00
diff 32 address 0x0001003d. Was 0x4b instead of 0x00
diff 33 address 0x0001003e. Was 0x0d instead of 0x00
diff 34 address 0x0001003f. Was 0x40 instead of 0x00
diff 35 address 0x00010040. Was 0x58 instead of 0x00
diff 36 address 0x00010041. Was 0x4b instead of 0x00
diff 37 address 0x00010042. Was 0x0d instead of 0x00
diff 38 address 0x00010043. Was 0x40 instead of 0x00
diff 39 address 0x00010044. Was 0x58 instead of 0x48
diff 40 address 0x00010045. Was 0x4b instead of 0x00
diff 41 address 0x00010046. Was 0x0d instead of 0x00
diff 42 address 0x00010047. Was 0x40 instead of 0x00
diff 43 address 0x00010048. Was 0x58 instead of 0x48
diff 44 address 0x00010049. Was 0x4b instead of 0x00
diff 45 address 0x0001004a. Was 0x0d instead of 0x00
diff 46 address 0x0001004b. Was 0x40 instead of 0x00
diff 47 address 0x0001004c. Was 0xb2 instead of 0x48
diff 48 address 0x0001004d. Was 0x4a instead of 0x00
diff 49 address 0x0001004e. Was 0x0d instead of 0x00
diff 50 address 0x0001004f. Was 0x40 instead of 0x00
diff 51 address 0x00010050. Was 0xfe instead of 0x48
diff 52 address 0x00010051. Was 0x4a instead of 0x00
diff 53 address 0x00010052. Was 0x0d instead of 0x00
diff 54 address 0x00010053. Was 0x40 instead of 0x00
diff 55 address 0x00010054. Was 0x12 instead of 0x48
diff 56 address 0x00010055. Was 0x4b instead of 0x00
diff 57 address 0x00010056. Was 0x0d instead of 0x00
diff 58 address 0x00010057. Was 0x40 instead of 0x00
diff 59 address 0x00010058. Was 0x35 instead of 0x48
diff 60 address 0x00010059. Was 0x4b instead of 0x00
diff 61 address 0x0001005a. Was 0x0d instead of 0x00
diff 62 address 0x0001005b. Was 0x40 instead of 0x00
diff 63 address 0x0001005c. Was 0xa9 instead of 0x48
diff 64 address 0x0001005d. Was 0x53 instead of 0x00
diff 65 address 0x0001005e. Was 0x0d instead of 0x00
diff 66 address 0x0001005f. Was 0x40 instead of 0x00
diff 67 address 0x00010060. Was 0x26 instead of 0x01
diff 68 address 0x00010061. Was 0x53 instead of 0x00
diff 69 address 0x00010062. Was 0x0d instead of 0x00
diff 70 address 0x00010063. Was 0x40 instead of 0x00
diff 71 address 0x00010064. Was 0x84 instead of 0x00
diff 72 address 0x00010065. Was 0x53 instead of 0x00
diff 73 address 0x00010066. Was 0x0d instead of 0x00
diff 74 address 0x00010067. Was 0x40 instead of 0x00
diff 75 address 0x00010068. Was 0xa9 instead of 0x05
diff 76 address 0x00010069. Was 0x53 instead of 0x00
diff 77 address 0x0001006a. Was 0x0d instead of 0x00
diff 78 address 0x0001006b. Was 0x40 instead of 0x00
diff 79 address 0x0001006c. Was 0xcd instead of 0x19
diff 80 address 0x0001006d. Was 0x53 instead of 0x00
diff 81 address 0x0001006e. Was 0x0d instead of 0x00
diff 82 address 0x0001006f. Was 0x40 instead of 0x00
diff 83 address 0x00010070. Was 0xf0 instead of 0x7d
diff 84 address 0x00010071. Was 0x53 instead of 0x00
diff 85 address 0x00010072. Was 0x0d instead of 0x00
diff 86 address 0x00010073. Was 0x40 instead of 0x00
diff 87 address 0x00010074. Was 0xf0 instead of 0x00
diff 88 address 0x00010075. Was 0x53 instead of 0x00
diff 89 address 0x00010076. Was 0x0d instead of 0x00
diff 90 address 0x00010077. Was 0x40 instead of 0x00
diff 91 address 0x00010078. Was 0xf0 instead of 0xbc
diff 92 address 0x00010079. Was 0x53 instead of 0x89
diff 93 address 0x0001007a. Was 0x0d instead of 0xd8
diff 94 address 0x0001007b. Was 0x40 instead of 0x97
diff 95 address 0x0001007c. Was 0xf0 instead of 0xb2
diff 96 address 0x0001007d. Was 0x53 instead of 0xd2
diff 97 address 0x0001007e. Was 0x0d instead of 0x9c
diff 98 address 0x0001007f. Was 0x40 instead of 0x3c
diff 99 address 0x00010080. Was 0x4a instead of 0x33
diff 100 address 0x00010081. Was 0x53 instead of 0xa7
diff 101 address 0x00010082. Was 0x0d instead of 0xa8
diff 102 address 0x00010083. Was 0x40 instead of 0xd5
diff 103 address 0x00010084. Was 0x95 instead of 0x23
diff 104 address 0x00010085. Was 0x53 instead of 0xf6
diff 105 address 0x00010086. Was 0x0d instead of 0x49
diff 106 address 0x00010087. Was 0x40 instead of 0x39
diff 107 address 0x00010088. Was 0xa9 instead of 0x3d
diff 108 address 0x00010089. Was 0x53 instead of 0xa7
diff 109 address 0x0001008a. Was 0x0d instead of 0xf4
diff 110 address 0x0001008b. Was 0x40 instead of 0x44
diff 111 address 0x0001008c. Was 0xcd instead of 0xfd
diff 112 address 0x0001008d. Was 0x53 instead of 0x0f
diff 113 address 0x0001008e. Was 0x0d instead of 0xa5
diff 114 address 0x0001008f. Was 0x40 instead of 0x32
diff 115 address 0x00010090. Was 0x00 instead of 0x9d
diff 116 address 0x00010091. Was 0x00 instead of 0x97
diff 117 address 0x00010092. Was 0x00 instead of 0x8c
diff 118 address 0x00010093. Was 0x00 instead of 0xcf
diff 119 address 0x00010094. Was 0x00 instead of 0x08
diff 120 address 0x00010095. Was 0x00 instead of 0xba
diff 121 address 0x00010096. Was 0x00 instead of 0x5b
diff 122 address 0x00010097. Was 0x80 instead of 0x25
diff 123 address 0x00010098. Was 0x00 instead of 0x43
diff 124 address 0x00010099. Was 0x00 instead of 0x6f
diff 125 address 0x0001009a. Was 0x00 instead of 0xac
diff 126 address 0x0001009b. Was 0xa0 instead of 0x64
diff 127 address 0x0001009c. Was 0x00 instead of 0x28
More than 128 errors, the rest are not printed.
embedded:startup.tcl:480: Error: ** Verify Failed **
in procedure ‘program_esp32’
in procedure ‘program_error’ called at file “C:/Users/Dev1/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg”, line 138
at file “embedded:startup.tcl”, line 480
Warn : Flash driver of esp32.flash does not support free_driver_priv()
Warn : Flash driver of irom does not support free_driver_priv()
Warn : Flash driver of drom does not support free_driver_priv()
*** [upload] Error 1

Please help to understand the problem!
Thank you!

For further analysis, can you answer a few questions and test a few things?:

  • What board are you using? Is it really a DOIT ESP32? Or something similar?
  • Have you tested with a minimal program, e.g. a Blink example? If you, can you try?
  • Does the board and the program work with the default upload protocol, i.e. esptool (upload via the board’s USB connection)? If not, can you try it?

Yes, Of course:

  1. The board looks exactly like doit esp32 devkit v1, pinout and pin names similar, probably it’s clone.
  2. Yes I did. For example when I tried on windows 10, my example was a simple blink. Output of the PIO absolutely the same on Mac and Win.
  3. The firmware uploads and works successfully when I’m using onboard usb->ttl, except for timeout issue.

I have an idea of trying to add a capacitor between EN and GND pins.
I’ll write after the test.

It’s a strange behavior. The only thing I can currently think of is a communication issue (either USB, wiring or SPI flash parameters.

The next things you can try:

  • Ensure that your board uses an ESP32-WROOM-32 (and not a ESP32-WROVER-32 or ESP-SOLO-1) module. It should be labelled on the metallic module cover.
  • Reduce the length of the cables between the ESP-Prog and the board to at most 20cm.
  • Reduce the communication speed (see below)
  • Try a different USB cable and USB port

Reduce speed

In C:\Users\username\.platformio\packages\tool-openocd-esp32\share\openocd\scripts\target\esp-wroom-32.cfg append the line:

adapter_khz 1000

If it is successful, you should see this output when upload or debugging:

adapter speed: 1000 kHz
1 Like

The problem was completely solved by adding a capacitor between EN and GND, I used a value of 0,22uF ceramic. Now uploading and debugging works as expected. Also adding a cap solves the problem with automatic flashing through the onboard usb -> ttl.

Manuel, thank you very much for your advice!

4 Likes

That’s a cool tip. I have ESP32 boards that I cannot reliably flash via USB. To make it work, I have to press the BOOT button. Possibly the capacitor will make it work. I’ll give it a try.