Debugging ESP32-S2 with OpenOCD and GDB part 2

This is the OpenOCD command session:

$ esp32s2openocd -s tcl -c 'set ESP_RTOS none' -f esp32s2_saola.cfg -c "init; reset halt"
Open On-Chip Debugger v0.10.0-esp32-20210401-13-g5d011fa5 (2021-05-12-12:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none
adapter speed: 3000 kHz

Info : clock speed 3000 kHz
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Target halted, PC=0x4001AA90, debug_reason=00000000
Info : Detected ESP32-S2 chip
Info : Listening on port 3333 for gdb connections
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 : esp32s2: Target halted, PC=0x4000729B, debug_reason=00000000
Info : esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'gdb' connection on tcp/3333
Info : esp32s2: Target halted, PC=0x40031CAA, debug_reason=00000001
Error: Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031CAA, debug_reason=00000001
Info : esp32s2: Target halted, PC=0x40031CAA, 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=0x40031CAA, debug_reason=00000001
Error: Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031CAA, debug_reason=00000001
Info : Using flash bank 'esp32s2.irom' size 0 KB
Info : esp32s2: Target halted, PC=0x40031CAA, debug_reason=00000001
Error: Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031CAA, debug_reason=00000001
Info : Using flash bank 'esp32s2.drom' size 0 KB
Warn : negative reply, retrying
invalid command name "nuttx.pid_offset"
invalid command name "nuttx.xcpreg_offset"
invalid command name "nuttx.state_offset"
invalid command name "nuttx.name_offset"
invalid command name "nuttx.name_size"
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 : esp32s2: Target halted, PC=0x40007286, debug_reason=00000000
Info : esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : The target is not running when halt was requested, stopping GDB.
Warn : target esp32s2 is not halted (gdb fileio)
Warn : xtensa_write_memory: esp32s2: target not halted
Error: esp32s2: Failed to read insn (-304)!
Error: esp32s2: Failed to remove SW breakpoint (-304)!
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Target halted, PC=0x4001126A, debug_reason=00000000
Info : dropped 'gdb' connection

This is the GDB terminal session:

$ xtensa-esp32-elf-gdb nuttx
GNU gdb (crosstool-NG esp-2020r2) 8.1.0.20180627-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"…
Reading symbols from nuttx…done.
(gdb) target extended-remote :3333
Remote debugging using :3333
0x40000400 in ?? ()
(gdb) symbol-file nuttx
Load new symbol table from "nuttx"? (y or n) y
Reading symbols from nuttx…done.
invalid command name "nuttx.pid_offset"
invalid command name "nuttx.xcpreg_offset"
invalid command name "nuttx.state_offset"
invalid command name "nuttx.name_offset"
invalid command name "nuttx.name_size"
(gdb) mon reset halt
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
esp32s2: Debug controller was reset.
esp32s2: Core was reset.
esp32s2: Target halted, PC=0x40007286, debug_reason=00000000
esp32s2: Core was reset.
esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
(gdb) flushregs
Register cache flushed.
(gdb) b __start
Breakpoint 1 at 0x400226b8: file chip/esp32s2_start.c, line 77.
(gdb) c
Continuing.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
esp32s2: Debug controller was reset.
^C
The target is not running when halt was requested, stopping GDB.
Program received signal SIGINT, Interrupt.
0x40000400 in ?? ()
(gdb) quit
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) y
Detaching from program: /comum/workspace/Espressif/NuttX/nuttx/nuttx, Remote target

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s