Skip to content

Commit 7a22d64

Browse files
pillo79facchinm
andauthored
Implement official Arduino IDE debugger API (#9116)
* refactor(on-release): improve platform.txt path replacements Use regexs to replace all occurrences of `{runtime.platform.path}` with the correct `{runtime.tools.*.path}`, regardless of directory separator, and remove dependency on specific text around each path. Note that the order has been changed to ensure that the longest paths are replaced first, to avoid replacing parts of other paths. * fix(platform): Windows backslash cleanups Ensure Windows paths properly use a backslash as folder separator. * 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. * feat(debug): pass objdump path to resolve globals Cortex-debug requires objdump to be in the same folder as gdb, or needs the full path to the executable in the `launch.json` file. This is now possible with the new debugging API. * feat(debug): conditionally enable debug button on Nano ESP32 If the `debug.executable` variable is null or unset, the Debug button appears grayed out. The new IDE also takes current parameters into account, allowing to conditionally enable the Debug button only when some conditions are met. * on_release: allow single board packages --------- Co-authored-by: Martino Facchin <[email protected]>
1 parent c21a8cd commit 7a22d64

File tree

8 files changed

+128
-151
lines changed

8 files changed

+128
-151
lines changed

Diff for: .github/scripts/on-release.sh

+36-13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPA
3535
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
3636
echo "Tag: $RELEASE_TAG, Draft: $draft, Pre-Release: $RELEASE_PRE"
3737

38+
# Try extracting something like a JSON with a "boards" array/element and "vendor" fields
39+
BOARDS=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.boards[]? // .boards? // empty' | xargs echo -n 2>/dev/null`
40+
VENDOR=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.vendor? // empty' | xargs echo -n 2>/dev/null`
41+
if ! [ -z "${BOARDS}" ]; then echo "Releasing board(s): $BOARDS" ; fi
42+
if ! [ -z "${VENDOR}" ]; then echo "Setting packager: $VENDOR" ; fi
43+
3844
function get_file_size(){
3945
local file="$1"
4046
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -170,12 +176,26 @@ mkdir -p "$PKG_DIR/tools"
170176

171177
# Copy all core files to the package folder
172178
echo "Copying files for packaging ..."
173-
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
179+
if [ -z "${BOARDS}" ]; then
180+
# Copy all variants
181+
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
182+
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
183+
else
184+
# Remove all entries not starting with any board code or "menu." from boards.txt
185+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^menu\." > "$PKG_DIR/boards.txt"
186+
for board in ${BOARDS} ; do
187+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^${board}\." >> "$PKG_DIR/boards.txt"
188+
done
189+
# Copy only relevant variant files
190+
mkdir "$PKG_DIR/variants/"
191+
for variant in `cat ${PKG_DIR}/boards.txt | grep "\.variant=" | cut -d= -f2` ; do
192+
cp -Rf "$GITHUB_WORKSPACE/variants/${variant}" "$PKG_DIR/variants/"
193+
done
194+
fi
174195
cp -f "$GITHUB_WORKSPACE/package.json" "$PKG_DIR/"
175196
cp -f "$GITHUB_WORKSPACE/programmers.txt" "$PKG_DIR/"
176197
cp -Rf "$GITHUB_WORKSPACE/cores" "$PKG_DIR/"
177198
cp -Rf "$GITHUB_WORKSPACE/libraries" "$PKG_DIR/"
178-
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
179199
cp -f "$GITHUB_WORKSPACE/tools/espota.exe" "$PKG_DIR/tools/"
180200
cp -f "$GITHUB_WORKSPACE/tools/espota.py" "$PKG_DIR/tools/"
181201
cp -f "$GITHUB_WORKSPACE/tools/gen_esp32part.py" "$PKG_DIR/tools/"
@@ -201,19 +221,22 @@ RVTC_NEW_NAME="esp-rv32"
201221
echo "Generating platform.txt..."
202222
cat "$GITHUB_WORKSPACE/platform.txt" | \
203223
sed "s/version=.*/version=$RELEASE_TAG/g" | \
204-
sed 's/tools.esp32-arduino-libs.path={runtime.platform.path}\/tools\/esp32-arduino-libs/tools.esp32-arduino-libs.path=\{runtime.tools.esp32-arduino-libs.path\}/g' | \
205-
sed 's/tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf/tools.xtensa-esp32-elf-gcc.path=\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
206-
sed 's/tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf/tools.xtensa-esp32s2-elf-gcc.path=\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
207-
sed 's/tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf/tools.xtensa-esp32s3-elf-gcc.path=\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
208-
sed 's/tools.xtensa-esp-elf-gdb.path={runtime.platform.path}\/tools\/xtensa-esp-elf-gdb/tools.xtensa-esp-elf-gdb.path=\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
209-
sed "s/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\\/tools\\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\\{runtime.tools.$RVTC_NEW_NAME.path\\}/g" | \
210-
sed 's/tools.riscv32-esp-elf-gdb.path={runtime.platform.path}\/tools\/riscv32-esp-elf-gdb/tools.riscv32-esp-elf-gdb.path=\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
211-
sed 's/tools.esptool_py.path={runtime.platform.path}\/tools\/esptool/tools.esptool_py.path=\{runtime.tools.esptool_py.path\}/g' | \
212-
sed 's/debug.server.openocd.path={runtime.platform.path}\/tools\/openocd-esp32\/bin\/openocd/debug.server.openocd.path=\{runtime.tools.openocd-esp32.path\}\/bin\/openocd/g' | \
213-
sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-esp32\/share\/openocd\/scripts\//debug.server.openocd.scripts_dir=\{runtime.tools.openocd-esp32.path\}\/share\/openocd\/scripts\//g' | \
214-
sed 's/debug.server.openocd.scripts_dir.windows={runtime.platform.path}\\tools\\openocd-esp32\\share\\openocd\\scripts\\/debug.server.openocd.scripts_dir.windows=\{runtime.tools.openocd-esp32.path\}\\share\\openocd\\scripts\\/g' \
224+
sed 's/{runtime\.platform\.path}.tools.esp32-arduino-libs/\{runtime.tools.esp32-arduino-libs.path\}/g' | \
225+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp-elf-gdb/\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
226+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
227+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
228+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
229+
sed 's/{runtime\.platform\.path}.tools.riscv32-esp-elf-gdb/\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
230+
sed "s/{runtime\.platform\.path}.tools.riscv32-esp-elf/\\{runtime.tools.$RVTC_NEW_NAME.path\\}/g" | \
231+
sed 's/{runtime\.platform\.path}.tools.esptool/\{runtime.tools.esptool_py.path\}/g' | \
232+
sed 's/{runtime\.platform\.path}.tools.openocd-esp32/\{runtime.tools.openocd-esp32.path\}/g' \
215233
> "$PKG_DIR/platform.txt"
216234

235+
if ! [ -z ${VENDOR} ]; then
236+
# Append vendor name to platform.txt to create a separate section
237+
sed -i "/^name=.*/s/$/ ($VENDOR)/" "$PKG_DIR/platform.txt"
238+
fi
239+
217240
# Add header with version information
218241
echo "Generating core_version.h ..."
219242
ver_define=`echo $RELEASE_TAG | tr "[:lower:].\055" "[:upper:]_"`

Diff for: boards.txt

+14-3
Original file line numberDiff line numberDiff line change
@@ -33459,9 +33459,22 @@ nano_nora.build.psram_type=opi
3345933459
nano_nora.build.memory_type={build.boot}_{build.psram_type}
3346033460
nano_nora.build.disable_pin_remap=
3346133461

33462+
nano_nora.debug_config.nano_nora.cortex-debug.custom.name=Arduino on Nano ESP32
33463+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.0=set remote hardware-watchpoint-limit 2
33464+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.1=monitor reset halt
33465+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.2=monitor gdb_sync
33466+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideAttachCommands.3=interrupt
33467+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt
33468+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync
33469+
nano_nora.debug_config.nano_nora.cortex-debug.custom.overrideRestartCommands.2=interrupt
33470+
nano_nora.debug.additional_config=debug_config.nano_nora
33471+
3346233472
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"
3346333473
nano_nora.tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset erase_flash
3346433474

33475+
nano_nora.programmer.default=esptool
33476+
nano_nora.debug.executable=
33477+
3346533478
nano_nora.menu.PartitionScheme.default=With FAT partition (default)
3346633479
nano_nora.menu.PartitionScheme.spiffs=With SPIFFS partition (advanced)
3346733480
nano_nora.menu.PartitionScheme.spiffs.build.partitions=app3M_spiffs9M_fact512k_16MB
@@ -33473,9 +33486,7 @@ nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_G
3347333486
nano_nora.menu.USBMode.default=Normal mode (TinyUSB)
3347433487
nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC)
3347533488
nano_nora.menu.USBMode.hwcdc.build.usb_mode=1
33476-
nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1
33477-
nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg
33478-
nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json
33489+
nano_nora.menu.USBMode.hwcdc.debug.executable={build.path}/{build.project_name}.elf
3347933490

3348033491
##############################################################
3348133492

0 commit comments

Comments
 (0)