Unknown Source ESP32 JTAG Debug

Hello,

I am using ESP-WROVER-KIT to debug my ESP32 projects. I’ve already put this thing to work with a simpler code, like blink example. Everything debugs just fine with it.

However, when I’m trying to debug another code, wich uses WiFi features of ESP32, it doesn’t work properly. The code compiles and is flashed to ESP, then the Debug Tool initialize, but after it, the debug session does not follow my code. It does not stop at void setup() neither at any breakpoints I try to insert.

If I Pause, Call Stack fills with adress with Unknown Source and I get the message on console:

Program received signal
SIGINT, Interrupt.
0x40009034 in ?? ()

If I Step Out, I get the message:

Error: esp32: Failed to read insn (-4)!
Error: esp32: Failed to add SW BP!
Error: can't add breakpoint: resource not available

I tried to insert gdb_breakpoint_override hard on .platformio\packages\tool-openocd-esp32\share\openocd\scripts\target\esp32.cfg . By doing that, it doesn’t give me any errors, but it doesn’t work as well.

Here is the Debug Console:

Reading symbols from c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/firmware.elf…
done.
PlatformIO Unified Debugger → hhttp://bit.ly/pio-debug
PlatformIO: Initializing remote target…
Open On-Chip Debugger v0.10.0-esp32-20190313 (2019-03-13-09:57)
Licensed under GNU GPL v2
For bug reports, read
hhttp://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : tcl server disabled
Info : telnet server disabled
Info : ftdi: if you experience problems at higher adapter clocks, try the command “ftdi_tdo_sample_edge falling”
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : accepting ‘gdb’ connection from pipe
Error: No symbols for FreeRTOS
Info : Target halted. PRO_CPU: PC=0x40009087 (active) APP_CPU: PC=0x400076DD
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x400076DD
Info : Flash mapping 0: 0x10020 → 0x3f400020, 239 KB
Info : Flash mapping 1: 0x50018 → 0x400d0018, 760 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x400076DD
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x400076DD
Info : Flash mapping 0: 0x10020 → 0x3f400020, 239 KB
Info : Flash mapping 1: 0x50018 → 0x400d0018, 760 KB
Info : Using flash size 764 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x400076DD
Info : Flash mapping 0: 0x10020 → 0x3f400020, 239 KB
Info : Flash mapping 1: 0x50018 → 0x400d0018, 760 KB
Info : Using flash size 240 KB
0x40009087 in ?? ()
Temporary breakpoint 1 at 0x400e2388: file src\main.cpp, line 312.
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 20480 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.985057s (20.303 KiB/s)
wrote 20480 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.985057s (20.303 KiB/s)
** Programming Finished **
** Verify Started **
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 16848 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.303018s (54.298 KiB/s)
contents match
** Verified OK **
read 16848 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.303018s (54.298 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 4096 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/partitions.bin in 0.594033s (6.734 KiB/s)
wrote 4096 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/partitions.bin in 0.594033s (6.734 KiB/s)
** Programming Finished **
** Verify Started **
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 3072 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/partitions.bin and flash bank 0 at offset 0x00008000 in 0.237014s (12.657 KiB/s)
contents match
** Verified OK **
read 3072 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/partitions.bin and flash bank 0 at offset 0x00008000 in 0.237014s (12.657 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 8192 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.679039s (11.781 KiB/s)
wrote 8192 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.679039s (11.781 KiB/s)
** Programming Finished **
** Programming Finished **
** Verify Started **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 8192 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.529031s (15.122 KiB/s)
contents match
read 8192 bytes from file C:/Users/Deividi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.529031s (15.122 KiB/s)
contents match
** Verified OK **
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 1122304 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/firmware.bin in 10.819619s (101.297 KiB/s)
wrote 1122304 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/firmware.bin in 10.819619s (101.297 KiB/s)
** Programming Finished **
** Verify Started **
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 1118800 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/firmware.bin and flash bank 0 at offset 0x00010000 in 3.886223s (281.141 KiB/s)
contents match
** Verified OK **
read 1118800 bytes from file c:/Users/Deividi/Documents/PlatformIO/Projects/esp-conectado/.pio/build/esp32dev/firmware.bin and flash bank 0 at offset 0x00010000 in 3.886223s (281.141 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
PlatformIO: Initialization completed
PlatformIO: Resume the execution to debug_init_break = tbreak setup
PlatformIO: More configuration options → Redirecting...
Note: automatically using hardware breakpoints for read-only addresses.
Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again.
Info : Target halted. PRO_CPU: PC=0x40009034 (active) APP_CPU: PC=0x400076E2
Target halted. PRO_CPU: PC=0x40009034 (active) APP_CPU: PC=0x400076E2

Program received signal
SIGINT, Interrupt.
0x40009034 in ?? ()

Error: esp32: Failed to read insn (-4)!
Error: esp32: Failed to add SW BP!
Error: can’t add breakpoint: resource not available

I have the same problem. ESP-WROVER-KIT, Win7 64Bit, Visual Studio Code with platformIO, IDF. With a few lines of code (15-20 lines) debugging and breakpoints worked in most of the cases. If I have more code stepover worked but several times it stopped in a freertos library instead at the next line and a breakpoint is ignored in most cases, even when I set it after doing some stepovers. A breakpoint in an own thread was always ignored if I have more than the simple 20 lines of code. I bought the ESP-WROVER-KIT to be able to use onchip debugging, but it seems this is makes no sense.

Is there anybody where the JTAG debugging with the ESP-WROVER-KIT works stable on bigger source codes?

See ‘tips and quirks’ Tips and Quirks - ESP32 - — ESP-IDF Programming Guide latest documentation

Do you have theh same error as above?

I got this error one time. But the common behavior is likedeivdi21 described it:

One difference is: I use IDF. The debugger stops at void main() as expected but breakpoints are ignored in nearly every case (I tried one breakpoint only, defined before start debugging and also defining it after some stepover steps).

Very mysterious! I checked how ota partitions or the cpu frequency influences that behavior. First it seems no ota partition and 80 MHz will solve the problems. At the end I had my old problematical configuration with ota partitions and 240 MHz and now it works. I have no idea why now and not in the past.

I have the same problem.

The environment is as follows.

  • Windows10-64bit
  • Visual Studio Code with platformIO
  • ESP-WROOM-32(Flash memory:4MB)
  • FT2232D

The same problem occurred with IDF and Arduino.

I tried on some Windows 10 devices, but the same problem occurs.

Does debugger stop at app_main()?

I also had this problem. Ive been trying to get esp32 debugging working the past few nights.

First I had to update with the dev release to fix the filename \ issue (im now using pio 4.0.3b1).

Then I ran into this issue. I found an old bug report that “gdb_breakpoint_override hard” was missing from the esp32.cfg . It should of been fixed a long time ago but when I checked my esp32.cfg it was not there. So I added it and its now working !
so check <user..platformio\packages\tool-openocd-esp32\share\openocd\scripts\target\esp32.cfg
and if it does not have “gdb_breakpoint_override hard” try adding it (I added it to line 4).

Are you sure that use the latest openOCD for ESP32? Could you open PlatformIO IDE Terminal and type

pio update

My understanding is that gdb_breakpoint_override hard was deliberatly removed more than a year ago for good (see esp32: Adds support for SW breakpoints in flash · espressif/openocd-esp32@fa6cf62 · GitHub). OpenOCD should now be aware of the memory layout and automatically pick between hardware breakpoints for flash areas and software breakpoints for RAM.

It’s surprising that it seems fix certain problems. In my experience, debugging the ESP32 isn’t the most reliable thing (especially compared to ARM based microcontrollers). But I don’t really understand the cause of the problem: whether it’s a hardware issue, an OpenOCD issue or a problem with the VS Code integration, or a mix of all of them…

We have just released PlatformIO Core 4.0.3 which fixes PIO Unified Debugger on Windows.

We use the same GDB backend for ARM, RISC-V, ESP32, etc. The only ESP32 has issues. What I see in their docs:

ESP32 debugger supports 2 hardware implemented breakpoints and 64 software ones.

Tips and Quirks - ESP32 - — ESP-IDF Programming Guide latest documentation

and

When stepping through the code with next command, GDB is internally setting a breakpoint (one out of two available) ahead in the code to bypass the subroutine calls.

Tips and Quirks - ESP32 - — ESP-IDF Programming Guide latest documentation

So, as I understand correctly, it’s better to remove ALL breakpoints before doing debugging. Then, when program is started is better to keep only 2 active breakpoints.

OK upgrading seems to fix it, I don’t need the “gdb_breakpoint_override hard” . I can’t really explain this as the ocd version seems the same. Anyway I’m happy I have it working I hope the others users who had issues also have it resolved :slight_smile:

2 Likes