1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

make: replace emulate% targets with EMULATE variable

This commit is contained in:
Alexandre Abadie 2020-11-26 14:43:20 +01:00
parent 753e13fba3
commit 08108f85b4
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
5 changed files with 29 additions and 23 deletions

View File

@ -397,11 +397,13 @@ include $(BOARDDIR)/Makefile.include
INCLUDES += -I$(RIOTCPU)/$(CPU)/include INCLUDES += -I$(RIOTCPU)/$(CPU)/include
include $(RIOTCPU)/$(CPU)/Makefile.include include $(RIOTCPU)/$(CPU)/Makefile.include
# Include emulator code if available and if emulate target is used # Include emulator code when required and if available
ifneq (,$(filter emulate%,$(MAKECMDGOALS))) ifeq (1,$(EMULATE))
# Use renode as default emulator # Use renode as default emulator
RIOT_EMULATOR ?= renode RIOT_EMULATOR ?= renode
-include $(RIOTMAKE)/tools/$(RIOT_EMULATOR).inc.mk -include $(RIOTMAKE)/tools/$(RIOT_EMULATOR).inc.mk
TERMDEPS += $(EMULATORDEPS)
DEBUGDEPS += $(EMULATORDEPS)
endif endif
# Include common serial logic to define TERMPROG, TERMFLAGS variables based on # Include common serial logic to define TERMPROG, TERMFLAGS variables based on
@ -746,20 +748,10 @@ debug-server:
$(call check_cmd,$(DEBUGSERVER),Debug server program) $(call check_cmd,$(DEBUGSERVER),Debug server program)
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS) $(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
emulate: all $(EMULATORDEPS) ifeq (1,$(EMULATE))
ifeq (,$(filter term cleanterm debug%,$(MAKECMDGOALS))) emulate:
$(call check_cmd,$(EMULATOR),Emulation program) $(call check_cmd,$(EMULATOR),Emulation program)
$(EMULATOR) $(EMULATOR_FLAGS) $(EMULATOR) $(EMULATOR_FLAGS)
else
@:
endif
emulate-only: $(EMULATORDEPS)
ifeq (,$(filter term cleanterm debug%,$(MAKECMDGOALS)))
$(call check_cmd,$(EMULATOR),Emulation program)
$(EMULATOR) $(EMULATOR_FLAGS)
else
@:
endif endif
reset: reset:

View File

@ -45,9 +45,10 @@ trap '' INT
# start emulator GDB server # start emulator GDB server
sh -c "\ sh -c "\
GDB_PORT=${GDB_PORT} \ GDB_PORT=${GDB_PORT} \
EMULATE=1 \
EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \ EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \
BOARD=${BOARD} \ BOARD=${BOARD} \
make -C ${APPDIR} emulate-only debug-server & \ make -C ${APPDIR} debug-server & \
echo \$! > ${EMULATOR_PIDFILE}" & echo \$! > ${EMULATOR_PIDFILE}" &
# Start the debugger and connect to the GDB server # Start the debugger and connect to the GDB server
sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}" sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}"

View File

@ -45,8 +45,9 @@ trap "cleanup terminal for ${EMULATOR} emulator" EXIT
# start emulator in background # start emulator in background
sh -c "\ sh -c "\
EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \ EMULATOR_PIDFILE=${EMULATOR_PIDFILE} \
EMULATE=1 \
BOARD=${BOARD} \ BOARD=${BOARD} \
make -C ${APPDIR} emulate-only & \ make -C ${APPDIR} emulate & \
echo \$! > ${EMULATOR_PIDFILE}" & echo \$! > ${EMULATOR_PIDFILE}" &
# with qemu, start socat redirector in background # with qemu, start socat redirector in background

View File

@ -4,17 +4,19 @@ EMULATOR_MONITOR_PORT ?= 45454
EMULATOR_MONITOR_FLAGS ?= telnet::$(EMULATOR_MONITOR_PORT),server,nowait EMULATOR_MONITOR_FLAGS ?= telnet::$(EMULATOR_MONITOR_PORT),server,nowait
FLASHFILE ?= $(ELFFILE) FLASHFILE ?= $(ELFFILE)
QEMU_SERIAL_TCP_PORT ?= 5555
EMULATOR_FLAGS = -machine $(EMULATOR_MACHINE) -device loader,file=$(ELFFILE) \ EMULATOR_FLAGS = -machine $(EMULATOR_MACHINE) -device loader,file=$(ELFFILE) \
-serial telnet::5555,server,nowait,nodelay \ -serial telnet::$(QEMU_SERIAL_TCP_PORT),server,nowait,nodelay \
-monitor $(EMULATOR_MONITOR_FLAGS) \ -monitor $(EMULATOR_MONITOR_FLAGS) \
-nographic -nographic
# Configure the qemu terminal access # Configure the qemu terminal access
PORT = /tmp/riot_$(APPLICATION)_$(BOARD)_uart EMULATOR_SERIAL_PORT ?= /tmp/riot_$(APPLICATION)_$(BOARD)_uart
PORT = $(EMULATOR_SERIAL_PORT)
RIOT_TERMPROG := $(TERMPROG) RIOT_TERMPROG := $(TERMPROG)
RIOT_TERMFLAGS := $(TERMFLAGS) RIOT_TERMFLAGS := $(TERMFLAGS)
TERMPROG := $(RIOTTOOLS)/emulator/term.sh TERMPROG := $(RIOTTOOLS)/emulator/term.sh
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(PORT) TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT)
# Configure the debugger # Configure the debugger
GDB_PORT ?= 3333 GDB_PORT ?= 3333
@ -26,3 +28,7 @@ DEBUGSERVER_FLAGS ?= $(QEMU_DEBUG_FLAGS)
DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT) DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT)
DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh
# No flasher available with qemu emulator
FLASHER ?=
FFLAGS ?=

View File

@ -30,19 +30,21 @@ ifneq (1,$(RENODE_SHOW_GUI))
endif endif
# Configure local serial port # Configure local serial port
PORT = /tmp/riot_$(APPLICATION)_$(BOARD)_uart RENODE_SYSBUS_UART ?= sysbus.uart0
RENODE_CONFIG_FLAGS += -e "emulation CreateUartPtyTerminal \"term\" \"$(PORT)\" true" EMULATOR_SERIAL_PORT ?= /tmp/riot_$(APPLICATION)_$(BOARD)_uart
RENODE_CONFIG_FLAGS += -e "connector Connect sysbus.uart0 term" RENODE_CONFIG_FLAGS += -e "emulation CreateUartPtyTerminal \"term\" \"$(EMULATOR_SERIAL_PORT)\" true"
RENODE_CONFIG_FLAGS += -e "connector Connect $(RENODE_SYSBUS_UART) term"
# Set emulator variables # Set emulator variables
EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start EMULATOR_FLAGS ?= $(RENODE_CONFIG_FLAGS) -e start
EMULATOR ?= $(RENODE) EMULATOR ?= $(RENODE)
# Configure the terminal # Configure the terminal
PORT = $(EMULATOR_SERIAL_PORT)
RIOT_TERMPROG := $(TERMPROG) RIOT_TERMPROG := $(TERMPROG)
RIOT_TERMFLAGS := $(TERMFLAGS) RIOT_TERMFLAGS := $(TERMFLAGS)
TERMPROG := $(RIOTTOOLS)/emulator/term.sh TERMPROG := $(RIOTTOOLS)/emulator/term.sh
TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(PORT) TERMFLAGS := $(RIOT_EMULATOR) $(BOARD) $(APPDIR) $(RIOT_TERMPROG) '$(RIOT_TERMFLAGS)' $(EMULATOR_SERIAL_PORT)
# Configure the debugger # Configure the debugger
GDB_PORT ?= 3333 GDB_PORT ?= 3333
@ -54,3 +56,7 @@ DEBUGSERVER_FLAGS ?= $(RENODE_DEBUG_FLAGS)
DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT) "-ex \"monitor start\"" DEBUGGER_FLAGS ?= $(BOARD) $(APPDIR) $(ELFFILE) $(GDB_PORT) "-ex \"monitor start\""
DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh DEBUGGER ?= $(RIOTTOOLS)/emulator/debug.sh
# No flasher available with renode emulator
FLASHER ?=
FFLAGS ?=