Debugging via custom debug tool

Hi!
I’m currently trying to get OpenOCD working with the ESP32 on windows (in visual studio code/PIO), and while i am making some progress, the whole process is really slow when the entire project is rebuilt every time i try to debug.
Is there any way to configure platformIO so it doesn’t try to recompile the whole project when i launch a debug session, i just want it to assume that the correct firmware is on the target.

What is your platformio.ini?

Hi Ivan
It looks like this:

[env:esp32thing]
platform = espressif32
board = esp32thing
framework = espidf
monitor_baud = 115200
upload_speed=921600
debug_init_cmds =
debug_tool = custom
debug_extra_cmds =
break main.cpp:13
debug_load_cmd =
debug_server =
$PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd <-- this .exe is overwritten with a cross compiled version of the ESP-IDF version of OpenOCD
-s
path-to-OpenOCDDir/tcl
-f
path-to-OpenOCDDir/share/openocd/scripts/interface/ftdi/esp32_devkitj_v1.cfg
-f
path-to-OpenOCDDir/share/openocd/scripts/board/esp32-wrover.cfg

Could you provide a log from Debug Console where yo usee that PIO rebuilds whole project each time. We check project before debugging and rebuild only changed files.

Yes that seems to be true, but it also looks like any change to the platformio.ini also triggers a complete rebuild, which is very time consuming when testing out different debugger options. It could be very useful to have a option to skip recompiling alltogether.

Yes, that is OK by design. If you change a configuration file, we will rebuild a whole project. We don’t track which lines in INI file were changed. It could be “build_flags” option or other which affects build environment.


Which debug JTAG probe do you use to debug ESP32?

This is true but it does make it very tedius from a developer perspective when testing out a brand new configuration with many unknowns. I spent 3 hours on testing debugging the other day with probably 90% of the time waiting for the system to build the same unchanged project. I’m just saying that some sort of manual override would be nice :slight_smile:

I’m trying to debug using the built-in debugging interface on the ESP-WROVER-KIT development board. It can be brought to work on windows with an external OpenOCD debugging server running in Mingw32 with a platformio.ini configuration to connect to the server on localhost:3333.
However i just switched workstations and now i’m unable to properly connect to the external debugging server in Visual Studio Code (it just crashes/exits on any interaction).

Since then i’ve tried to crosscompile OpenOCD with the workspace package from Espressif (from here: GitHub - espressif/openocd-esp32: OpenOCD branch with ESP32 JTAG support). I think modified the platform configuration for the ESP32 in PlatformIO to include openOCD as a custom debug tool and then overwrote the .exe downloaded by PlatformIO.

It almost works (i can set a manual breakpoint), but it seems like there is some information missing when debugging, i can’t set breakpoints at runtime and can’t see variables or threads (using the UI anyway). I think my knowledge of hardware debugging has reached its limit at this point and i’m now considering running my entire development environment in a VM instead :confused:

Why do you change platformio.ini each time? Normally, you configure your project and dependencies one time and no need to change it for a few months.

Espressif team still works on OpenOCD for ESP32 and there is no final release. We tried many times the latest development build and there a lot of problems.

The OpenOCD executable can take a number of options on launch, getting the correct ones for “debug_server=” or debug_extra_cmds=" can take a lot of trial and error.

Getting a reliable upload speed (depending on the cable used etc) can also take a few attempts, where it also doesn’t make a lot of sense to recompile the entire project, monitor_baud can also be experimented with at times.