mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #15490 from aabadie/pr/tools/renode_refactor
tools/renode: refactor integration + add debugger support
This commit is contained in:
commit
0b8ec0ba11
@ -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,9 +742,21 @@ 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)
|
||||
else
|
||||
@:
|
||||
endif
|
||||
|
||||
reset:
|
||||
$(call check_cmd,$(RESET),Reset program)
|
||||
|
1
boards/cc2538dk/dist/board.resc
vendored
1
boards/cc2538dk/dist/board.resc
vendored
@ -27,4 +27,3 @@ macro reset
|
||||
"""
|
||||
|
||||
runMacro $reset
|
||||
start
|
||||
|
1
boards/firefly/dist/board.resc
vendored
1
boards/firefly/dist/board.resc
vendored
@ -29,4 +29,3 @@ macro reset
|
||||
"""
|
||||
|
||||
runMacro $reset
|
||||
start
|
||||
|
1
boards/hifive1/dist/board.resc
vendored
1
boards/hifive1/dist/board.resc
vendored
@ -21,4 +21,3 @@ macro reset
|
||||
"""
|
||||
|
||||
runMacro $reset
|
||||
start
|
||||
|
1
boards/hifive1b/dist/board.resc
vendored
1
boards/hifive1b/dist/board.resc
vendored
@ -21,4 +21,3 @@ macro reset
|
||||
"""
|
||||
|
||||
runMacro $reset
|
||||
start
|
||||
|
53
dist/tools/renode/renode-debug.sh
vendored
Executable file
53
dist/tools/renode/renode-debug.sh
vendored
Executable file
@ -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 <alexandre.abadie@inria.fr>
|
||||
|
||||
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}"
|
84
dist/tools/renode/run-renode.sh
vendored
84
dist/tools/renode/run-renode.sh
vendored
@ -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 <basstottelaar@gmail.com>
|
||||
|
||||
# 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
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 ?=
|
||||
|
@ -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 \
|
||||
|
@ -1,2 +1,31 @@
|
||||
EMULATOR ?= $(RIOTTOOLS)/renode/run-renode.sh
|
||||
EMULATOR_FLAGS ?= start
|
||||
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
|
||||
RENODE_CONFIG_FLAGS += -e "set image_file '$(RENODE_IMAGE_FILE)'"
|
||||
RENODE_CONFIG_FLAGS += -e "include @$(RENODE_BOARD_CONFIG)"
|
||||
|
||||
# Set emulator variables
|
||||
EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start
|
||||
EMULATOR ?= $(RENODE)
|
||||
|
||||
# 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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user