From 3cca8f4ee27ef1131611356c130c82d6f8546234 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 20 Nov 2020 22:02:32 +0100 Subject: [PATCH 01/13] makefiles/tools/renode: control renode via Makefile only --- makefiles/tools/renode.inc.mk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index ecd82f4132..f5ab546a55 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -1,2 +1,11 @@ -EMULATOR ?= $(RIOTTOOLS)/renode/run-renode.sh -EMULATOR_FLAGS ?= start +RENODE ?= renode +RENODE_IMAGE_FILE ?= $(ELFFILE) +RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc + +# Use renode interactive commands to specify the image file and board config +RENODE_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'" +RENODE_FLAGS += -e "include @$(RENODE_BOARD_CONFIG)" + +# Set emulator variables +EMULATOR_FLAGS ?= $(RENODE_FLAGS) +EMULATOR ?= $(RENODE) From c5d2050f925332083cbb284180a2f8bbf1306cdd Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 13:38:35 +0100 Subject: [PATCH 02/13] boards/cc2538dk: don't start renode in board config --- boards/cc2538dk/dist/board.resc | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/cc2538dk/dist/board.resc b/boards/cc2538dk/dist/board.resc index 3ec9edd893..f077d1d945 100644 --- a/boards/cc2538dk/dist/board.resc +++ b/boards/cc2538dk/dist/board.resc @@ -27,4 +27,3 @@ macro reset """ runMacro $reset -start From 44b8ad61e0969d1cadeead467d1da39b6c8f1674 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 27 Nov 2020 13:38:48 +0100 Subject: [PATCH 03/13] boards/hifive1*: don't start renode in board config --- boards/hifive1/dist/board.resc | 1 - boards/hifive1b/dist/board.resc | 1 - 2 files changed, 2 deletions(-) diff --git a/boards/hifive1/dist/board.resc b/boards/hifive1/dist/board.resc index 0e90f854f2..9db3a1c3bc 100644 --- a/boards/hifive1/dist/board.resc +++ b/boards/hifive1/dist/board.resc @@ -21,4 +21,3 @@ macro reset """ runMacro $reset -start diff --git a/boards/hifive1b/dist/board.resc b/boards/hifive1b/dist/board.resc index 7c08b025a5..9a52b02a3e 100644 --- a/boards/hifive1b/dist/board.resc +++ b/boards/hifive1b/dist/board.resc @@ -21,4 +21,3 @@ macro reset """ runMacro $reset -start From c61a231d7f8d04b42451283aaef30ce4cf1006b7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 27 Nov 2020 13:39:04 +0100 Subject: [PATCH 04/13] boards/firefly: don't start renode in board config --- boards/firefly/dist/board.resc | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/firefly/dist/board.resc b/boards/firefly/dist/board.resc index 6496d10f1b..b73b022795 100644 --- a/boards/firefly/dist/board.resc +++ b/boards/firefly/dist/board.resc @@ -29,4 +29,3 @@ macro reset """ runMacro $reset -start From 4707de2a5f7e942991d4d40a4f92e01401a7c87d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 13:39:16 +0100 Subject: [PATCH 05/13] makefiles/renode: add debugger config --- makefiles/tools/renode.inc.mk | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index f5ab546a55..c4aad0747f 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -1,11 +1,17 @@ RENODE ?= renode RENODE_IMAGE_FILE ?= $(ELFFILE) RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc +DEBUGGER ?= gdb-multiarch +DEBUGGER_PORT ?= 3333 # Use renode interactive commands to specify the image file and board config -RENODE_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'" -RENODE_FLAGS += -e "include @$(RENODE_BOARD_CONFIG)" +RENODE_CONFIG_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'" +RENODE_CONFIG_FLAGS += -e "include @$(RENODE_BOARD_CONFIG)" # Set emulator variables -EMULATOR_FLAGS ?= $(RENODE_FLAGS) +EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start +EMULATOR_DEBUG_FLAGS += $(RENODE_CONFIG_FLAGS) +EMULATOR_DEBUG_FLAGS += -e "machine StartGdbServer $(DEBUGGER_PORT) true" + EMULATOR ?= $(RENODE) +DEBUGGER_FLAGS ?= $(ELFFILE) -ex "target remote :$(DEBUGGER_PORT)" -ex "monitor start" From 4b149fa3c361e1c8313c24111ca2b1df7241390c Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 13:39:36 +0100 Subject: [PATCH 06/13] Makefile.include: add emulate-debug-server target --- Makefile.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.include b/Makefile.include index 5407b390de..b8da964836 100644 --- a/Makefile.include +++ b/Makefile.include @@ -746,6 +746,10 @@ emulate: $(call check_cmd,$(EMULATOR),Emulation program) $(EMULATOR) $(EMULATOR_FLAGS) +emulate-debug-server: + $(call check_cmd,$(EMULATOR),Emulation program) + $(EMULATOR) $(EMULATOR_DEBUG_FLAGS) + reset: $(call check_cmd,$(RESET),Reset program) $(RESET) $(RESET_FLAGS) From dcaa9eb59c232392921fc809143a8a72435440f1 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 18:12:43 +0100 Subject: [PATCH 07/13] makefiles/tools/renode: improve debugger management When using the debug target, the GDB server is spawned automatically in the background. This logic is moved in a external script --- dist/tools/renode/renode-debug.sh | 53 +++++++++++++++++++++++++++++++ makefiles/tools/renode.inc.mk | 22 +++++++++---- 2 files changed, 69 insertions(+), 6 deletions(-) create mode 100755 dist/tools/renode/renode-debug.sh diff --git a/dist/tools/renode/renode-debug.sh b/dist/tools/renode/renode-debug.sh new file mode 100755 index 0000000000..4db5c24253 --- /dev/null +++ b/dist/tools/renode/renode-debug.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# This script wraps Renode emulator GDB server and a debugger +# client in a single command and takes 4 arguments: the board to emulate, +# the application directory of the the current application, the elffile +# containing the firmware to debug, the debugger port and custom debugger client +# arguments + +# This script is supposed to be called from RIOTs make system when using the +# "debug" target. + +# @author Alexandre Abadie + +BOARD=$1 +APPDIR=$2 +ELFFILE=$3 + +# GDB command, usually a separate command for each platform (e.g. arm-none-eabi-gdb) +: ${GDB:=gdb-multiarch} +# Debugger client command, can be used to wrap GDB in a front-end +: ${DBG:=${GDB}} +# Default GDB port, set to 0 to disable, required != 0 for debug and debug-server targets +: ${GDB_PORT:=$4} +# Default debugger flags, +: ${DBG_DEFAULT_FLAGS:=-q -ex \"target remote :${GDB_PORT}\"} +# Custom extra debugger flags, depends on the emulator +: ${DBG_CUSTOM_FLAGS:=$5} +# Debugger flags, will be passed to sh -c, remember to escape any quotation signs. +# Use ${DBG_DEFAULT_FLAGS} to insert the default flags anywhere in the string +: ${DBG_FLAGS:=${DBG_DEFAULT_FLAGS} ${DBG_CUSTOM_FLAGS}} + +# temporary file that contains the emulator pid +EMULATOR_PIDFILE=$(mktemp -t "emulator_pid.XXXXXXXXXX") +# will be called by trap +cleanup() { + kill "$(cat ${EMULATOR_PIDFILE})" + rm -f "${EMULATOR_PIDFILE}" + exit 0 +} +# cleanup after script terminates +trap "cleanup ${EMULATOR_PIDFILE}" EXIT +# don't trap on Ctrl+C, because GDB keeps running +trap '' INT + +# start Renode GDB server +sh -c "\ + GDB_PORT=${GDB_PORT} \ + EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \ + BOARD=${BOARD} \ + make -C ${APPDIR} emulate-only debug-server & \ + echo \$! > ${EMULATOR_PIDFILE}" & +# Start the debugger and connect to the GDB server +sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}" diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index c4aad0747f..eeb80d06cb 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -1,8 +1,6 @@ RENODE ?= renode RENODE_IMAGE_FILE ?= $(ELFFILE) RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc -DEBUGGER ?= gdb-multiarch -DEBUGGER_PORT ?= 3333 # Use renode interactive commands to specify the image file and board config RENODE_CONFIG_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'" @@ -10,8 +8,20 @@ RENODE_CONFIG_FLAGS += -e "include @$(RENODE_BOARD_CONFIG)" # Set emulator variables EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start -EMULATOR_DEBUG_FLAGS += $(RENODE_CONFIG_FLAGS) -EMULATOR_DEBUG_FLAGS += -e "machine StartGdbServer $(DEBUGGER_PORT) true" - EMULATOR ?= $(RENODE) -DEBUGGER_FLAGS ?= $(ELFFILE) -ex "target remote :$(DEBUGGER_PORT)" -ex "monitor start" + +# Configure the debugger +GDB_PORT ?= 3333 +EMULATOR_PIDFILE ?= +ifneq (,$(EMULATOR_PIDFILE)) + $(info Using Renode pid file $(EMULATOR_PIDFILE)) + RENODE_CONFIG_FLAGS += --pid-file $(EMULATOR_PIDFILE) +endif +RENODE_DEBUG_FLAGS += $(RENODE_CONFIG_FLAGS) +RENODE_DEBUG_FLAGS += -e "machine StartGdbServer $(GDB_PORT) true" + +DEBUGSERVER ?= $(EMULATOR) +DEBUGSERVER_FLAGS ?= $(RENODE_DEBUG_FLAGS) + +DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT) "-ex \"monitor start\"" +DEBUGGER ?= $(RIOTTOOLS)/renode/renode-debug.sh From 11db3db714f16846e984a6b783b361b08ca72a4e Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 18:13:17 +0100 Subject: [PATCH 08/13] Makefile.include: silent emulate when debug% targets are used --- Makefile.include | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.include b/Makefile.include index b8da964836..7337cfd531 100644 --- a/Makefile.include +++ b/Makefile.include @@ -743,12 +743,12 @@ debug-server: $(DEBUGSERVER) $(DEBUGSERVER_FLAGS) emulate: +ifeq (,$(filter debug%,$(MAKECMDGOALS))) $(call check_cmd,$(EMULATOR),Emulation program) $(EMULATOR) $(EMULATOR_FLAGS) - -emulate-debug-server: - $(call check_cmd,$(EMULATOR),Emulation program) - $(EMULATOR) $(EMULATOR_DEBUG_FLAGS) +else + @: +endif reset: $(call check_cmd,$(RESET),Reset program) From d2f57c3aad7905c99a30cbfd500c03dc7a89363d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 18:34:48 +0100 Subject: [PATCH 09/13] dist/tools/renode: remove unused run-renode script --- dist/tools/renode/run-renode.sh | 84 --------------------------------- 1 file changed, 84 deletions(-) delete mode 100755 dist/tools/renode/run-renode.sh diff --git a/dist/tools/renode/run-renode.sh b/dist/tools/renode/run-renode.sh deleted file mode 100755 index 8b20e6be14..0000000000 --- a/dist/tools/renode/run-renode.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh - -# -# Unified Renode script for RIOT -# -# This script is supposed to be called from RIOTs make system, -# as it depends on certain environment variables. -# -# It will start the Renode emulator, providing it with several environment -# variables: -# $image_file Full path to the image file (see $IMAGE_FILE below) -# -# Global environment variables used: -# RENODE: Renode command name, default: "renode" -# RENODE_CONFIG: Renode configuration file name, -# default: "${BOARDSDIR}/${BOARD}/dist/board.resc" -# RENODE_BIN_CONFIG: Renode intermediate configuration file name, -# default: "${BINDIR}/board.resc" -# -# @author Bas Stottelaar - -# Default path to Renode configuration file -: ${RENODE_CONFIG:=${BOARDSDIR}/${BOARD}/dist/board.resc} -# Default path to Renode intermediate configuration file -: ${RENODE_BIN_CONFIG:=${BINDIR}/board.resc} -# Default Renode command -: ${RENODE:=renode} -# Image file used for emulation -# Default is to use $ELFFILE -: ${IMAGE_FILE:=${ELFFILE}} - -# -# config test section. -# -test_config() { - if [ ! -f "${RENODE_CONFIG}" ]; then - echo "Error: Unable to locate Renode board file" - echo " (${RENODE_CONFIG})" - exit 1 - fi -} - -# -# helper section. -# -write_config() { - echo "\$image_file = '${IMAGE_FILE}'" > "${RENODE_BIN_CONFIG}" - echo "include @${RENODE_CONFIG}" >> "${RENODE_BIN_CONFIG}" -} - -# -# now comes the actual actions -# -do_write() { - test_config - write_config - echo "Script written to '${RENODE_BIN_CONFIG}'" -} - -do_start() { - test_config - write_config - sh -c "${RENODE} '${RENODE_BIN_CONFIG}'" -} - -# -# parameter dispatching -# -ACTION="$1" - -case "${ACTION}" in - write) - echo "### Writing emulation script ###" - do_write - ;; - start) - echo "### Starting Renode ###" - do_start - ;; - *) - echo "Usage: $0 {write|start}" - exit 2 - ;; -esac From 9eadcb38f38865f5db617406566091141c7eae45 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 18:45:16 +0100 Subject: [PATCH 10/13] makefiles/renode: make emulate depends on board config file --- makefiles/tools/renode.inc.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index eeb80d06cb..94acf1547b 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -1,6 +1,7 @@ RENODE ?= renode RENODE_IMAGE_FILE ?= $(ELFFILE) RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc +EMULATORDEPS += $(RENODE_BOARD_CONFIG) # Use renode interactive commands to specify the image file and board config RENODE_CONFIG_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'" From 2bcc754fe57bcf10425643d582b2603a0f2b2d48 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 22:31:03 +0100 Subject: [PATCH 11/13] makefiles/tools: ensure all FLASHER/DEBUGGER* vars are overridable --- makefiles/tools/adafruit-nrfutil.inc.mk | 2 +- makefiles/tools/avrdude.inc.mk | 8 ++++---- makefiles/tools/bmp.inc.mk | 2 +- makefiles/tools/cc2538-bsl.inc.mk | 2 +- makefiles/tools/jlink.inc.mk | 4 ++-- makefiles/tools/openocd.inc.mk | 4 ++-- makefiles/tools/pyocd.inc.mk | 4 ++-- makefiles/tools/uniflash.inc.mk | 8 ++++---- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/makefiles/tools/adafruit-nrfutil.inc.mk b/makefiles/tools/adafruit-nrfutil.inc.mk index eea4ba8024..73c395faf2 100644 --- a/makefiles/tools/adafruit-nrfutil.inc.mk +++ b/makefiles/tools/adafruit-nrfutil.inc.mk @@ -1,6 +1,6 @@ FLASHFILE = $(HEXFILE) FLASHDEPS += $(HEXFILE).zip -FLASHER = adafruit-nrfutil +FLASHER ?= adafruit-nrfutil FFLAGS = dfu serial --port=${PORT} --baudrate=${BAUD} --touch=1200 --package=$(HEXFILE).zip --singlebank %.hex.zip: %.hex diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index 85bb78492f..29f9371f10 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -1,8 +1,8 @@ -FLASHER = avrdude +FLASHER ?= avrdude DIST_PATH = $(BOARDDIR)/dist AVARICE_PATH = $(RIOTTOOLS)/avarice DEBUGSERVER_PORT = 4242 -DEBUGSERVER = $(AVARICE_PATH)/debug_srv.sh +DEBUGSERVER ?= $(AVARICE_PATH)/debug_srv.sh # Allow choosing debugger hardware via AVR_DEBUGDEVICE, default to Atmel ICE, # which is compatible to all AVR devices and since the AVR Dragon is no longer # produced, the least expensive option @@ -15,8 +15,8 @@ else # Use JTAG as protocol for debugging DEBUGPROTO := -j $(AVR_DEBUGINTERFACE) endif -DEBUGSERVER_FLAGS = "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)" -DEBUGGER_FLAGS = "-x $(AVARICE_PATH)/gdb.conf $(ELFFILE)" +DEBUGSERVER_FLAGS ?= "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)" +DEBUGGER_FLAGS ?= "-x $(AVARICE_PATH)/gdb.conf $(ELFFILE)" DEBUGGER = "$(AVARICE_PATH)/debug.sh" $(DEBUGSERVER_FLAGS) $(AVARICE_PATH) $(DEBUGSERVER_PORT) AVRDUDE_PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU)) diff --git a/makefiles/tools/bmp.inc.mk b/makefiles/tools/bmp.inc.mk index 208793e211..47503b9722 100644 --- a/makefiles/tools/bmp.inc.mk +++ b/makefiles/tools/bmp.inc.mk @@ -1,5 +1,5 @@ FLASHER ?= $(RIOTTOOLS)/bmp/bmp.py -DEBUGGER = $(RIOTTOOLS)/bmp/bmp.py +DEBUGGER ?= $(RIOTTOOLS)/bmp/bmp.py RESET ?= $(RIOTTOOLS)/bmp/bmp.py FLASHFILE ?= $(ELFFILE) diff --git a/makefiles/tools/cc2538-bsl.inc.mk b/makefiles/tools/cc2538-bsl.inc.mk index cb9bcf7c36..6b55640338 100644 --- a/makefiles/tools/cc2538-bsl.inc.mk +++ b/makefiles/tools/cc2538-bsl.inc.mk @@ -1,5 +1,5 @@ FLASHFILE ?= $(BINFILE) -FLASHER = $(RIOTTOOLS)/cc2538-bsl/cc2538-bsl.py +FLASHER ?= $(RIOTTOOLS)/cc2538-bsl/cc2538-bsl.py FFLAGS_OPTS ?= PROG_BAUD ?= 500000 # default value in cc2538-bsl diff --git a/makefiles/tools/jlink.inc.mk b/makefiles/tools/jlink.inc.mk index 149a6183d6..83a7c0c482 100644 --- a/makefiles/tools/jlink.inc.mk +++ b/makefiles/tools/jlink.inc.mk @@ -1,6 +1,6 @@ FLASHER = $(RIOTTOOLS)/jlink/jlink.sh -DEBUGGER = $(RIOTTOOLS)/jlink/jlink.sh -DEBUGSERVER = $(RIOTTOOLS)/jlink/jlink.sh +DEBUGGER ?= $(RIOTTOOLS)/jlink/jlink.sh +DEBUGSERVER ?= $(RIOTTOOLS)/jlink/jlink.sh RESET ?= $(RIOTTOOLS)/jlink/jlink.sh FLASHFILE ?= $(BINFILE) diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index e2c4324db5..a67db84f1b 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -1,6 +1,6 @@ FLASHER ?= $(RIOTTOOLS)/openocd/openocd.sh -DEBUGGER = $(RIOTTOOLS)/openocd/openocd.sh -DEBUGSERVER = $(RIOTTOOLS)/openocd/openocd.sh +DEBUGGER ?= $(RIOTTOOLS)/openocd/openocd.sh +DEBUGSERVER ?= $(RIOTTOOLS)/openocd/openocd.sh RESET ?= $(RIOTTOOLS)/openocd/openocd.sh FLASHFILE ?= $(ELFFILE) diff --git a/makefiles/tools/pyocd.inc.mk b/makefiles/tools/pyocd.inc.mk index c23ff60057..087ab9b118 100644 --- a/makefiles/tools/pyocd.inc.mk +++ b/makefiles/tools/pyocd.inc.mk @@ -1,6 +1,6 @@ FLASHER ?= $(RIOTBASE)/dist/tools/pyocd/pyocd.sh -DEBUGGER = $(RIOTBASE)/dist/tools/pyocd/pyocd.sh -DEBUGSERVER = $(RIOTBASE)/dist/tools/pyocd/pyocd.sh +DEBUGGER ?= $(RIOTBASE)/dist/tools/pyocd/pyocd.sh +DEBUGSERVER ?= $(RIOTBASE)/dist/tools/pyocd/pyocd.sh RESET ?= $(RIOTBASE)/dist/tools/pyocd/pyocd.sh FLASH_TARGET_TYPE ?= diff --git a/makefiles/tools/uniflash.inc.mk b/makefiles/tools/uniflash.inc.mk index 5845044063..2e66f3d921 100644 --- a/makefiles/tools/uniflash.inc.mk +++ b/makefiles/tools/uniflash.inc.mk @@ -29,9 +29,9 @@ endif CCS_PATH ?= "CCS_PATH unconfigured" # configure the debug server -DEBUGSERVER = $(CCS_PATH)/ccs/ccs_base/common/uscif/gdb_agent_console -DEBUGSERVER_FLAGS = -p 3333 $(UNIFLASH_CONFIG_DAT) +DEBUGSERVER ?= $(CCS_PATH)/ccs/ccs_base/common/uscif/gdb_agent_console +DEBUGSERVER_FLAGS ?= -p 3333 $(UNIFLASH_CONFIG_DAT) # configure the debugging tool -DEBUGGER = $(PREFIX)gdb -DEBUGGER_FLAGS = -x $(UNIFLASH_CONFIG_GDB) $(ELFFILE) +DEBUGGER ?= $(PREFIX)gdb +DEBUGGER_FLAGS ?= -x $(UNIFLASH_CONFIG_GDB) $(ELFFILE) From 82eb48964d6856770ced0dc961eed032ae773d7a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sun, 22 Nov 2020 10:36:22 +0100 Subject: [PATCH 12/13] makefiles/qemu: renode: define FLASHFILE --- makefiles/tools/qemu.inc.mk | 1 + makefiles/tools/renode.inc.mk | 3 +++ 2 files changed, 4 insertions(+) diff --git a/makefiles/tools/qemu.inc.mk b/makefiles/tools/qemu.inc.mk index 9644dfcee5..9e5732b784 100644 --- a/makefiles/tools/qemu.inc.mk +++ b/makefiles/tools/qemu.inc.mk @@ -2,6 +2,7 @@ EMULATOR ?= qemu-system-arm EMULATOR_MACHINE ?= $(BOARD) EMULATOR_MONITOR_PORT ?= 45454 EMULATOR_MONITOR_FLAGS ?= telnet::$(EMULATOR_MONITOR_PORT),server,nowait +FLASHFILE ?= $(ELFFILE) EMULATOR_FLAGS = -machine $(EMULATOR_MACHINE) -device loader,file=$(ELFFILE) \ -serial stdio \ diff --git a/makefiles/tools/renode.inc.mk b/makefiles/tools/renode.inc.mk index 94acf1547b..0335fe0372 100644 --- a/makefiles/tools/renode.inc.mk +++ b/makefiles/tools/renode.inc.mk @@ -1,6 +1,9 @@ RENODE ?= renode RENODE_IMAGE_FILE ?= $(ELFFILE) RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc + +# Global build system configurations +FLASHFILE ?= $(ELFFILE) EMULATORDEPS += $(RENODE_BOARD_CONFIG) # Use renode interactive commands to specify the image file and board config From 02ee3a7d4d61e861133cf857e79ec82740968a3a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 21 Nov 2020 18:44:36 +0100 Subject: [PATCH 13/13] Makefile.include: renode: add emulate-only target --- Makefile.include | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index 7337cfd531..f2bdb9ff93 100644 --- a/Makefile.include +++ b/Makefile.include @@ -398,7 +398,7 @@ INCLUDES += -I$(RIOTCPU)/$(CPU)/include include $(RIOTCPU)/$(CPU)/Makefile.include # Include emulator code if available and if emulate target is used -ifneq (,$(filter emulate,$(MAKECMDGOALS))) +ifneq (,$(filter emulate%,$(MAKECMDGOALS))) # Use renode as default emulator RIOT_EMULATOR ?= renode -include $(RIOTMAKE)/tools/$(RIOT_EMULATOR).inc.mk @@ -742,7 +742,15 @@ debug-server: $(call check_cmd,$(DEBUGSERVER),Debug server program) $(DEBUGSERVER) $(DEBUGSERVER_FLAGS) -emulate: +emulate: all $(EMULATORDEPS) +ifeq (,$(filter debug%,$(MAKECMDGOALS))) + $(call check_cmd,$(EMULATOR),Emulation program) + $(EMULATOR) $(EMULATOR_FLAGS) +else + @: +endif + +emulate-only: $(EMULATORDEPS) ifeq (,$(filter debug%,$(MAKECMDGOALS))) $(call check_cmd,$(EMULATOR),Emulation program) $(EMULATOR) $(EMULATOR_FLAGS)