mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
make/emulate: use unix sockets with qemu
This commit is contained in:
parent
ea13f4421e
commit
415f9aa0ee
13
dist/tools/emulator/debug.sh
vendored
13
dist/tools/emulator/debug.sh
vendored
@ -14,23 +14,24 @@
|
||||
BOARD=$1
|
||||
APPDIR=$2
|
||||
ELFFILE=$3
|
||||
RUNTIME_TMP_DIR=$5
|
||||
|
||||
# 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}
|
||||
: ${GDB_REMOTE:=$4}
|
||||
# Default debugger flags,
|
||||
: ${DBG_DEFAULT_FLAGS:=-q -ex \"target remote :${GDB_PORT}\"}
|
||||
: ${DBG_DEFAULT_FLAGS:=-q -ex \"target remote ${GDB_REMOTE}\"}
|
||||
# Custom extra debugger flags, depends on the emulator
|
||||
: ${DBG_CUSTOM_FLAGS:=$5}
|
||||
: ${DBG_CUSTOM_FLAGS:=$6}
|
||||
# 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")
|
||||
EMULATOR_PIDFILE="${RUNTIME_TMP_DIR}/emulator_pid"
|
||||
# will be called by trap
|
||||
cleanup() {
|
||||
kill "$(cat ${EMULATOR_PIDFILE})"
|
||||
@ -44,11 +45,13 @@ trap '' INT
|
||||
|
||||
# start emulator GDB server
|
||||
sh -c "\
|
||||
GDB_PORT=${GDB_PORT} \
|
||||
GDB_REMOTE=${GDB_REMOTE} \
|
||||
EMULATE=1 \
|
||||
RUNTIME_TMP_DIR=${RUNTIME_TMP_DIR} \
|
||||
EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \
|
||||
BOARD=${BOARD} \
|
||||
make -C ${APPDIR} debug-server & \
|
||||
echo \$! > ${EMULATOR_PIDFILE}" &
|
||||
# Start the debugger and connect to the GDB server
|
||||
sleep 1
|
||||
sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}"
|
||||
|
9
dist/tools/emulator/term.sh
vendored
9
dist/tools/emulator/term.sh
vendored
@ -20,10 +20,11 @@ APPDIR=$3
|
||||
TERMPROG=$4
|
||||
TERMFLAGS=$5
|
||||
PORT=$6
|
||||
RUNTIME_TMP_DIR=$7
|
||||
|
||||
# temporary file that contains the emulator pid
|
||||
EMULATOR_PIDFILE=$(mktemp -t "emulator_pid.XXXXXXXXXX")
|
||||
SOCAT_PIDFILE=$(mktemp -t "socat_pid.XXXXXXXXXX")
|
||||
EMULATOR_PIDFILE="${RUNTIME_TMP_DIR}/emulator_pid"
|
||||
SOCAT_PIDFILE="${RUNTIME_TMP_DIR}/socat_pid"
|
||||
|
||||
# will be called by trap
|
||||
cleanup() {
|
||||
@ -37,6 +38,7 @@ cleanup() {
|
||||
kill "$(cat ${EMULATOR_PIDFILE})"
|
||||
rm -f "${EMULATOR_PIDFILE}"
|
||||
rm -f ${PORT}
|
||||
rmdir ${RUNTIME_TMP_DIR}
|
||||
exit 0
|
||||
}
|
||||
# cleanup after script terminates
|
||||
@ -46,6 +48,7 @@ trap "cleanup terminal for ${EMULATOR} emulator" EXIT
|
||||
sh -c "\
|
||||
EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \
|
||||
EMULATE=1 \
|
||||
RUNTIME_TMP_DIR=${RUNTIME_TMP_DIR} \
|
||||
BOARD=${BOARD} \
|
||||
make -C ${APPDIR} emulate & \
|
||||
echo \$! > ${EMULATOR_PIDFILE}" &
|
||||
@ -55,7 +58,7 @@ if [ ${EMULATOR} = "qemu" ]
|
||||
then
|
||||
sleep 1
|
||||
sh -c "\
|
||||
socat pty,link=${PORT},raw,echo=0 TCP:localhost:5555 & \
|
||||
socat unix-connect:${RUNTIME_TMP_DIR}/uart_socket pty,link=${PORT},raw,echo=0 & \
|
||||
echo \$! > ${SOCAT_PIDFILE}" &
|
||||
fi
|
||||
|
||||
|
@ -1,35 +1,39 @@
|
||||
QEMU ?= qemu-system-arm
|
||||
QEMU_MACHINE ?= $(BOARD)
|
||||
QEMU_MONITOR_PORT ?= 45454
|
||||
QEMU_MONITOR_FLAGS ?= telnet::$(QEMU_MONITOR_PORT),server,nowait
|
||||
FLASHFILE ?= $(ELFFILE)
|
||||
|
||||
QEMU_SERIAL_TCP_PORT ?= 5555
|
||||
ifeq (,$(RUNTIME_TMP_DIR))
|
||||
RUNTIME_TMP_DIR := $(shell mktemp -td riot_$(APPLICATION)_$(BOARD).XXXXX)
|
||||
endif
|
||||
|
||||
EMULATOR_SERIAL_PORT ?= $(RUNTIME_TMP_DIR)/uart
|
||||
EMULATOR_MONITOR ?= $(RUNTIME_TMP_DIR)/mon
|
||||
|
||||
# Configure emulator variables
|
||||
EMULATOR ?= $(QEMU)
|
||||
EMULATOR_FLAGS ?= -machine $(QEMU_MACHINE) -device loader,file=$(ELFFILE) \
|
||||
-serial telnet::$(QEMU_SERIAL_TCP_PORT),server,nowait,nodelay \
|
||||
-monitor $(QEMU_MONITOR_FLAGS) \
|
||||
EMULATOR_FLAGS ?= -machine $(QEMU_MACHINE) \
|
||||
-device loader,file=$(ELFFILE) \
|
||||
-serial unix:$(EMULATOR_SERIAL_PORT)_socket,server=on,wait=off \
|
||||
-monitor unix:$(EMULATOR_MONITOR)_socket,server=on,wait=off \
|
||||
-nographic
|
||||
|
||||
# Configure the qemu terminal access
|
||||
EMULATOR_SERIAL_PORT ?= /tmp/riot_$(APPLICATION)_$(BOARD)_uart
|
||||
PORT = $(EMULATOR_SERIAL_PORT)
|
||||
RIOT_TERMPROG := $(TERMPROG)
|
||||
RIOT_TERMFLAGS := $(TERMFLAGS)
|
||||
TERMPROG := $(RIOTTOOLS)/emulator/term.sh
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT)
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT) $(RUNTIME_TMP_DIR)
|
||||
|
||||
# Configure the debugger
|
||||
GDB_PORT ?= 3333
|
||||
QEMU_DEBUG_FLAGS += -S -gdb tcp::$(GDB_PORT)
|
||||
# Configure the debugger ,wait=off
|
||||
GDB_REMOTE ?= $(RUNTIME_TMP_DIR)/gdb_socket
|
||||
|
||||
QEMU_DEBUG_FLAGS += -S -gdb unix:$(GDB_REMOTE),server=on
|
||||
QEMU_DEBUG_FLAGS += $(EMULATOR_FLAGS)
|
||||
|
||||
DEBUGSERVER ?= $(EMULATOR)
|
||||
DEBUGSERVER_FLAGS ?= $(QEMU_DEBUG_FLAGS)
|
||||
|
||||
DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT)
|
||||
DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_REMOTE) $(RUNTIME_TMP_DIR)
|
||||
DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh
|
||||
|
||||
# No flasher available with qemu emulator
|
||||
|
@ -6,6 +6,10 @@ RENODE_BOARD_CONFIG ?= $(BOARDDIR)/dist/board.resc
|
||||
FLASHFILE ?= $(ELFFILE)
|
||||
EMULATORDEPS += $(RENODE_BOARD_CONFIG)
|
||||
|
||||
ifeq (,$(RUNTIME_TMP_DIR))
|
||||
RUNTIME_TMP_DIR := $(shell mktemp -td riot_$(APPLICATION)_$(BOARD).XXXXX)
|
||||
endif
|
||||
|
||||
# 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)"
|
||||
@ -44,17 +48,18 @@ PORT = $(EMULATOR_SERIAL_PORT)
|
||||
RIOT_TERMPROG := $(TERMPROG)
|
||||
RIOT_TERMFLAGS := $(TERMFLAGS)
|
||||
TERMPROG := $(RIOTTOOLS)/emulator/term.sh
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT)
|
||||
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT) $(RUNTIME_TMP_DIR)
|
||||
|
||||
# Configure the debugger
|
||||
GDB_PORT ?= 3333
|
||||
GDB_REMOTE ?= :$(GDB_PORT)
|
||||
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_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_REMOTE) $(RUNTIME_TMP_DIR) "-ex \"monitor start\""
|
||||
DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh
|
||||
|
||||
# No flasher available with renode emulator
|
||||
|
Loading…
Reference in New Issue
Block a user