diff --git a/Makefile.include b/Makefile.include index 350d15fd08..e3dd7383d3 100644 --- a/Makefile.include +++ b/Makefile.include @@ -395,6 +395,13 @@ include $(BOARDDIR)/Makefile.include 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))) + # Use renode as default emulator + RIOT_EMULATOR ?= renode + -include $(RIOTMAKE)/tools/$(RIOT_EMULATOR).inc.mk +endif + # Assume GCC/GNU as supported toolchain if CPU's Makefile.include doesn't # provide this macro TOOLCHAINS_SUPPORTED ?= gnu diff --git a/boards/cc2538dk/Makefile.include b/boards/cc2538dk/Makefile.include index aa93b15f7c..966f546ddf 100644 --- a/boards/cc2538dk/Makefile.include +++ b/boards/cc2538dk/Makefile.include @@ -6,7 +6,4 @@ PROGRAMMER_SERIAL ?= 06EB PORT_LINUX ?= $(word 2,$(shell $(RIOTTOOLS)/usb-serial/find-tty.sh '^$(PROGRAMMER_SERIAL)')) PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*))) -# setup emulator -include $(RIOTMAKE)/tools/renode.inc.mk - include $(RIOTBOARD)/common/cc2538/Makefile.include diff --git a/boards/microbit/Makefile.include b/boards/microbit/Makefile.include index ec6606b587..388569066b 100644 --- a/boards/microbit/Makefile.include +++ b/boards/microbit/Makefile.include @@ -12,11 +12,7 @@ else ifeq (pyocd,$(PROGRAMMER)) endif # QEMU 4.0 added microbit system emulation. -EMULATOR = qemu-system-arm -EMULATOR_FLAGS = -M microbit -device loader,file=$(ELFFILE) \ - -serial stdio \ - -monitor telnet::45454,server,nowait \ - -nographic +RIOT_EMULATOR ?= qemu # include nrf51 boards common configuration include $(RIOTBOARD)/common/nrf51/Makefile.include diff --git a/makefiles/tools/qemu.inc.mk b/makefiles/tools/qemu.inc.mk new file mode 100644 index 0000000000..9644dfcee5 --- /dev/null +++ b/makefiles/tools/qemu.inc.mk @@ -0,0 +1,9 @@ +EMULATOR ?= qemu-system-arm +EMULATOR_MACHINE ?= $(BOARD) +EMULATOR_MONITOR_PORT ?= 45454 +EMULATOR_MONITOR_FLAGS ?= telnet::$(EMULATOR_MONITOR_PORT),server,nowait + +EMULATOR_FLAGS = -machine $(EMULATOR_MACHINE) -device loader,file=$(ELFFILE) \ + -serial stdio \ + -monitor $(EMULATOR_MONITOR_FLAGS) \ + -nographic