PlatformIO Community

Esp-prog ESP32, not working

I looked at all the posts on this forum concerning esp-prog/esp32. Also explored several other youbube vids.

I followed the youtube vid:
Use the PIO Debugger on the ESP32 uing the esp-prog by Brian Lough.

I’m using ESP-WROOM-32 with the esp-prog (FT2232HL).
I installed FTDI and Zadig and verified all was fine in the DevMgr.

I connect 2 USB cables, 1 to esp32 (COM7) the other to esp-prog(COM9)

The PIO.ini file is:

[env:esp32dev]

platform = espressif32
board = esp32dev
framework = arduino

;upload_port = COM9
;build_type = debug
debug_tool = esp-prog
debug_init_break = tbreak setup

The blink code builds successfully but won’t upload.

The following is the upload file:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (1.11.2) > 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)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
No dependencies
Building in debug 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 15356 bytes from 327680 bytes)
Flash: [==        ]  16.1% (used 211029 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...
Auto-detected: COM9
Uploading .pio\build\esp32dev\firmware.bin
esptool.py v2.6
Serial port COM9
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
*** [upload] Error 2
================================================================================================================= [FAILED] Took 28.37 seconds =================================================================================================================
The terminal process "C:\Users\jake\.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.

=======================================================================

Concerns:

  1. From what I’ve gleaned from other posts is that one of the USB connections can be removed but I’m not sure which to remove. I tried and got weird output.
  2. If I remove esp-prog board COM9 do I have to power board via 3v3?

You have set your debug_tool to esp-prog, but the upload_protocol is still different from that. Just add

upload_protocol = esp-prog

to the platformio.ini.

** Edit addition:**

After I posted this issue I started doing some searching. I’ve come to the conclusion that I need to have the “openocd” package in the …/.platformio/packages directory. The problem is I haven’t found a clear approach to do this.

Anyone have any suggestions?

=======================================================================

I made the suggested changes to PIO.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
debug_tool = esp-prog
debug_init_break = tbreak setup
upload_protocol = esp-prog

Also I’ve included the DevMgr:
image

The DevMgr looks correct to me:

Here’s the issue:

When I go to upload I get the error, see terminal dump below.

‘openocd’ is not recognized as an internal or external command, operable program or batch file

I’ve ran into issues like this before and resolved by adding a “pause” in a batch file. This error leads to believe that this might be the issue but I have no idea where to make the correction. This is possibly a race condition.

Is this the case or could it be something else. Also what would I modify?

==============================================================
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (1.11.2) > 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)
PACKAGES:

  • framework-arduinoespressif32 3.10004.200129 (1.0.4)
  • tool-esptoolpy 1.20600.0 (2.6.0)
  • tool-mkspiffs 2.230.0 (2.30)
  • tool-openocd-esp32 1.1000.20190709 (10.0)
  • toolchain-xtensa32 2.50200.80 (5.2.0)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 29 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 15356 bytes from 327680 bytes)
    Flash: [== ] 16.1% (used 210937 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 = esp-prog
    Uploading .pio\build\esp32dev\firmware.bin
    ‘openocd’ is not recognized as an internal or external command,
    operable program or batch file.
    *** [upload] Error 1
    ================================================================================================ [FAILED] Took 2.09 seconds ================================================================================================The terminal process “C:\Users\jake.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.

PlatformIO should download the required OpenOCD package automatically.

According to the build log, it has correctly determined that the package is needed. But from the rest of the output it sounds as if the package wasn’t properly installed.

Do you have a directory .platformio\packages\tool-openocd-esp32 within your home directory? If so, delete it and try again. PlatformIO should then re-download it – thereby hopefully fixing it.

I did the following:

  1. removed the tool-openocd-esp32 dir.

  2. lowered the adapter speed by editing the file /Users/xxx/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/board/esp-wroom-32.cfg and changing the value for adapter_khz to 10K.

  3. Tried these changes and did make some progress but still didn’t download. I then made the executive decision to uninstall/install vs code.

The re-install allowed me to download the code.

Here’s the issue

With the code downloaded I go to Run > Start debugging I expect to see the “step” image inset. I don’t see it consistently but does flash up and goes away. See the pic of the expected inset.

image

======================================================================

The downloaded code:

NOTICE… the line at the very end of this output:
shutdown command invoked
is this what I should suspect or is this an ERROR?

image

Executing task in folder Test_JTAG: C:\Users\jake.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
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (1.11.2) > 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)
PACKAGES:

  • framework-arduinoespressif32 3.10004.200129 (1.0.4)
  • tool-esptoolpy 1.20600.0 (2.6.0)
  • tool-mkspiffs 2.230.0 (2.30)
  • tool-openocd-esp32 1.1000.20190709 (10.0)
  • toolchain-xtensa32 2.50200.80 (5.2.0)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 29 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 15356 bytes from 327680 bytes)
    Flash: [== ] 16.1% (used 210937 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 = esp-prog
    Uploading .pio\build\esp32dev\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
    http://openocd.org/doc/doxygen/bugs.html
    debug_level: 1
    none separate
    adapter speed: 10000 kHz
    esp32 interrupt mask on
    ** Programming Started **
    auto erase enabled
    wrote 212992 bytes from file .pio\build\esp32dev\firmware.bin in 2.963738s (70.182 KiB/s)
    ** Programming Finished **
    ** Verify Started **
    read 211056 bytes from file .pio\build\esp32dev\firmware.bin and flash bank 0 at offset 0x00010000 in 1.139169s (180.930 KiB/s)
    contents match
    ** Verified OK **
    ** Programming Started **
    auto erase enabled
    wrote 16384 bytes from file C:/Users/jake/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.873812s (18.311 KiB/s)
    ** Programming Finished **
    ** Verify Started **
    read 15872 bytes from file C:/Users/jake/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.366790s (42.259 KiB/s)
    contents match
    ** Verified OK **
    ** Programming Started **
    auto erase enabled
    wrote 4096 bytes from file C:/Users/jake/OneDrive/Documents/PlatformIO/Projects/Test_JTAG/.pio/build/esp32dev/partitions.bin in 0.702635s (5.693 KiB/s)
    ** Programming Finished **
    ** Verify Started **
    read 3072 bytes from file C:/Users/jake/OneDrive/Documents/PlatformIO/Projects/Test_JTAG/.pio/build/esp32dev/partitions.bin and flash bank 0 at offset 0x00008000 in 0.320941s (9.348 KiB/s)
    contents match
    ** Verified OK **
    ** Programming Started **
    auto erase enabled
    wrote 8192 bytes from file C:/Users/jake/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.760872s (10.514 KiB/s)
    ** Programming Finished **
    ** Verify Started **
    read 8192 bytes from file C:/Users/jake/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.345986s (23.122 KiB/s)
    contents match
    ** Verified OK **
    shutdown command invoked
    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()
    =============================================================================================== [SUCCESS] Took 10.07 seconds ===============================================================================================
    Terminal will be reused by tasks, press any key to close it.

It’s already programmed and verified the flash contents correctly.

You can only step forward if the chip is halted at a breakpoint (or you press the pause button).

Your platformio.ini already contains the tbreak setup instruction. Have you tried pressing th reset button to see if the chip halts at the breakpoint?

Pressing the RST on the esp-prog board didn’t work.
I did notice that the Run > Stop Debugging menu selection was still dim.
I then put a print statement in the code and it printed in the loop.

From there I moved the esp-prog board from one com port to another and also reloaded the blink program.

Then I verified that my DevMgr looked corrected (it did).

I did a restart of the PC and from PIO I did Run > Start Debugging…it performed as expected.

My conclusion is that there’s some PFM (Pure F… Magic) going on but the engineering side of me says it might have been either the Com port or reload of the code.

In the end, it seems to work.

Thanks for everyones input. I spent many hours on trying to get this up and running.

Also from the input of the following:

image

I’ve seen your name while I was trying to get esp-prog up and running. Do you have a website, help group or education connection?

There’s a single page about ESP32 that I’ve written: https://medium.com/@manuel.bl/low-cost-esp32-in-circuit-debugging-dbbee39e508b. It’s mainly about the hardware.

From experience I know that is easy to get something wrong (wiring, PlatformIO configuration, USB drivers etc.). I might compile a troubleshooting guide if I find the time…

I’m possibly interested in your comment: I might compile a troubleshooting guide…

I would be available.

Any Comments?