tmedicci opened a new pull request, #16234: URL: https://github.com/apache/nuttx/pull/16234
## Summary This PR adds new fields to the metadata section used by MCUBoot. The openocd-esp32 project requires these fields to properly map the flash segments and enable using SW breakpoints and flash through openocd-esp32. MCUboot version was also updated and the corresponding documentation for each SoC too. ## Impact Impact on user: YES. Now users can add SW-defined breakpoints (in addition to the already existing HW breakpoints) Impact on build: NO. Impact on hardware: YES. It enables it for all supported Espressif SoCS. Impact on documentation: YES. The command used for `openocd-esp32` has changed. Documentation is provided for it. Impact on security: NO. Impact on compatibility: NO. ## Testing Please, follow documentation for debugging each SoC. For ESP32-S3, for instance, the instructions are available [here](https://nuttx.apache.org/docs/latest/platforms/xtensa/esp32s3/index.html#debugging-with-openocd-and-gdb): ### Building Following the instructions for ESP32-S3-DevKitC-1 board, build the firmware with `CONFIG_DEBUG_SYMBOLS=y`: ``` make -j distclean && ./tools/configure.sh esp32s3-devkit:mcuboot_nsh && kconfig-tweak -e DEBUG_SYMBOLS && make olddefconfig && make bootloader && make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_PORT=/dev/ttyUSB0 ESPTOOL_BINDIR=./ -s -j$(nproc) ``` ### Running Open another terminal to run `openocd-esp32`: ``` openocd -s tcl -c 'set ESP_RTOS hwthread' -f board/esp32s3-builtin.cfg -c 'init; reset halt; esp appimage_offset 0x10000' ``` Then, create the `gdbinit` file with the following content: ``` target remote :3333 set remote hardware-watchpoint-limit 2 mon reset halt flushregs monitor reset halt thb nsh_main c ``` And, on another terminal, run GDB: ``` xtensa-esp32s3-elf-gdb -x ./gdbinit --tui nuttx ``` Insert breakpoints for the `ls`, `ps` and `help` NSH's commands on GDB: ``` b cmd_ls b cmd_ps b cmd_help ``` Finally, on NuttX's NSH terminal, type those commands and check the program being halted on GDB. ### Results The device is expected to properly halt the program's execution when the software breakpoints are reached: #### GDB log ``` Thread 1 "esp32s3.cpu0" hit Temporary breakpoint 1, nsh_main (argc=1107319712, argv=0x1) at nsh_main.c:54 +b cmd_ls Breakpoint 2 at 0x42008b7c: file nsh_fscmds.c, line 1524. Note: automatically using hardware breakpoints for read-only addresses. +b cmd_ps Breakpoint 3 at 0x42009df0: file nsh_proccmds.c, line 862. +b cmd_help Breakpoint 4 at 0x42007330: file nsh_command.c, line 998. +c Continuing. [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x42008B7C, debug_reason=00000001 Set GDB target to 'esp32s3.cpu0' [esp32s3.cpu1] Target halted, PC=0x40043A3B, debug_reason=00000000 Thread 1 "esp32s3.cpu0" hit Breakpoint 2, cmd_ls (vtbl=0x3fc8c530, argc=1, argv=0x3fc8c1a0) at nsh_fscmds.c:1524 +c Continuing. [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x42009DF0, debug_reason=00000001 Set GDB target to 'esp32s3.cpu0' [esp32s3.cpu1] Target halted, PC=0x40043A3B, debug_reason=00000000 Thread 1 "esp32s3.cpu0" hit Breakpoint 3, cmd_ps (vtbl=0x3fc8c530, argc=1, argv=0x3fc8c1a0) at nsh_proccmds.c:862 +c Continuing. [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x42007330, debug_reason=00000001 Set GDB target to 'esp32s3.cpu0' [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Thread 1 "esp32s3.cpu0" hit Breakpoint 4, cmd_help (vtbl=0x3fc8c530, argc=1, argv=0x3fc8c1a0) at nsh_command.c:998 +c Continuing. [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 [esp32s3.cpu0] Target halted, PC=0x42013466, debug_reason=00000000 Set GDB target to 'esp32s3.cpu0' [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Thread 1 "esp32s3.cpu0" received signal SIGINT, Interrupt. up_idle () at chip/esp32s3_idle.c:221 ``` #### `openocd-esp32` log ``` Open On-Chip Debugger v0.12.0-esp32-20241016-315-gab6be67b (2025-04-10-17:18) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html hwthread Info : only one transport option; autoselecting 'jtag' Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001 Info : esp_usb_jtag: capabilities descriptor set to 0x2000 Info : [(null)] Hardware thread awareness created Info : [(null)] Hardware thread awareness created Info : esp_usb_jtag: serial (7C:DF:A1:E7:27:5C) Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255 Info : clock speed 40000 kHz Info : JTAG tap: esp32s3.tap0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32s3.tap1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : [esp32s3.cpu0] Examination succeed Info : [esp32s3.cpu1] Examination succeed Info : [esp32s3.cpu0] starting gdb server on 3333 Info : Listening on port 3333 for gdb connections Info : JTAG tap: esp32s3.tap0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32s3.tap1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : [esp32s3.cpu0] requesting target halt and executing a soft reset Info : [esp32s3.cpu0] Debug controller was reset. Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x42013466, debug_reason=00000000 Info : Set GDB target to 'esp32s3.cpu0' Info : [esp32s3.cpu1] Debug controller was reset. Info : [esp32s3.cpu1] Core was reset. Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Info : [esp32s3.cpu1] Reset cause (1) - (Power on reset) Info : [esp32s3.cpu0] Debug controller was reset. Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x500000EF, debug_reason=00000000 Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Debug controller was reset. Info : [esp32s3.cpu1] Core was reset. Info : [esp32s3.cpu1] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Using flash bank 'esp32s3.cpu0.irom' size 80 KB Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Using flash bank 'esp32s3.cpu0.drom' size 12 KB Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Auto-detected flash bank 'esp32s3.cpu0.flash' size 8192 KB Info : Using flash bank 'esp32s3.cpu0.flash' size 8192 KB Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Using flash bank 'esp32s3.cpu1.irom' size 80 KB Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Using flash bank 'esp32s3.cpu1.drom' size 12 KB Info : [esp32s3.cpu0] Target halted, PC=0x4038CCA2, debug_reason=00000001 Info : Flash mapping 0: 0x40000 -> 0x3c040000, 10 KB Info : Flash mapping 1: 0x20000 -> 0x42000000, 79 KB Info : Auto-detected flash bank 'esp32s3.cpu1.flash' size 8192 KB Info : Using flash bank 'esp32s3.cpu1.flash' size 8192 KB Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : accepting 'gdb' connection on tcp/3333 Info : New GDB Connection: 1, Target esp32s3.cpu0, state: halted Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333" Info : JTAG tap: esp32s3.tap0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32s3.tap1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : [esp32s3.cpu0] requesting target halt and executing a soft reset Info : [esp32s3.cpu0] Debug controller was reset. Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x500000EF, debug_reason=00000000 Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Debug controller was reset. Info : [esp32s3.cpu1] Core was reset. Info : [esp32s3.cpu1] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : JTAG tap: esp32s3.tap0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32s3.tap1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : [esp32s3.cpu0] requesting target halt and executing a soft reset Info : [esp32s3.cpu0] Debug controller was reset. Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x500000EF, debug_reason=00000000 Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Core was reset. Info : [esp32s3.cpu0] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Debug controller was reset. Info : [esp32s3.cpu1] Core was reset. Info : [esp32s3.cpu1] Target halted, PC=0x40000400, debug_reason=00000000 Info : [esp32s3.cpu1] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset) Info : [esp32s3.cpu0] Target halted, PC=0x42005BA0, debug_reason=00000001 Info : Set GDB target to 'esp32s3.cpu0' Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x42007330, debug_reason=00000001 Info : Set GDB target to 'esp32s3.cpu0' Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x42008B7C, debug_reason=00000001 Info : Set GDB target to 'esp32s3.cpu0' Info : [esp32s3.cpu1] Target halted, PC=0x40043A3E, debug_reason=00000000 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x42009DF0, debug_reason=00000001 Info : Set GDB target to 'esp32s3.cpu0' Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCB6, debug_reason=00000001 Info : [esp32s3.cpu0] Target halted, PC=0x4038CCF6, debug_reason=00000001 ``` Note that the "Flash mappings" are being correctly evaluated at the beginning of the logs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org