mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
dist/tools/emulator: allow use of term with emulators
This commit is contained in:
parent
916f554d2a
commit
c8ce41c9de
@ -747,7 +747,7 @@ debug-server:
|
||||
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
|
||||
|
||||
emulate: all $(EMULATORDEPS)
|
||||
ifeq (,$(filter debug%,$(MAKECMDGOALS)))
|
||||
ifeq (,$(filter term cleanterm debug%,$(MAKECMDGOALS)))
|
||||
$(call check_cmd,$(EMULATOR),Emulation program)
|
||||
$(EMULATOR) $(EMULATOR_FLAGS)
|
||||
else
|
||||
@ -755,7 +755,7 @@ else
|
||||
endif
|
||||
|
||||
emulate-only: $(EMULATORDEPS)
|
||||
ifeq (,$(filter debug%,$(MAKECMDGOALS)))
|
||||
ifeq (,$(filter term cleanterm debug%,$(MAKECMDGOALS)))
|
||||
$(call check_cmd,$(EMULATOR),Emulation program)
|
||||
$(EMULATOR) $(EMULATOR_FLAGS)
|
||||
else
|
||||
|
67
dist/tools/emulator/term.sh
vendored
Executable file
67
dist/tools/emulator/term.sh
vendored
Executable file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script wraps an emulator (renode or qemu) and a terminal client
|
||||
# in a single command and takes 6 arguments:
|
||||
# 1. the type of emulator (renode or qemu)
|
||||
# 2. the board to emulate,
|
||||
# 3. the application directory of the the current application
|
||||
# 4. the terminal client tool
|
||||
# 5. the options of the terminal client
|
||||
# 6. the serial port to connect to the terminal client to
|
||||
|
||||
# This script is supposed to be called from RIOTs make system when using the
|
||||
# "term" or "cleanterm" targets.
|
||||
|
||||
# @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
|
||||
EMULATOR=$1
|
||||
BOARD=$2
|
||||
APPDIR=$3
|
||||
TERMPROG=$4
|
||||
TERMFLAGS=$5
|
||||
PORT=$6
|
||||
|
||||
# temporary file that contains the emulator pid
|
||||
EMULATOR_PIDFILE=$(mktemp -t "emulator_pid.XXXXXXXXXX")
|
||||
SOCAT_PIDFILE=$(mktemp -t "socat_pid.XXXXXXXXXX")
|
||||
|
||||
# will be called by trap
|
||||
cleanup() {
|
||||
if [ ${EMULATOR} = "qemu" ]
|
||||
then
|
||||
echo "cleanup ${SOCAT_PIDFILE}"
|
||||
kill "$(cat ${SOCAT_PIDFILE})"
|
||||
rm -f "${SOCAT_PIDFILE}"
|
||||
fi
|
||||
echo "cleanup ${EMULATOR_PIDFILE}"
|
||||
kill "$(cat ${EMULATOR_PIDFILE})"
|
||||
rm -f "${EMULATOR_PIDFILE}"
|
||||
rm -f ${PORT}
|
||||
exit 0
|
||||
}
|
||||
# cleanup after script terminates
|
||||
trap "cleanup terminal for ${EMULATOR} emulator" EXIT
|
||||
|
||||
# start emulator in background
|
||||
sh -c "\
|
||||
EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \
|
||||
BOARD=${BOARD} \
|
||||
make -C ${APPDIR} emulate-only & \
|
||||
echo \$! > ${EMULATOR_PIDFILE}" &
|
||||
|
||||
# with qemu, start socat redirector in background
|
||||
if [ ${EMULATOR} = "qemu" ]
|
||||
then
|
||||
sleep 1
|
||||
sh -c "\
|
||||
socat pty,link=${PORT},raw,echo=0 TCP:localhost:5555 & \
|
||||
echo \$! > ${SOCAT_PIDFILE}" &
|
||||
fi
|
||||
|
||||
# Start the terminal client after PORT is available. PORT can be a symlink.
|
||||
while [ ! -L "${PORT}" ]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sh -c "${TERMPROG} ${TERMFLAGS}"
|
@ -5,10 +5,17 @@ EMULATOR_MONITOR_FLAGS ?= telnet::$(EMULATOR_MONITOR_PORT),server,nowait
|
||||
FLASHFILE ?= $(ELFFILE)
|
||||
|
||||
EMULATOR_FLAGS = -machine $(EMULATOR_MACHINE) -device loader,file=$(ELFFILE) \
|
||||
-serial stdio \
|
||||
-serial telnet::5555,server,nowait,nodelay \
|
||||
-monitor $(EMULATOR_MONITOR_FLAGS) \
|
||||
-nographic
|
||||
|
||||
# Configure the qemu terminal access
|
||||
PORT = /tmp/riot_$(APPLICATION)_$(BOARD)_uart
|
||||
RIOT_TERMPROG := $(TERMPROG)
|
||||
RIOT_TERMFLAGS := $(TERMFLAGS)
|
||||
TERMPROG := $(RIOTTOOLS)/emulator/term.sh
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(PORT)
|
||||
|
||||
# Configure the debugger
|
||||
GDB_PORT ?= 3333
|
||||
QEMU_DEBUG_FLAGS += -S -gdb tcp::$(GDB_PORT)
|
||||
|
@ -9,18 +9,29 @@ 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
|
||||
|
||||
# Configure local serial port
|
||||
PORT = /tmp/riot_$(APPLICATION)_$(BOARD)_uart
|
||||
RENODE_CONFIG_FLAGS += -e "emulation CreateUartPtyTerminal \"term\" \"$(PORT)\" true"
|
||||
RENODE_CONFIG_FLAGS += -e "connector Connect sysbus.uart0 term"
|
||||
|
||||
# Set emulator variables
|
||||
EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start
|
||||
EMULATOR ?= $(RENODE)
|
||||
|
||||
# Configure the terminal
|
||||
RIOT_TERMPROG := $(TERMPROG)
|
||||
RIOT_TERMFLAGS := $(TERMFLAGS)
|
||||
TERMPROG := $(RIOTTOOLS)/emulator/term.sh
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(PORT)
|
||||
|
||||
# Configure the debugger
|
||||
GDB_PORT ?= 3333
|
||||
RENODE_DEBUG_FLAGS += $(RENODE_CONFIG_FLAGS)
|
||||
RENODE_DEBUG_FLAGS += -e "machine StartGdbServer $(GDB_PORT) true"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user