From 16c49fc0121d453c18516d8f8b9b59234bd4cb24 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 30 Aug 2023 09:36:22 +0200 Subject: [PATCH 1/5] Nano ESP32: fix previous merge issues --- boards.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/boards.txt b/boards.txt index 3b3bdbcd475..12ef4887d05 100644 --- a/boards.txt +++ b/boards.txt @@ -24173,8 +24173,4 @@ nano_nora.menu.PinNumbers.default=By Arduino pin (default) nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy) nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS -nano_nora.menu.PinNumbers.default=By Arduino pin (default) -nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy) -nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS - ############################################################## From 2e00e8b2185ce1f6fd7f4d2a1c9e492b2c4e8f73 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Fri, 25 Aug 2023 15:02:07 +0200 Subject: [PATCH 2/5] 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.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index 970107849fe..bc0f23c7025 100644 --- a/platform.txt +++ b/platform.txt @@ -181,7 +181,7 @@ recipe.hooks.prebuild.4.pattern.windows=cmd /c IF EXIST "{build.source.path}\boo # Check if custom build options exist in the sketch folder 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" -recipe.hooks.prebuild.6.pattern=bash -c "[ -f "{build.path}"/build_opt.h ] || touch "{build.path}"/build_opt.h" +recipe.hooks.prebuild.6.pattern=bash -c "[ -f "{build.path}"/build_opt.h ] || : > "{build.path}"/build_opt.h" 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" recipe.hooks.prebuild.6.pattern.windows=cmd /c if not exist "{build.path}\build_opt.h" type nul > "{build.path}\build_opt.h" From 5caa7091efa79789a8096b0a49ac1011dd886a92 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 23 Aug 2023 14:47:44 +0200 Subject: [PATCH 3/5] platform: make debug_custom.json file customizable by board --- platform.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform.txt b/platform.txt index bc0f23c7025..6d72e155fb8 100644 --- a/platform.txt +++ b/platform.txt @@ -160,6 +160,9 @@ build.openocdscript.esp32s3=esp32s3-builtin.cfg build.openocdscript.esp32c3=esp32c3-builtin.cfg build.openocdscript={build.openocdscript.{build.mcu}} +# Debug plugin configuration +build.debugconfig={build.mcu}.json + # Custom build options build.opt.name=build_opt.h build.opt.path={build.path}/{build.opt.name} @@ -201,8 +204,8 @@ recipe.hooks.postbuild.1.pattern=bash -c "[ {build.copy_jtag_files} -eq 0 ] || c 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" # Generate debug_custom.json -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" -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" +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" +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" # Generate chip.svd 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" From 99a2eb57d53417663d916121593483adc2ebe6bb Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 23 Aug 2023 14:49:27 +0200 Subject: [PATCH 4/5] 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. --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index 6d72e155fb8..dcd24c54067 100644 --- a/platform.txt +++ b/platform.txt @@ -266,7 +266,7 @@ pluggable_monitor.required.serial=builtin:serial-monitor debug.executable={build.path}/{build.project_name}.elf debug.toolchain=gcc debug.toolchain.path={tools.{build.tarch}-esp-elf-gdb.path}/bin/ -debug.toolchain.prefix={build.tarch}-{build.target}-elf +debug.toolchain.prefix={build.tarch}-{build.target}-elf- debug.server=openocd debug.server.openocd.script=debug.cfg From 6113158644fb8580fae54acdcfac7013f44b611e Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 23 Aug 2023 14:49:53 +0200 Subject: [PATCH 5/5] Nano ESP32: add debugging support --- boards.txt | 7 +++++++ tools/ide-debug/esp32s3-arduino.json | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tools/ide-debug/esp32s3-arduino.json diff --git a/boards.txt b/boards.txt index 12ef4887d05..0d87edb4d2c 100644 --- a/boards.txt +++ b/boards.txt @@ -24173,4 +24173,11 @@ nano_nora.menu.PinNumbers.default=By Arduino pin (default) nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy) nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS +nano_nora.menu.USBMode.default=Normal mode (TinyUSB) +nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC) +nano_nora.menu.USBMode.hwcdc.build.usb_mode=1 +nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1 +nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg +nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json + ############################################################## diff --git a/tools/ide-debug/esp32s3-arduino.json b/tools/ide-debug/esp32s3-arduino.json new file mode 100644 index 00000000000..559d2878cbe --- /dev/null +++ b/tools/ide-debug/esp32s3-arduino.json @@ -0,0 +1,18 @@ +{ + "name":"Arduino on ESP32-S3", + "toolchainPrefix":"xtensa-esp32s3-elf", + "svdFile":"debug.svd", + "request":"attach", + "overrideAttachCommands":[ + "set remote hardware-watchpoint-limit 2", + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "interrupt" + ], + "overrideRestartCommands":[ + "monitor reset halt", + "monitor gdb_sync", + "interrupt" + ] +}