Skip to content

Commit 7d1dd85

Browse files
pillo79me-no-dev
authored andcommitted
Nano ESP32: add debug support (#8567)
* Nano ESP32: fix previous merge issues * platform: remove previous build options if file is missing "touch" would create the file if not present, but not delete its contents if a previous run left the file in the build dir. * platform: make debug_custom.json file customizable by board * platform: fix default debug prefix "debug.toolchain.prefix" must end with a dash, since only the tool name is appended to this string. The reason this is not a major issue is that the "debug_custom.json" file (copied in the sketch directory when debugging is enabled) forces its own prefix. And to make things more interesting, the "toolchainPrefix" entry in that file should _not_ end with a dash. * Nano ESP32: add debugging support
1 parent 58761be commit 7d1dd85

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Diff for: boards.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -25673,8 +25673,11 @@ nano_nora.menu.PinNumbers.default=By Arduino pin (default)
2567325673
nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy)
2567425674
nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS
2567525675

25676-
nano_nora.menu.PinNumbers.default=By Arduino pin (default)
25677-
nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy)
25678-
nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS
25676+
nano_nora.menu.USBMode.default=Normal mode (TinyUSB)
25677+
nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC)
25678+
nano_nora.menu.USBMode.hwcdc.build.usb_mode=1
25679+
nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1
25680+
nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg
25681+
nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json
2567925682

2568025683
##############################################################

Diff for: platform.txt

+7-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ build.openocdscript.esp32s3=esp32s3-builtin.cfg
160160
build.openocdscript.esp32c3=esp32c3-builtin.cfg
161161
build.openocdscript={build.openocdscript.{build.mcu}}
162162

163+
# Debug plugin configuration
164+
build.debugconfig={build.mcu}.json
165+
163166
# Custom build options
164167
build.opt.name=build_opt.h
165168
build.opt.path={build.path}/{build.opt.name}
@@ -181,7 +184,7 @@ recipe.hooks.prebuild.4.pattern.windows=cmd /c IF EXIST "{build.source.path}\boo
181184

182185
# Check if custom build options exist in the sketch folder
183186
recipe.hooks.prebuild.5.pattern=bash -c "[ ! -f "{build.source.path}"/build_opt.h ] || cp -f "{build.source.path}"/build_opt.h "{build.path}"/build_opt.h"
184-
recipe.hooks.prebuild.6.pattern=bash -c "[ -f "{build.path}"/build_opt.h ] || touch "{build.path}"/build_opt.h"
187+
recipe.hooks.prebuild.6.pattern=bash -c "[ -f "{build.path}"/build_opt.h ] || : > "{build.path}"/build_opt.h"
185188

186189
recipe.hooks.prebuild.5.pattern.windows=cmd /c if exist "{build.source.path}\build_opt.h" COPY /y "{build.source.path}\build_opt.h" "{build.path}\build_opt.h"
187190
recipe.hooks.prebuild.6.pattern.windows=cmd /c if not exist "{build.path}\build_opt.h" type nul > "{build.path}\build_opt.h"
@@ -201,8 +204,8 @@ recipe.hooks.postbuild.1.pattern=bash -c "[ {build.copy_jtag_files} -eq 0 ] || c
201204
recipe.hooks.postbuild.1.pattern.windows=cmd /c IF {build.copy_jtag_files}==1 COPY /y "{debug.server.openocd.scripts_dir}board\{build.openocdscript}" "{build.source.path}\debug.cfg"
202205

203206
# Generate debug_custom.json
204-
recipe.hooks.postbuild.2.pattern=bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{runtime.platform.path}"/tools/ide-debug/{build.mcu}.json "{build.source.path}"/debug_custom.json"
205-
recipe.hooks.postbuild.2.pattern.windows=cmd /c IF {build.copy_jtag_files}==1 COPY /y "{runtime.platform.path}\tools\ide-debug\{build.mcu}.json" "{build.source.path}\debug_custom.json"
207+
recipe.hooks.postbuild.2.pattern=bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{runtime.platform.path}"/tools/ide-debug/{build.debugconfig} "{build.source.path}"/debug_custom.json"
208+
recipe.hooks.postbuild.2.pattern.windows=cmd /c IF {build.copy_jtag_files}==1 COPY /y "{runtime.platform.path}\tools\ide-debug\{build.debugconfig}" "{build.source.path}\debug_custom.json"
206209

207210
# Generate chip.svd
208211
recipe.hooks.postbuild.3.pattern=bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{runtime.platform.path}"/tools/ide-debug/svd/{build.mcu}.svd "{build.source.path}"/debug.svd"
@@ -263,7 +266,7 @@ pluggable_monitor.required.serial=builtin:serial-monitor
263266
debug.executable={build.path}/{build.project_name}.elf
264267
debug.toolchain=gcc
265268
debug.toolchain.path={tools.{build.tarch}-esp-elf-gdb.path}/bin/
266-
debug.toolchain.prefix={build.tarch}-{build.target}-elf
269+
debug.toolchain.prefix={build.tarch}-{build.target}-elf-
267270
debug.server=openocd
268271
debug.server.openocd.script=debug.cfg
269272

Diff for: tools/ide-debug/esp32s3-arduino.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name":"Arduino on ESP32-S3",
3+
"toolchainPrefix":"xtensa-esp32s3-elf",
4+
"svdFile":"debug.svd",
5+
"request":"attach",
6+
"overrideAttachCommands":[
7+
"set remote hardware-watchpoint-limit 2",
8+
"monitor reset halt",
9+
"monitor gdb_sync",
10+
"thb setup",
11+
"interrupt"
12+
],
13+
"overrideRestartCommands":[
14+
"monitor reset halt",
15+
"monitor gdb_sync",
16+
"interrupt"
17+
]
18+
}

0 commit comments

Comments
 (0)