Skip to content

Commit 0e673fa

Browse files
committed
platform: use new debug API
Implement sketch debugging according to the official Arduino Platform Debug Specification [1]. The biggest improvement is that now `launch.json` can be fully customized by the core (including the type of each entry), so there is no need to copy files in the sketch folder. In particular, `debug_custom.json` is not used anymore. [1] https://arduino.github.io/arduino-cli/0.35/platform-specification/#sketch-debugging-configuration
1 parent faecc65 commit 0e673fa

File tree

6 files changed

+91
-117
lines changed

6 files changed

+91
-117
lines changed

boards.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29741,9 +29741,21 @@ nano_nora.build.psram_type=opi
2974129741
nano_nora.build.memory_type={build.boot}_{build.psram_type}
2974229742
nano_nora.build.disable_pin_remap=
2974329743

29744+
nano_nora.debug_config.nano_nora.cortex-debug.custom.name=Arduino on Nano ESP32
29745+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 2
29746+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.1=monitor reset halt
29747+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.2=monitor gdb_sync
29748+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.3=interrupt
29749+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
29750+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
29751+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.2=interrupt
29752+
nano_nora.debug.additional_config=debug_config.nano_nora
29753+
2974429754
nano_nora.tools.esptool_py.program.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size {build.flash_size} {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0xf70000 "{build.variant.path}/extra/nora_recovery/nora_recovery.ino.bin" 0x10000 "{build.path}/{build.project_name}.bin"
2974529755
nano_nora.tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset erase_flash
2974629756

29757+
nano_nora.programmer.default=esptool
29758+
2974729759
nano_nora.menu.PartitionScheme.default=With FAT partition (default)
2974829760
nano_nora.menu.PartitionScheme.spiffs=With SPIFFS partition (advanced)
2974929761
nano_nora.menu.PartitionScheme.spiffs.build.partitions=app3M_spiffs9M_fact512k_16MB
@@ -29755,8 +29767,5 @@ nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_G
2975529767
nano_nora.menu.USBMode.default=Normal mode (TinyUSB)
2975629768
nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC)
2975729769
nano_nora.menu.USBMode.hwcdc.build.usb_mode=1
29758-
nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1
29759-
nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg
29760-
nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json
2976129770

2976229771
##############################################################

platform.txt

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ tools.xtensa-esp-elf-gdb.path={runtime.platform.path}/tools/xtensa-esp-elf-gdb
99
tools.riscv32-esp-elf-gcc.path={runtime.platform.path}/tools/riscv32-esp-elf
1010
tools.riscv32-esp-elf-gdb.path={runtime.platform.path}/tools/riscv32-esp-elf-gdb
1111

12-
debug.server.openocd.path={runtime.platform.path}/tools/openocd-esp32/bin/openocd
13-
debug.server.openocd.scripts_dir={runtime.platform.path}/tools/openocd-esp32/share/openocd/scripts/
14-
debug.server.openocd.scripts_dir.windows={runtime.platform.path}\tools\openocd-esp32\share\openocd\scripts\
15-
1612
tools.esptool_py.path={runtime.platform.path}/tools/esptool
1713
tools.esptool_py.cmd=esptool
1814
tools.esptool_py.cmd.linux=esptool.py
@@ -105,19 +101,6 @@ build.extra_flags=-DARDUINO_HOST_OS="{runtime.os}" -DARDUINO_FQBN="{build.fqbn}"
105101
build.extra_libs=
106102
build.memory_type={build.boot}_qspi
107103

108-
# OpenOCD default configs
109-
build.copy_jtag_files=0
110-
build.openocdscript.esp32=esp32-wrover-kit-3.3v.cfg
111-
build.openocdscript.esp32s2=esp32s2-kaluga-1.cfg
112-
build.openocdscript.esp32s3=esp32s3-builtin.cfg
113-
build.openocdscript.esp32c3=esp32c3-builtin.cfg
114-
build.openocdscript.esp32c6=esp32c6-builtin.cfg
115-
build.openocdscript.esp32c6=esp32h2-builtin.cfg
116-
build.openocdscript={build.openocdscript.{build.mcu}}
117-
118-
# Debug plugin configuration
119-
build.debugconfig={build.mcu}.json
120-
121104
# Custom build options
122105
build.opt.name=build_opt.h
123106
build.opt.path={build.path}/{build.opt.name}
@@ -154,18 +137,6 @@ recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{fi
154137
recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > "{file_opts.path}"
155138
recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}"
156139

157-
# Generate debug.cfg (must be postbuild)
158-
recipe.hooks.postbuild.1.pattern=/usr/bin/env bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{debug.server.openocd.scripts_dir}"board/{build.openocdscript} "{build.source.path}"/debug.cfg"
159-
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"
160-
161-
# Generate debug_custom.json
162-
recipe.hooks.postbuild.2.pattern=/usr/bin/env bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{runtime.platform.path}"/tools/ide-debug/{build.debugconfig} "{build.source.path}"/debug_custom.json"
163-
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"
164-
165-
# Generate chip.svd
166-
recipe.hooks.postbuild.3.pattern=/usr/bin/env 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"
167-
recipe.hooks.postbuild.3.pattern.windows=cmd /c IF {build.copy_jtag_files}==1 COPY /y "{runtime.platform.path}\tools\ide-debug\svd\{build.mcu}.svd" "{build.source.path}\debug.svd"
168-
169140
## Compile c files
170141
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.extra_flags} {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" -DARDUINO_PARTITION_{build.partitions} {build.extra_flags} {compiler.cpreprocessor.flags} {includes} "@{build.opt.path}" "@{file_opts.path}" "{source_file}" -o "{object_file}"
171142

@@ -217,16 +188,87 @@ pluggable_monitor.required.serial=builtin:serial-monitor
217188
## Upload/Debug tools
218189
## ------------------
219190

220-
# Debugger configuration (general options)
221-
# ----------------------------------------
222-
# EXPERIMENTAL feature:
223-
# - this is alpha and may be subject to change without notice
224-
debug.executable={build.path}/{build.project_name}.elf
191+
# Debugger configuration
192+
# ----------------------
193+
194+
# OS-specific paths
195+
pathsep=/
196+
pathsep.windows=\
197+
binext=
198+
binext.windows=.exe
199+
200+
# ESP32 debug configuration
201+
debug_script.esp32=esp32-wrover-kit-3.3v.cfg
202+
debug_config.esp32.cortex-debug.custom.name=Arduino on ESP32
203+
debug_config.esp32.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2
204+
debug_config.esp32.cortex-debug.custom.postAttachCommands.1=monitor reset halt
205+
debug_config.esp32.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync
206+
debug_config.esp32.cortex-debug.custom.postAttachCommands.3=thb setup
207+
debug_config.esp32.cortex-debug.custom.postAttachCommands.4=c
208+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
209+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
210+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.2=thb setup
211+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.3=c
212+
213+
# ESP32-S2 debug configuration
214+
debug_script.esp32s2=esp32s2-kaluga-1.cfg
215+
debug_config.esp32s2.cortex-debug.custom.name=Arduino on ESP32-S2
216+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2
217+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.1=monitor reset halt
218+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync
219+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.3=thb setup
220+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.4=c
221+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
222+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
223+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.2=thb setup
224+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.3=c
225+
226+
# ESP32-S3 debug configuration
227+
debug_script.esp32s3=esp32s3-builtin.cfg
228+
debug_config.esp32s3.cortex-debug.custom.name=Arduino on ESP32-S3
229+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 2
230+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.1=monitor reset halt
231+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.2=monitor gdb_sync
232+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.3=thb setup
233+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.4=c
234+
debug_config.esp32s3.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
235+
debug_config.esp32s3.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
236+
237+
# ESP32-C3 debug configuration
238+
debug_script.esp32c3=esp32c3-builtin.cfg
239+
debug_config.esp32c3.cortex-debug.custom.name=Arduino on ESP32-C3
240+
debug_config.esp32c3.cortex-debug.custom.serverArgs.0=-d3
241+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 8
242+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.1=monitor reset
243+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.2=monitor halt
244+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.3=monitor gdb_sync
245+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.4=thb setup
246+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.0=monitor reset
247+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.1=monitor halt
248+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.2=monitor gdb_sync
249+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.3=thb setup
250+
251+
# ESP32-C6 debug configuration (TBD)
252+
debug_script.esp32c6=esp32c6-builtin.cfg
253+
debug_config.esp32c6=
254+
255+
# ESP32-H2 debug configuration (TBD)
256+
debug_script.esp32h2=esp32h2-builtin.cfg
257+
debug_config.esp32h2=
258+
259+
# Debug API variable definitions
260+
debug.executable={build.path}{pathsep}{build.project_name}.elf
225261
debug.toolchain=gcc
226-
debug.toolchain.path={tools.{build.tarch}-esp-elf-gdb.path}/bin/
227-
debug.toolchain.prefix={build.tarch}-{build.target}-elf-
262+
debug.toolchain.path={tools.{build.tarch}-esp-elf-gdb.path}{pathsep}bin{pathsep}
263+
debug.toolchain.prefix={build.tarch}-{build.target}-elf
228264
debug.server=openocd
229-
debug.server.openocd.script=debug.cfg
265+
debug.server.openocd.path={runtime.platform.path}{pathsep}tools{pathsep}openocd-esp32{pathsep}bin{pathsep}openocd{binext}
266+
debug.server.openocd.scripts_dir={runtime.platform.path}{pathsep}tools{pathsep}openocd-esp32{pathsep}share{pathsep}openocd{pathsep}scripts{pathsep}
267+
debug.server.openocd.scripts.0=board{pathsep}{debug_script.{build.mcu}}
268+
debug.svd_file={runtime.platform.path}{pathsep}tools{pathsep}ide-debug{pathsep}svd{pathsep}{build.mcu}.svd
269+
270+
debug.cortex-debug.custom.request=attach
271+
debug.additional_config=debug_config.{build.mcu}
230272

231273
##
232274
## ESPTool

tools/ide-debug/esp32.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

tools/ide-debug/esp32c3.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

tools/ide-debug/esp32s2.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

tools/ide-debug/esp32s3.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)