Using OpenOCD to Debug ESP32S3 Microcontroller

Compile the OpenOCD’s project:

$ git clone https://github.com/espressif/openocd-esp32
$ ./configure --program-prefix=esp32s3- --enable-dummy --enable-ftdi --enable-ftdi-oscan1 --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-ft232r --enable-vsllink --enable-xds110 --enable-osbdm --enable-opendous --enable-esp-usb-jtag --enable-aice --enable-usbprog --enable-rlink --enable-armjtagew --enable-cmsis-dap --enable-kitprog --enable-usb-blaster --enable-presto --enable-openjtag --enable-jlink
$ make
$ make install

This is the way I’m debugging ESP32-S3 using Espressif’s OpenOCD:

$ sudo esp32s3-openocd -c "set ESP_RTOS none" -c "set ESP32_ONLYCPU 1" -c "set ESP_FLASH_SIZE 0" -f board/esp32s3-builtin.cfg

Open a new terminal and run GDB:

$ xtensa-esp32s3-elf-gdb nuttx
GNU gdb (crosstool-NG esp-2021r2) 9.2.90.20200913-git
Copyright (C) 2020 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-esp32s3-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…
(gdb) tar rem :3333
Remote debugging using :3333
0x420042ba in esp32s3_region_protection () at chip/esp32s3_region.c:91
91 {
(gdb) mon reset halt
JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
esp32s3.cpu0: Debug controller was reset.
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
Set GDB target to 'esp32s3.cpu0'
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
esp32s3.cpu1: Debug controller was reset.
esp32s3.cpu1: Core was reset.
esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
(gdb) b __start
Breakpoint 1 at 0x40378750: file chip/esp32s3_start.c, line 190.
(gdb) c
Continuing.
esp32s3.cpu0: Target halted, PC=0x40378750, debug_reason=00000001
Set GDB target to 'esp32s3.cpu0'
esp32s3.cpu1: Target halted, PC=0x40043A40, debug_reason=00000000

Breakpoint 1, __start () at chip/esp32s3_start.c:190
190 {
(gdb) quit

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