I have set up an example project (blinky) to try and get the esp gdbstub working. To do this I set the ESP_SYSTEM_GDBSTUB_RUNTIME in the menuconfig for the project, then flashed and ran idf.py with monitor and did the Ctrl C trick documented. It opened up gdb and I was able to debug just fine which was very exciting! everything worked as expected, it was AWESOME!
I then went back to an old project using platformIO over the top of esp, copied over its builds to the expected places (since it needs - unfortunately - to be built with platformIO’s wrapping build system).
I ran:
Code: Select all
cp .\.pio\build\dev\firmware.elf .\build\<PROJECT_NAME>.elfWhen I do this and use the same trick with Ctrl - C and the serial monitor, it halts the processor and allows me to set breakpoints, but these breakpoints are never ever hit. I know for a fact that these lines of code are being run frequently- they are toggling LED over an MCP once per second which is visible. It also seems kinda glitchy using the gdb prompt. For example, when continuing, the prompt hangs at “continuing” in gdb. You cannot enter any further commands until the prompt returns when you hit Ctrl C again.
I thought that perhaps there might be issues with code inlining and optimisation but in my ini file:
Code: Select all
[build_type_flags]
debug_flags = -D${compile_option_flags.debug} -O0 ; Turn off
optimisations -g3 ; All debug information
...
[env:dev]
build_type = debug
build_flags = ${common.build_flags} ${build_type_flags.debug_flags}later, reading the pio documentation on pio debug I ran the following:
Code: Select all
(penv) PS C:<MY_PATH_TO_MY_PROJECT>> pio debug --interface=gdb
C:\Users\<MY_USER>\.platformio\packages\toolchain-xtensa-esp32\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from C:<MY_PATH_TO_MY_PROJECT>\.pio\build\dev\firmware.elf...
(gdb) target remote COM3
Remote debugging using COM3
0x4019480e in esp_pm_impl_waiti ()
at C:\Users\<MY_USER>\.platformio\packages\framework-espidf\components\hal\esp32\include/hal/cpu_ll.h:183
183 asm volatile ("waiti 0\n");
(gdb) continue
Continuing.Any advice to get this working? I'd really appreciate any and all guidance since I have been stuck for a few days now trying to get this set up working. In some of our projects JTAG isn't always feasible and this would be a dream come true to be able to do some debugging over serial even if I can only set one breakpoint at a time!