Skip to content

Commit 55d515b

Browse files
committed
feat(platform)!: use new Arduino 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/latest/platform-specification/#sketch-debugging-configuration BREAKING CHANGE: This commit requires Arduino IDE 2.3.0 or later to use the debugging features. Older versions will no longer be able to start a debug session successfully.
1 parent c342175 commit 55d515b

File tree

7 files changed

+76
-131
lines changed

7 files changed

+76
-131
lines changed

Diff for: boards.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -26035,9 +26035,21 @@ nano_nora.build.psram_type=opi
2603526035
nano_nora.build.memory_type={build.boot}_{build.psram_type}
2603626036
nano_nora.build.disable_pin_remap=
2603726037

26038+
nano_nora.debug_config.nano_nora.cortex-debug.custom.name=Arduino on Nano ESP32
26039+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 2
26040+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.1=monitor reset halt
26041+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.2=monitor gdb_sync
26042+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.3=interrupt
26043+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
26044+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
26045+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.2=interrupt
26046+
nano_nora.debug.additional_config=debug_config.nano_nora
26047+
2603826048
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"
2603926049
nano_nora.tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset erase_flash
2604026050

26051+
nano_nora.programmer.default=esptool
26052+
2604126053
nano_nora.menu.PartitionScheme.default=With FAT partition (default)
2604226054
nano_nora.menu.PartitionScheme.spiffs=With SPIFFS partition (advanced)
2604326055
nano_nora.menu.PartitionScheme.spiffs.build.partitions=app3M_spiffs9M_fact512k_16MB
@@ -26049,9 +26061,6 @@ nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_G
2604926061
nano_nora.menu.USBMode.default=Normal mode (TinyUSB)
2605026062
nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC)
2605126063
nano_nora.menu.USBMode.hwcdc.build.usb_mode=1
26052-
nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1
26053-
nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg
26054-
nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json
2605526064

2605626065
##############################################################
2605726066

Diff for: platform.txt

+64-33
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ tools.xtensa-esp-elf-gdb.path={runtime.platform.path}/tools/xtensa-esp-elf-gdb
88
tools.riscv32-esp-elf-gcc.path={runtime.platform.path}/tools/riscv32-esp-elf
99
tools.riscv32-esp-elf-gdb.path={runtime.platform.path}/tools/riscv32-esp-elf-gdb
1010

11-
debug.server.openocd.path={runtime.platform.path}/tools/openocd-esp32/bin/openocd
12-
debug.server.openocd.scripts_dir={runtime.platform.path}/tools/openocd-esp32/share/openocd/scripts/
13-
debug.server.openocd.scripts_dir.windows={runtime.platform.path}\tools\openocd-esp32\share\openocd\scripts\
14-
1511
tools.esptool_py.path={runtime.platform.path}/tools/esptool
1612
tools.esptool_py.cmd=esptool
1713
tools.esptool_py.cmd.linux=esptool.py
@@ -152,17 +148,6 @@ build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.loop_core
152148
build.extra_libs=
153149
build.memory_type={build.boot}_qspi
154150

155-
# OpenOCD default configs
156-
build.copy_jtag_files=0
157-
build.openocdscript.esp32=esp32-wrover-kit-3.3v.cfg
158-
build.openocdscript.esp32s2=esp32s2-kaluga-1.cfg
159-
build.openocdscript.esp32s3=esp32s3-builtin.cfg
160-
build.openocdscript.esp32c3=esp32c3-builtin.cfg
161-
build.openocdscript={build.openocdscript.{build.mcu}}
162-
163-
# Debug plugin configuration
164-
build.debugconfig={build.mcu}.json
165-
166151
# Custom build options
167152
build.opt.name=build_opt.h
168153
build.opt.path={build.path}/{build.opt.name}
@@ -199,18 +184,6 @@ recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{fi
199184
recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > "{file_opts.path}"
200185
recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}"
201186

202-
# Generate debug.cfg (must be postbuild)
203-
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"
204-
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"
205-
206-
# Generate debug_custom.json
207-
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"
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"
209-
210-
# Generate chip.svd
211-
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"
212-
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"
213-
214187
## Compile c files
215188
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.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} {compiler.c.extra_flags} {build.extra_flags} "@{build.opt.path}" "@{file_opts.path}" {includes} "{source_file}" -o "{object_file}"
216189

@@ -259,16 +232,74 @@ pluggable_monitor.required.serial=builtin:serial-monitor
259232
## Upload/Debug tools
260233
## ------------------
261234

262-
# Debugger configuration (general options)
263-
# ----------------------------------------
264-
# EXPERIMENTAL feature:
265-
# - this is alpha and may be subject to change without notice
235+
# Debugger configuration
236+
# ----------------------
237+
238+
# ESP32 debug configuration
239+
debug_script.esp32=esp32-wrover-kit-3.3v.cfg
240+
debug_config.esp32.cortex-debug.custom.name=Arduino on ESP32
241+
debug_config.esp32.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2
242+
debug_config.esp32.cortex-debug.custom.postAttachCommands.1=monitor reset halt
243+
debug_config.esp32.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync
244+
debug_config.esp32.cortex-debug.custom.postAttachCommands.3=thb setup
245+
debug_config.esp32.cortex-debug.custom.postAttachCommands.4=c
246+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
247+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
248+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.2=thb setup
249+
debug_config.esp32.cortex-debug.custom.overrideRestartCommands.3=c
250+
251+
# ESP32-S2 debug configuration
252+
debug_script.esp32s2=esp32s2-kaluga-1.cfg
253+
debug_config.esp32s2.cortex-debug.custom.name=Arduino on ESP32-S2
254+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2
255+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.1=monitor reset halt
256+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync
257+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.3=thb setup
258+
debug_config.esp32s2.cortex-debug.custom.postAttachCommands.4=c
259+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
260+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
261+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.2=thb setup
262+
debug_config.esp32s2.cortex-debug.custom.overrideRestartCommands.3=c
263+
264+
# ESP32-S3 debug configuration
265+
debug_script.esp32s3=esp32s3-builtin.cfg
266+
debug_config.esp32s3.cortex-debug.custom.name=Arduino on ESP32-S3
267+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 2
268+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.1=monitor reset halt
269+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.2=monitor gdb_sync
270+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.3=thb setup
271+
debug_config.esp32s3.cortex-debug.custom.overrideAttachCommands.4=c
272+
debug_config.esp32s3.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
273+
debug_config.esp32s3.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
274+
275+
# ESP32-C3 debug configuration
276+
debug_script.esp32c3=esp32c3-builtin.cfg
277+
debug_config.esp32c3.cortex-debug.custom.name=Arduino on ESP32-C3
278+
debug_config.esp32c3.cortex-debug.custom.serverArgs.0=-d3
279+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 8
280+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.1=monitor reset
281+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.2=monitor halt
282+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.3=monitor gdb_sync
283+
debug_config.esp32c3.cortex-debug.custom.overrideAttachCommands.4=thb setup
284+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.0=monitor reset
285+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.1=monitor halt
286+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.2=monitor gdb_sync
287+
debug_config.esp32c3.cortex-debug.custom.overrideRestartCommands.3=thb setup
288+
289+
# Debug API variable definitions
266290
debug.executable={build.path}/{build.project_name}.elf
267291
debug.toolchain=gcc
268292
debug.toolchain.path={tools.{build.tarch}-esp-elf-gdb.path}/bin/
269-
debug.toolchain.prefix={build.tarch}-{build.target}-elf-
293+
debug.toolchain.prefix={build.tarch}-{build.target}-elf
270294
debug.server=openocd
271-
debug.server.openocd.script=debug.cfg
295+
debug.server.openocd.path={runtime.platform.path}/tools/openocd-esp32/bin/openocd
296+
debug.server.openocd.scripts_dir={runtime.platform.path}/tools/openocd-esp32/share/openocd/scripts/
297+
debug.server.openocd.scripts_dir.windows={runtime.platform.path}\tools\openocd-esp32\share\openocd\scripts\
298+
debug.server.openocd.scripts.0=board/{debug_script.{build.mcu}}
299+
debug.svd_file={runtime.platform.path}/tools/ide-debug/svd/{build.mcu}.svd
300+
301+
debug.cortex-debug.custom.request=attach
302+
debug.additional_config=debug_config.{build.mcu}
272303

273304
##
274305
## ESPTool

Diff for: tools/ide-debug/esp32.json

-19
This file was deleted.

Diff for: tools/ide-debug/esp32c3.json

-22
This file was deleted.

Diff for: tools/ide-debug/esp32s2.json

-19
This file was deleted.

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

-18
This file was deleted.

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

-17
This file was deleted.

0 commit comments

Comments
 (0)