ESP32 Debugging doesn't start on platformio


So I am having a hard time getting debugging to work on the esp32 with platform IO.

I am using an esp-prog jtag interface, and I have a new ESP32DevKitE.

I followed the instructions here: Get started with Arduino and ESP32-DevKitC: debugging and unit testing — PlatformIO latest documentation

I am able to get the launch.json to populate and it builds and even flashes properly using openOCD when I use the upload command, but when I run the debugger, the little transport control pops up, the device compiles, flashes and then exits.

I did a bit of digging, and i found where it is exiting. Inside of platformio/commands/debug/, on line 92 there is a snippet of code where it exits:

if not interface:
    return helpers.predebug_project(ctx, project_dir, env_name, False, verbose)

I believe that interface is supposed to be "GDB’ but for whatever reason, when I click the run button on the PIO debug task, it is not set, and I can’t for the life of me figure out how it should be set.

if i run pio debug --interface ‘gbd’ it dumps me out to a gdb prompt in the terminal, but i wanted to be able to set breakpoints and stuff with the GUI.

Any help would be greatly appreciated!
Thank you!

Is your platformio.ini 1:1 what is described in the tutorial? A olimex-arm-usb-ocd-h as debug tool? What is the full output in the “Output” and “Debug Console” tabs of PlatformIO?

Does the behavior change if you use the latest PlatformIO dev version? (CLI and pio upgrade --dev).

good point! My platform.ini is not 1:1, I am using the esp-prog for JTAG. I posted the requested info below. The Debug Console is completely empty in this case. I am about to switch to the dev version and see if that helps: Edit: Tried the dev version, and that diddn’t help.

I suspect line 58 in command .py is not getting the correct argument for --interface:

 @click.option("--interface", type=click.Choice(["gdb"]))

Here is my platformio.ini:

platform = espressif32
board = esp32dev
framework = espidf
monitor_speed = 115200
monitor_port = /dev/cu.usbserial-14240
upload_speed = 921600
debug_tool = esp-prog
debug_init_break = tbreak setup
upload_protocol = esp-prog

And here is the output of the terminal tab:

> Executing task in folder esp32_pio_debugtest: platformio debug <
Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.2.0) > 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-espidf 3.40200.210118 (4.2.0) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-ninja 1.9.0 
 - tool-openocd-esp32 2.1000.20201202 (10.0) 
 - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 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:   [          ]   3.3% (used 10812 bytes from 327680 bytes)
Flash: [==        ]  15.7% (used 164336 bytes from 1048576 bytes)
================================================= [SUCCESS] Took 10.32 seconds =================================================

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

And the debug console is empty…

if put this extra line in, when I click the button I can get it to spawn a GDB console, but its in the terminal, and its not connected up to the debug console output

interface = "gdb"
if not interface:
    return helpers.predebug_project(ctx, project_dir, env_name, False, verbose)

am I correct to say that esp-prog is not supported for jtag debugging with the esp32dev board?

I feel like there is something missing here. GDB never launches, and I would think its a simple task modification but I can’t for the life of me figure out where to made those modifications.

for now, I am going to try and go back to the esp-idf vscode extension to try and get debug working.

ESP-Prog debugging works, I’ve personally tested it, e.g. in ESP-Prog debugger issue. No visible error. (Ubuntu) - #41 by maxgerhardt

What happens when you drop into a CLI and execute

pio upgrade --dev
pio debug --interface=gdb -x .pioinit

in the project’s root directory?

This starts OpenOCD and GDB, and should show an error if there is some.

If there is not, you’ve likely installed a conflicting VSCode extension, as in the linked topic.

I’ve got the same problem. I tried :

pio upgrade --dev
pio debug --interface=gdb -x .pioinit

It starts. Why PIO threw launch.json configuration “PIO Debug” does not start debug ? Only build in debug mode.

If it helps, I’m on MacOS

Most of the cases where the commandline pio debug --interface=gdb -x .pioinit works but not via the VSCode GUI are caused by having conflicting extensions installed. Does this also occur when just having C++ by Microsoft and PlatformIO as the only VSCode extensions?

I’ve tested now, with no plugin except PlatformIO. It goes further. Now, I think it’s not a problem of PlatformIO.

The problem is the interaction between PlatformIO plugin and other. I’ll check which one is faulty