platformio / platform-espressif32

Espressif 32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif32
Apache License 2.0
855 stars 570 forks source link

Debugging not hitting breakpoints #1392

Open aaron-neal opened 2 weeks ago

aaron-neal commented 2 weeks ago

I am trying to debug an ESP32-S2 board. I have succesfully connected the ESP-PROG board and can perfectly program the ESP32 from VS Code over ESP-PROG.

When i press debug, everything seems to work fine, except no breakpoints get hit in VS Code, it seems as if the debugger connects, but doesn't attach to VScode.

platformio.ini

debug_tool = esp-prog
upload_protocol = esp-prog
debug_init_break = tbreak setup

Debug Console log

Processing dev (board: esp32-s2-saola-1; platform: espressif32; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s2-saola-1.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S2-Saola-1
HARDWARE: ESP32S2 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (cmsis-dap, esp-bridge, 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:
....
....
....
esptool.py v4.5.1
Creating esp32s2 image...
Merged 2 ELF sections
Successfully created esp32s2 image.
========================= [SUCCESS] Took 8.11 seconds =========================

Environment    Status    Duration
-------------  --------  ------------
dev            SUCCESS   00:00:08.107
========================= 1 succeeded in 00:00:08.107 =========================
Reading symbols from C:\Users\...\Documents\GitHub\...\.pio\build\dev\******.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target...
Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz

adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 5000 kHz
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : starting gdb server for esp32s2 on pipe
Info : accepting 'gdb' connection from pipe
Info : [esp32s2] Target halted, PC=0x400DADE2, debug_reason=00000000
Memory protection is enabled. Reset target to disable it...
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] requesting target halt and executing a soft reset
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x400004F5, debug_reason=00000000
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
Warn : No symbols for FreeRTOS!
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f000020, 119 KB
Info : Flash mapping 1: 0x30020 -> 0x40080020, 369 KB
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : Auto-detected flash bank 'esp32s2.flash' size 4096 KB
Info : Using flash bank 'esp32s2.flash' size 4096 KB
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f000020, 119 KB
Info : Flash mapping 1: 0x30020 -> 0x40080020, 369 KB
Info : Using flash bank 'esp32s2.irom' size 372 KB
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f000020, 119 KB
Info : Flash mapping 1: 0x30020 -> 0x40080020, 369 KB
Info : Using flash bank 'esp32s2.drom' size 120 KB
0x40000400 in ?? ()
Loading section .dram0.data, size 0x2a30 lma 0x3ffc0b60
Loading section .iram0.vectors, size 0x403 lma 0x40024000
Loading section .iram0.text, size 0xc758 lma 0x40024404
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] requesting target halt and executing a soft reset
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40007299, debug_reason=00000000
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1010 ms). Workaround: increase "set remotetimeout" in GDB
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1013 ms). Workaround: increase "set remotetimeout" in GDB
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : PROF: Erased 122880 bytes in 1598.49 ms
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] requesting target halt and executing a soft reset
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x400004F9, debug_reason=00000000
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1032 ms). Workaround: increase "set remotetimeout" in GDB
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : PROF: Erased 380928 bytes in 2694.44 ms
Loading section .flash.appdesc, size 0x100 lma 0x3f000020
Loading section .flash.rodata, size 0x1db08 lma 0x3f000120
Loading section .flash.text, size 0x5c5bf lma 0x40080020
Info : PROF: Compressed 121864 bytes to 33137 bytes in 1.999000ms
Info : PROF: Data transferred in 327.764 ms @ 98.7306 KB/s
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : PROF: Wrote 121864 bytes in 2418.25 ms (data transfer time included)
Info : PROF: Compressed 378303 bytes to 250912 bytes in 11.001000ms
Info : PROF: Data transferred in 2601.17 ms @ 94.2004 KB/s
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001
Info : PROF: Wrote 378303 bytes in 4488.85 ms (data transfer time included)
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] requesting target halt and executing a soft reset
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x400004F5, debug_reason=00000000
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
Start address 0x400272bc, load size 563026
Transfer rate: 35 KB/sec, 14436 bytes/write.
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32s2] requesting target halt and executing a soft reset
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
[esp32s2] requesting target halt and executing a soft reset
Info : [esp32s2] Debug controller was reset.
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x400004F5, debug_reason=00000000
[esp32s2] Debug controller was reset.
[esp32s2] Core was reset.
[esp32s2] Target halted, PC=0x400004F5, debug_reason=00000000
Info : [esp32s2] Core was reset.
Info : [esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
[esp32s2] Core was reset.
[esp32s2] Target halted, PC=0x40000400, debug_reason=00000000
Temporary breakpoint 1 at 0x4008afd0: setup. (2 locations)
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak setup`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Info : [esp32s2] Target halted, PC=0x40031E92, debug_reason=00000001

However, it appears the code isn't halted (watchdog LED is flashing) and no breakpoints are hit, including at setup.

Any help greatly appreciated.

image
valeros commented 2 weeks ago

Hi @aaron-neal, does it work if you remove the debug_init_break option?

aaron-neal commented 2 weeks ago

Hi @valeros, thanks for getting back to me. I will have to check later today, I did however notice the "2 locations" for the setup function so I renamed one of the functions in a library to see if this was the issue, but still did not work.

I also span up a linux VM to test and I had the same issue as on my Windows install.

I haven't tried with a simple blink sketch yet, but plan to do that as well.