Skip to content

Commit

Permalink
build: abstract emulation and replace qemu goal with run
Browse files Browse the repository at this point in the history
This will replace the current goal of 'make qemu' with 'make run' and
moves Qemu handling into its own file and into the boards instead of
being architecture specific.

We should be able to add new boards that support some other type of
emulation (by adding scripts/Makefile.<emu type>) and allow the board to
define their own options for the use type of emulation.

'make qemu' will still work, however it will be deprecated, starting
with this commit it is recommended to use 'make run'.

Jira: ZEP-359
Change-Id: I1cacd56b4ec09421a58cf5d010e22e9035214df6
Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif authored and Anas Nashif committed Jan 10, 2017
1 parent 6bea1be commit 2bc9d69
Show file tree
Hide file tree
Showing 52 changed files with 115 additions and 88 deletions.
31 changes: 10 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,9 @@ help:
@echo 'Other generic targets:'
@echo ' all - Build all targets marked with [*]'
@echo '* zephyr - Build a zephyr application'
@echo ' qemu - Build a zephyr application and run it in qemu'
@echo ' qemugdb - Same as 'qemu' but start a GDB server on port 1234'
@echo ' run - Build a zephyr application and run it if board supports emulation'
@echo ' qemu - Build a zephyr application and run it in qemu [deprecated]'
@echo ' qemugdb - Same as 'qemu' but start a GDB server on port 1234 [deprecated]'
@echo ' flash - Build and flash an application'
@echo ' debug - Build and debug an application using GDB'
@echo ' debugserver - Build and start a GDB server (port 1234 for Qemu targets)'
Expand Down Expand Up @@ -1238,29 +1239,17 @@ tools/%: FORCE
$(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $*

QEMU_FLAGS = $(QEMU_FLAGS_$(ARCH)) -pidfile qemu.pid
-include $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/Makefile.board

ifneq ($(QEMU_PTY),)
QEMU_FLAGS += -serial pty
else
ifneq ($(QEMU_PIPE),)
# Send console output to a pipe, used for running automated sanity tests
QEMU_FLAGS += -serial pipe:$(QEMU_PIPE)
ifneq ($(EMU_PLATFORM),)
-include $(srctree)/scripts/Makefile.$(EMU_PLATFORM)
else
QEMU_FLAGS += -serial mon:stdio
endif
run:
@echo ===================================================
@echo Emulation/Simulation not supported with this board.
@echo ===================================================
endif

qemu: zephyr
$(if $(QEMU_PIPE),,@echo "To exit from QEMU enter: 'CTRL+a, x'")
@echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(ARCH))'
$(if $(CONFIG_X86_IAMCU),python $(ZEPHYR_BASE)/scripts/qemu-machine-hack.py $(KERNEL_ELF_NAME))
$(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_ELF_NAME)

# FIXME: Deprecated
qemugdb: debugserver

-include $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/Makefile.board
ifneq ($(FLASH_SCRIPT),)
flash: zephyr
@echo "Flashing $(BOARD_NAME)"
Expand Down
21 changes: 8 additions & 13 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,19 @@ DOTCONFIG = $(O)/.config
all: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)

ifeq ($(findstring qemu_,$(BOARD)),)
qemu:
@echo "Emulation not available for this board."
qemugdb: qemu
else
qemu: $(DOTCONFIG)
debug: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)
qemugdb: debugserver
@echo "This target is deprecated, please use debugserver instead"
endif

debug: $(DOTCONFIG)
flash: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)

qemugdb: debugserver

flash: $(DOTCONFIG)
qemu: $(DOTCONFIG)
@echo This target is deprecated, use 'make run' instead
$(Q)$(call zephyrmake,$(O),$@)

run: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)

ifeq ($(MAKECMDGOALS),debugserver)
Expand All @@ -110,14 +107,12 @@ endif
debugserver: FORCE
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/support/$(DEBUG_SCRIPT) debugserver


initconfig outputexports: $(DOTCONFIG)

$(BOARDCONFIG):
@rm -f $(O)/.board_*
@touch $@


ram_report: initconfig
$(Q)$(call zephyrmake,$(O),$@)

Expand Down
2 changes: 2 additions & 0 deletions boards/arm/qemu_cortex_m3/Makefile.board
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

EMU_PLATFORM = qemu

QEMU_CPU_TYPE_arm = cortex-m3
QEMU_FLAGS_arm = -cpu $(QEMU_CPU_TYPE_arm) \
-machine lm3s6965evb -nographic -vga none
Expand Down
2 changes: 2 additions & 0 deletions boards/nios2/qemu_nios2/Makefile.board
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

EMU_PLATFORM = qemu

QEMU_CPU_TYPE_nios2 = nios2
QEMU_FLAGS_nios2 = -machine altera_10m50_zephyr -nographic
QEMU_nios2 = qemu-system-nios2
Expand Down
2 changes: 2 additions & 0 deletions boards/x86/qemu_x86/Makefile.board
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

EMU_PLATFORM = qemu

QEMU_BIOS ?= /usr/share/qemu
QEMU_CPU_TYPE_x86 = qemu32
QEMU_X86_NO_REBOOT_y =
Expand Down
2 changes: 1 addition & 1 deletion doc/application/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ hardware.

.. code-block:: console
$ make [BOARD=<type> ...] qemu
$ make [BOARD=<type> ...] run
The Zephyr build system generates a :file:`zephyr.elf` image file
and then begins running it in the terminal console.
Expand Down
4 changes: 2 additions & 2 deletions doc/getting_started/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ type:

.. code-block:: console
$ make BOARD=qemu_x86 qemu
$ make BOARD=qemu_x86 run
To run an application using the ARM qemu_cortex_m3 board configuration, type:

.. code-block:: console
$ make BOARD=qemu_cortex_m3 qemu
$ make BOARD=qemu_cortex_m3 run
QEMU is not supported on all boards and SoCs. When developing for a specific
hardware target you should always test on the actual hardware and should not
Expand Down
4 changes: 2 additions & 2 deletions doc/subsystems/bluetooth/devel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The host OS's Bluetooth controller is connected to the second QEMU
serial line using a UNIX socket. This socket employs the QEMU option
:literal:`-serial unix:/tmp/bt-server-bredr`. This option is already
added to QEMU through :makevar:`QEMU_EXTRA_FLAGS` in most Bluetooth
sample Makefiles' and made available through the 'qemu' make target.
sample Makefiles' and made available through the 'run' make target.

On the host side, BlueZ allows to export its Bluetooth controller
through a so-called user channel for QEMU to use:
Expand All @@ -62,7 +62,7 @@ through a so-called user channel for QEMU to use:

.. code-block:: console
$ make qemu
$ make run
Running QEMU now results in a connection with the second serial line to
the :literal:`bt-server-bredr` UNIX socket, letting the application
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/README
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UNIX socket. When Bluetooth (CONFIG_BLUETOOTH) and Bluetooth HCI UART driver
From now on Bluetooth might be used by the application. To run application in
the qemu run:

$ make qemu
$ make run

= Bluetooth sanity check =

Expand Down
4 changes: 2 additions & 2 deletions samples/hello_world/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ on QEMU as follows:
.. code-block:: console
$ cd samples/hello_world
$ make qemu
$ make run
To build the single thread version, use the supplied configuration file for
single thread: :file:`prj_single.conf`:

.. code-block:: console
$ make CONF_FILE=prj_single.conf qemu
$ make CONF_FILE=prj_single.conf run
Sample Output
-------------
Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/cpp_synchronization/microkernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Building and Running Project:
This microkernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/cpp_synchronization/nanokernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Building and Running Project:
This nanokernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/kernel_event_logger/microkernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Building and Running Project:
This microkernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/kernel_event_logger/nanokernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Building and Running Project:
This nanokernel project outputs to the console. It can be built and executed
on QEMU as follows (only x86 and ARM platforms):

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/philosophers/microkernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Building and Running Project:
This microkernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/philosophers/nanokernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Building and Running Project:
This nanokernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/synchronization/microkernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Building and Running Project:
This microkernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/synchronization/nanokernel/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Building and Running Project:
This nanokernel project outputs to the console. It can be built and executed
on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/legacy/task_profiler/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ Term1: QEMU must be launched the following way

<--snippet
cd $APP_BASE
make BOARD=... QEMU_PTY=1 qemu
make BOARD=... QEMU_PTY=1 run
-->

QEMU will display virtually created TTY
Expand Down
2 changes: 1 addition & 1 deletion samples/logger-hook/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Building and Running Project:
This unified project outputs to the console.
It can be built and executed on QEMU as follows:

make qemu
make run

--------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions samples/net/README
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the data and sends it back.
The echo client can be running in the host system in which
case you need to use SLIP to connect to qemu. This usage scenario
is described in net-tools project README file [1]. This is the default
if you type "make qemu" in echo_server test application directory.
if you type "make run" in echo_server test application directory.
The network IP stack hooks right under IP stack (network level)
and sends the IP packet to host using SLIP. The layer 2 is the
SLIP layer in this case, no radio layer is simulated or used.
Expand Down Expand Up @@ -41,7 +41,7 @@ is correct.
The echo server can be running in the host system in which case
you need to use SLIP to connect to qemu. This usage scenario
is described in net-tools project README file [1]. This is the default
if you type "make qemu" in echo_client test application directory.
if you type "make run" in echo_client test application directory.
The network IP stack hooks right under IP stack (network level)
and sends the IP packet to host using SLIP. The layer 2 is the
SLIP layer in this case, no radio layer is simulated or used.
Expand Down
2 changes: 1 addition & 1 deletion samples/net/dns_client/README_IPv4
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ open a terminal window and type:

Open a terminal where the project was build (i.e. samples/net/dns_client) and type:

make qemu
make run


Usage FRDM K64F
Expand Down
8 changes: 4 additions & 4 deletions samples/net/ieee802154/qemu/Makefile.qemu
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ export QEMU_NUM
export QEMU_EXTRA_FLAGS

qemu1: setup_pipes_dual
$(Q)$(call zephyrmake,$(O),qemu)
$(Q)$(call zephyrmake,$(O),run)

qemu2: setup_pipes_dual
$(Q)$(call zephyrmake,$(O),qemu)
$(Q)$(call zephyrmake,$(O),run)

qemu1monitor: setup_pipes_dual_monitor
$(Q)$(call zephyrmake,$(O),qemu)
$(Q)$(call zephyrmake,$(O),run)

qemu2monitor: setup_pipes_dual_monitor
$(Q)$(call zephyrmake,$(O),qemu)
$(Q)$(call zephyrmake,$(O),run)
2 changes: 1 addition & 1 deletion samples/net/mbedtls_dtlsclient/README
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ QEMU gets terminated, due the Netwrok interface (tap) being restarted.

g) From the app directory type

$make pristine && make qemu
$make pristine && make run

The screen should display

Expand Down
2 changes: 1 addition & 1 deletion samples/net/zoap_client/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the net-tools[1] project for more details.

It can be built and executed on QEMU as follows:

make qemu
make run

[1] net-tools:
https://gerrit.zephyrproject.org/r/gitweb?p=net-tools.git;a=tree
Expand Down
2 changes: 1 addition & 1 deletion samples/net/zoap_server/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ See the net-tools[1] project for more details

It can be built and executed on QEMU as follows:

make qemu
make run

[1] net-tools:
https://gerrit.zephyrproject.org/r/gitweb?p=net-tools.git;a=tree
Expand Down
4 changes: 2 additions & 2 deletions samples/nfc/nfc_hello/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ To test the serial line routines, open a terminal window and type:
Open another terminal window and type:

For QEMU x86:
make pristine && make qemu
make pristine && make run

For QEMU ARM:
make pristine && make BOARD=qemu_cortex_m3 qmeu
make pristine && make BOARD=qemu_cortex_m3 run


Sample output
Expand Down
2 changes: 1 addition & 1 deletion samples/philosophers/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on QEMU as follows:
.. code-block:: console
$ cd samples/philosophers
$ make qemu
$ make run
Sample Output
-------------
Expand Down
2 changes: 1 addition & 1 deletion samples/synchronization/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on QEMU as follows:
.. code-block:: console
$ cd samples/synchronization
$ make qemu
$ make run
Sample Output
-------------
Expand Down
Loading

0 comments on commit 2bc9d69

Please sign in to comment.