From 7418e651385fb80e5935b52974cabc50d85020ec Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 19 Dec 2025 21:02:10 +0000 Subject: [PATCH] echoplayer: add 'debug' and 'flash' targets to makefile This replaces the gdb & openocd config in utils/stm32tools and is easier to use. Remove the srst workaround; it seems this was caused by the D1/D3 domains not being powered up while the CPU was in sleep mode. Change-Id: I28cc0273b3004c6e3146bb2447f0655cad8bb1c2 --- .../stm32tools => tools/echoplayer}/openocd.cfg | 12 +++++------- tools/echoplayer/openocd.make | 17 +++++++++++++++++ tools/root.make | 5 +++++ utils/stm32tools/gdbinit | 13 ------------- 4 files changed, 27 insertions(+), 20 deletions(-) rename {utils/stm32tools => tools/echoplayer}/openocd.cfg (64%) create mode 100644 tools/echoplayer/openocd.make delete mode 100644 utils/stm32tools/gdbinit diff --git a/utils/stm32tools/openocd.cfg b/tools/echoplayer/openocd.cfg similarity index 64% rename from utils/stm32tools/openocd.cfg rename to tools/echoplayer/openocd.cfg index fd18608d04..fd4bf83cfc 100644 --- a/utils/stm32tools/openocd.cfg +++ b/tools/echoplayer/openocd.cfg @@ -3,14 +3,12 @@ # Setup for STLINK-V3SET + STM32H7 source [find interface/stlink-dap.cfg] source [find target/stm32h7x.cfg] -reset_config srst_only srst_open_drain srst_nogate connect_assert_srst -init - -# Workaround for OpenOCD complaining about externally asserted resets. -# Possibly an electrical issue. -adapter assert srst -adapter deassert srst # OpenOCD doesn't handle soft breakpoints correctly for Cortex-M7 when ICache is enabled: # https://sourceforge.net/p/openocd/mailman/openocd-user/thread/6668098.sCNexbpv2J@linux-5nlr.menet/ gdb_breakpoint_override hard + +# Resume execution when GDB detaches, instead of halting +stm32h7x.cpu0 configure -event gdb-detach { + resume +} diff --git a/tools/echoplayer/openocd.make b/tools/echoplayer/openocd.make new file mode 100644 index 0000000000..f7664d128e --- /dev/null +++ b/tools/echoplayer/openocd.make @@ -0,0 +1,17 @@ +GDB := gdb +OPENOCD := openocd +OPENOCD_CFG := $(ROOTDIR)/tools/echoplayer/openocd.cfg + +ifneq (,$(findstring bootloader,$(APPSDIR))) + TARGET_ELF := $(BUILDDIR)/bootloader.elf +else + TARGET_ELF := $(BUILDDIR)/rockbox.elf +endif + +debug: + $(GDB) $(TARGET_ELF) -ex "target extended-remote | openocd -c \"gdb_port pipe\" -f $(OPENOCD_CFG)" + +flash: $(TARGET_ELF) + $(OPENOCD) -f $(OPENOCD_CFG) -c "program $(TARGET_ELF) verify reset exit" + +.PHONY: debug flash diff --git a/tools/root.make b/tools/root.make index e00dc7b626..e177057ecb 100644 --- a/tools/root.make +++ b/tools/root.make @@ -180,6 +180,11 @@ else # core endif # bootloader +# Include makefile for flashing/debugging with OpenOCD & GDB +ifeq (echor1,$(MODELNAME)) + include $(ROOTDIR)/tools/echoplayer/openocd.make +endif + # One or more subdir makefiles requested --gc-sections? ifdef CORE_GCSECTIONS # Do not use '--gc-sections' when compiling sdl-sim diff --git a/utils/stm32tools/gdbinit b/utils/stm32tools/gdbinit deleted file mode 100644 index 41ebfb2c8e..0000000000 --- a/utils/stm32tools/gdbinit +++ /dev/null @@ -1,13 +0,0 @@ -## Example GDB script for loading a bootloader binary using OpenOCD - -# Set target binary and connect to OpenOCD -file "./bootloader.elf" -target extended-remote localhost:3333 - -# Reset target and flush register cache since GDB is apparently -# not smart enough to do this itself. -monitor reset halt -maintenance flush register-cache - -# Download binary to target -load "./bootloader.elf"