-
Notifications
You must be signed in to change notification settings - Fork 150
Description
Development Kit
AZ-Delivery ESP32 NodeMCU
Module or chip used
ESP32-WROOM-32
Debug Adapter
Glasgow Interface Explorer
OpenOCD version
v0.12.0-esp32-20250422
Operating System
MacOS
Using an IDE ?
no (well actually yes, the Arduino IDE v2.3.2 but only for building the code and generating the image; and having ESP IDF tools available)
OpenOCD command line
./openocd -c 'adapter driver remote_bitbang; transport select jtag' -c 'remote_bitbang port 2222' -c 'reset_config none' -f target/esp32.cfg
JTAG Clock Speed
default
ESP-IDF version
v5.5-b66b5448-v1
Problem Description
Hi all!
I've so far only worked with ESP32 from the Arduino IDE or static analysis tools. I'd now like to try dynamic analysis/debugging. I haven't tried to start a debugging session from within the Arduino IDE because I think this way me even be harder and only supported by Arduino boards that have USB/serial + USB/JTAG, but I don't know.
I am using the Glasgow Interface Explorer (short: Glasgow) as the debugger. It comes with the jtag-openocd applet.
- This is what the code in the Arduino sketch looks like:
const char test[] = {0x12, 0x34, 0x56, 0x78};
char test2[] = {0x9A, 0xBC, 0xDE, 0xF0};
void setup() {
Serial.begin(115200);
Serial.println("JTAG test");
memset(test2, 0, sizeof(test2));
Serial.println("another print statement");
memcpy(test2, test, sizeof(test));
}
void loop() {
delay(1000);
Serial.println("hello from loop");
}
- Run glasgow CLI:
glasgow run jtag-openocd tcp:localhost:2222 -VA=3.3
I: g.hardware.device: device already has bitstream ID 39b48083453360847041bf7998bf34a2
I: g.hardware.assembly: port A voltage set to 3.3 V
I: g.cli: running handler for applet 'jtag-openocd'
I: g.applet.bridge.jtag_openocd: socket: listening at tcp:localhost:2222
- Run OpenOCD:
(from /Users/<redacted>/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20250422/bin)
./openocd -c 'adapter driver remote_bitbang; transport select jtag' -c 'remote_bitbang port 2222' -c 'reset_config none' -f target/esp32.cfg
Open On-Chip Debugger v0.12.0-esp32-20250422 (2025-04-22-13:11)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Initializing remote_bitbang driver
Info : Connecting to localhost:2222
Info : remote_bitbang driver initialized
Info : Note: The adapter "remote_bitbang" doesn't support configurable speed
Info : JTAG tap: esp32.tap0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.tap1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] Examination succeed
Info : [esp32.cpu1] Examination succeed
Info : [esp32.cpu0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0xFFFFFFFF, debug_reason=00000003
Error: [esp32.cpu0] Timed out waiting for CPU to be reset, target state=2
Info : [esp32.cpu0] Reset cause (52) - (Unknown reset cause)
Warn : [esp32.cpu0] Timed out waiting for target to finish stepping. dsr=0x8000c000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0xFFFFFFFF, debug_reason=00000003
Error: [esp32.cpu1] Timed out waiting for CPU to be reset, target state=2
Warn : [esp32.cpu1] Timed out waiting for target to finish stepping. dsr=0x8000c000
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0xFFFFFFFF, debug_reason=00000003
Error: [esp32.cpu0] Timed out waiting for CPU to be reset, target state=2
Info : [esp32.cpu0] Reset cause (52) - (Unknown reset cause)
Warn : [esp32.cpu0] Timed out waiting for target to finish stepping. dsr=0x8000c000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
^C^C^CInfo : [esp32.cpu1] Target halted, PC=0x40085B36, debug_reason=00000000
Error: [esp32.cpu1] Timed out waiting for CPU to be reset, target state=2
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
shutdown command invoked
Info : remote_bitbang interface quit
I guess the debugger connection is working (glasgow CLI shows I: g.applet.bridge.jtag_openocd: socket: new connection from [::1]:52541 in its log) and the JTAG hardware wiring and JTAG chain connection also (JTAG tap: esp32.tap[0|1] tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)). The issue seems to be that the controller keeps resetting.
- Connect to the serial interface:
hello from loop␍␊
hello from loop␍␊
hello from loop␍␊
ets Jun 8 2016 00:22:57␍␊␍␊rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)␍␊configsip: 0, SPIWP:0xee␍␊clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00␍␊mode:DIO, clock div:1␍␊load:0x3fff0030,len:4980␍␊load:0x40078000,len:16612␍␊load:0x40080400,len:3480␍␊entry 0x400805b4␍␊
JTAG test␍␊another print statement␍␊
hello from loop␍␊
ets Jun 8 2016 00:22:57␍␊␍␊rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)␍␊configsip: 0, SPIWP:0xee␍␊clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00␍␊mode:DIO, clock div:1␍␊load:0x3fff0030,len:4980␍␊load:0x40078000,len:16612␍␊load:0x40080400,len:3480␍␊entry 0x400805b4␍␊
JTAG test␍␊another print statement␍␊
hello from loop␍␊
ets Jun 8 2016 00:22:57␍␊␍␊rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)␍␊configsip: 0, SPIWP:0xee␍␊clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00␍␊mode:DIO, clock div:1␍␊load:0x3fff0030,len:4980␍␊load:0x40078000,len:16612␍␊load:0x40080400,len:3480␍␊entry 0x400805b4␍␊
JTAG test␍␊another print statement␍␊
hello from loop␍␊
hello from loop␍␊
I guess that the line containing TG1WDT_SYS_RESET comes from the bootloader and indicates a WDT reset. Those messages don't appear when I don't run openocd - the target keeps printing hello from loop instead.
Do I need to add some extra step to deactivate WDTs while debugging?
I've seen the section JTAG and ESP32-WROOM-32 AT Firmware Compatibility Issue in ESP-IDF Programming Guide > API Guides > JTAG Debugging> Tips and Quirks. Is this relevant for me? How can I check for "AT Firmware"?
- Run gdb:
Continuing here probably only makes sense as soon as the other issues above have been resolved.
(from /Users/<redacted>/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/16.2_20250324/bin)
$ ./xtensa-esp32-elf-gdb -q -x build/gdbinit/symbols -x build/gdbinit/prefix_map -x build/gdbinit/connect /private/var/folders/8f/6c1j5jjs1gxdt8vbhzg6zxq80000gn/T/arduino/sketches/812687EBCD8B49EB2B69EED10F84C171/esp32JtagTest.ino.elf
Reading symbols from /private/var/folders/8f/6c1j5jjs1gxdt8vbhzg6zxq80000gn/T/arduino/sketches/812687EBCD8B49EB2B69EED10F84C171/esp32JtagTest.ino.elf...
build/gdbinit/symbols: No such file or directory.
build/gdbinit/prefix_map: No such file or directory.
build/gdbinit/connect: No such file or directory.
(gdb) break app_main
Breakpoint 1 at 0x400d31f7: file /Users/<redacted>/Library/Arduino15/packages/esp32/hardware/esp32/3.3.0/cores/esp32/main.cpp, line 89.
(gdb) mon reset halt
"monitor" command not supported by this target.
(gdb) run
Don't know how to run. Try "help target".
(gdb)
I think I need some pointers what build/gdbinit refers to. Is this a build-specific folder full of symbols that should be loaded? Or have those files been pre-built for the specific gdb environment?
Why the '"monitor" command not supported by this target' and the 'Don't know how to run'? What am I missing here? Do I really need to flash beforehand? Because the whole image has been generated and flashed to the SPI flash by the Arduino IDE using esptool before.
Your help is very much appreciated!
Debug Logs
see aboveExpected behavior
- WDT does not reset the MCUs when OpenOCD is connected
- GDB can reset the target and start code execution
Screenshots
No response