From 1111631c4505c25ec5f9b939ca2acfe79c7ac2f8 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 31 May 2022 12:39:16 +0200 Subject: [PATCH] makefiles/tools: define DEBUG_ELFFILE and use it for debugging --- Makefile.include | 3 +++ boards/f4vi1/Makefile.include | 2 +- boards/stm32mp157c-dk2/Makefile.include | 2 +- makefiles/tools/avrdude.inc.mk | 2 +- makefiles/tools/bmp.inc.mk | 2 +- makefiles/tools/jlink.inc.mk | 2 +- makefiles/tools/mspdebug.inc.mk | 2 +- makefiles/tools/openocd.inc.mk | 2 +- makefiles/tools/pyocd.inc.mk | 2 +- makefiles/tools/qemu.inc.mk | 2 +- makefiles/tools/renode.inc.mk | 2 +- makefiles/tools/uniflash.inc.mk | 2 +- 12 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile.include b/Makefile.include index 3e73ed8f82..ad9cd293e6 100644 --- a/Makefile.include +++ b/Makefile.include @@ -670,6 +670,9 @@ ifneq (,$(filter suit,$(USEMODULE))) include $(RIOTMAKE)/suit.inc.mk endif +# elf file used for the debugger, must include bootloader offset +DEBUG_ELFFILE ?= $(ELFFILE) + # Targets to get given file elffile: $(ELFFILE) hexfile: $(HEXFILE) diff --git a/boards/f4vi1/Makefile.include b/boards/f4vi1/Makefile.include index 03f89fc9e0..57c159ddce 100644 --- a/boards/f4vi1/Makefile.include +++ b/boards/f4vi1/Makefile.include @@ -13,4 +13,4 @@ DEBUGSERVER = st-util # define st-flash parameters FLASHFILE ?= $(BINFILE) FFLAGS = write $(FLASHFILE) 0x8000000 -DEBUGGER_FLAGS = $(RIOTBOARD)/f4vi1/dist/gdb.conf $(ELFFILE) +DEBUGGER_FLAGS = $(RIOTBOARD)/f4vi1/dist/gdb.conf $(DEBUG_ELFFILE) diff --git a/boards/stm32mp157c-dk2/Makefile.include b/boards/stm32mp157c-dk2/Makefile.include index 8aff30cb20..98e2581d2c 100644 --- a/boards/stm32mp157c-dk2/Makefile.include +++ b/boards/stm32mp157c-dk2/Makefile.include @@ -7,7 +7,7 @@ OPENOCD_CORE = stm32mp15x.cm4 GDB_PORT_CORE_OFFSET = 1 FFLAGS ?= flashr $(FLASHFILE) -DEBUGGER_FLAGS ?= debugr $(ELFFILE) +DEBUGGER_FLAGS ?= debugr $(DEBUG_ELFFILE) # Setup of programmer and serial is shared between STM32 based boards include $(RIOTMAKE)/boards/stm32.inc.mk diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index 80337be76c..7d86c8d896 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -16,7 +16,7 @@ else DEBUGPROTO ?= -j $(AVR_DEBUGINTERFACE) endif DEBUGSERVER_FLAGS ?= "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)" -DEBUGGER_FLAGS ?= "-x $(AVARICE_PATH)/gdb.conf $(ELFFILE)" +DEBUGGER_FLAGS ?= "-x $(AVARICE_PATH)/gdb.conf $(DEBUG_ELFFILE)" DEBUGGER = "$(AVARICE_PATH)/debug.sh" $(DEBUGSERVER_FLAGS) $(AVARICE_PATH) $(DEBUGSERVER_PORT) ifeq (atxmega,$(CPU)) diff --git a/makefiles/tools/bmp.inc.mk b/makefiles/tools/bmp.inc.mk index 47503b9722..30efdf2260 100644 --- a/makefiles/tools/bmp.inc.mk +++ b/makefiles/tools/bmp.inc.mk @@ -5,5 +5,5 @@ RESET ?= $(RIOTTOOLS)/bmp/bmp.py FLASHFILE ?= $(ELFFILE) FFLAGS ?= $(BMP_OPTIONS) flash $(FLASHFILE) -DEBUGGER_FLAGS ?= $(BMP_OPTIONS) debug $(ELFFILE) +DEBUGGER_FLAGS ?= $(BMP_OPTIONS) debug $(DEBUG_ELFFILE) RESET_FLAGS ?= $(BMP_OPTIONS) reset diff --git a/makefiles/tools/jlink.inc.mk b/makefiles/tools/jlink.inc.mk index 8fe84958dc..a8d48020f1 100644 --- a/makefiles/tools/jlink.inc.mk +++ b/makefiles/tools/jlink.inc.mk @@ -6,7 +6,7 @@ RESET ?= $(RIOTTOOLS)/jlink/jlink.sh FLASHFILE ?= $(BINFILE) FFLAGS ?= flash $(FLASHFILE) -DEBUGGER_FLAGS ?= debug $(ELFFILE) +DEBUGGER_FLAGS ?= debug $(DEBUG_ELFFILE) DEBUGSERVER_FLAGS ?= debug-server RESET_FLAGS ?= reset diff --git a/makefiles/tools/mspdebug.inc.mk b/makefiles/tools/mspdebug.inc.mk index b95986ec77..cbfcf80396 100644 --- a/makefiles/tools/mspdebug.inc.mk +++ b/makefiles/tools/mspdebug.inc.mk @@ -10,7 +10,7 @@ FFLAGS = $(MSPDEBUGFLAGS) "prog $(FLASHFILE)" DEBUGSERVER = $(FLASHER) DEBUGSERVER_FLAGS = $(MSPDEBUGFLAGS) gdb DEBUGGER = $(PREFIX)gdb -DEBUGGER_FLAGS = --ex="target remote localhost:2000" --ex "monitor reset halt" --ex load -ex "monitor reset halt" $(ELFFILE) +DEBUGGER_FLAGS = --ex="target remote localhost:2000" --ex "monitor reset halt" --ex load -ex "monitor reset halt" $(DEBUG_ELFFILE) # setup reset tool RESET ?= mspdebug diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index 08add4606c..bf572f2832 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -5,7 +5,7 @@ RESET ?= $(RIOTTOOLS)/openocd/openocd.sh FLASHFILE ?= $(ELFFILE) FFLAGS ?= flash $(FLASHFILE) -DEBUGGER_FLAGS ?= debug $(ELFFILE) +DEBUGGER_FLAGS ?= debug $(DEBUG_ELFFILE) DEBUGSERVER_FLAGS ?= debug-server RESET_FLAGS ?= reset diff --git a/makefiles/tools/pyocd.inc.mk b/makefiles/tools/pyocd.inc.mk index 4d38b1f909..09592c19b0 100644 --- a/makefiles/tools/pyocd.inc.mk +++ b/makefiles/tools/pyocd.inc.mk @@ -6,7 +6,7 @@ RESET ?= $(RIOTBASE)/dist/tools/pyocd/pyocd.sh PYOCD_FLASH_TARGET_TYPE ?= FLASHFILE ?= $(HEXFILE) FFLAGS ?= flash $(FLASHFILE) -DEBUGGER_FLAGS ?= debug $(ELFFILE) +DEBUGGER_FLAGS ?= debug $(DEBUG_ELFFILE) DEBUGSERVER_FLAGS ?= debug-server RESET_FLAGS ?= reset diff --git a/makefiles/tools/qemu.inc.mk b/makefiles/tools/qemu.inc.mk index ae30d3f0cf..7dddf20cd7 100644 --- a/makefiles/tools/qemu.inc.mk +++ b/makefiles/tools/qemu.inc.mk @@ -33,7 +33,7 @@ QEMU_DEBUG_FLAGS += $(EMULATOR_FLAGS) DEBUGSERVER ?= $(EMULATOR) DEBUGSERVER_FLAGS ?= $(QEMU_DEBUG_FLAGS) -DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_REMOTE) $(EMULATOR_TMP_DIR) +DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(DEBUG_ELFFILE) $(GDB_REMOTE) $(EMULATOR_TMP_DIR) DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh # No flasher available with qemu emulator diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index fa40a98c64..29c8fc7834 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -59,7 +59,7 @@ RENODE_DEBUG_FLAGS += -e "machine StartGdbServer $(GDB_PORT) true" DEBUGSERVER ?= $(EMULATOR) DEBUGSERVER_FLAGS ?= $(RENODE_DEBUG_FLAGS) -DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_REMOTE) $(EMULATOR_TMP_DIR) "-ex \"monitor start\"" +DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(DEBUG_ELFFILE) $(GDB_REMOTE) $(EMULATOR_TMP_DIR) "-ex \"monitor start\"" DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh # No flasher available with renode emulator diff --git a/makefiles/tools/uniflash.inc.mk b/makefiles/tools/uniflash.inc.mk index 2e66f3d921..e568ffa4f5 100644 --- a/makefiles/tools/uniflash.inc.mk +++ b/makefiles/tools/uniflash.inc.mk @@ -34,4 +34,4 @@ DEBUGSERVER_FLAGS ?= -p 3333 $(UNIFLASH_CONFIG_DAT) # configure the debugging tool DEBUGGER ?= $(PREFIX)gdb -DEBUGGER_FLAGS ?= -x $(UNIFLASH_CONFIG_GDB) $(ELFFILE) +DEBUGGER_FLAGS ?= -x $(UNIFLASH_CONFIG_GDB) $(DEBUG_ELFFILE)