build: abstract emulation and replace qemu goal with run

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 <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-01-07 16:31:34 -05:00 committed by Anas Nashif
parent 6bea1becab
commit 2bc9d69981
52 changed files with 119 additions and 92 deletions

View file

@ -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)'
@ -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
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)
else
QEMU_FLAGS += -serial mon:stdio
endif
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 ($(EMU_PLATFORM),)
-include $(srctree)/scripts/Makefile.$(EMU_PLATFORM)
else
run:
@echo ===================================================
@echo Emulation/Simulation not supported with this board.
@echo ===================================================
endif
ifneq ($(FLASH_SCRIPT),)
flash: zephyr
@echo "Flashing $(BOARD_NAME)"

View file

@ -81,24 +81,21 @@ 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)
$(Q)$(call zephyrmake,$(O),$@)
qemugdb: debugserver
@echo "This target is deprecated, please use debugserver instead"
endif
debug: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)
flash: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)
qemugdb: debugserver
qemu: $(DOTCONFIG)
@echo This target is deprecated, use 'make run' instead
$(Q)$(call zephyrmake,$(O),$@)
run: $(DOTCONFIG)
$(Q)$(call zephyrmake,$(O),$@)
ifeq ($(MAKECMDGOALS),debugserver)
ARCH = $(notdir $(subst /$(BOARD),,$(wildcard $(ZEPHYR_BASE)/boards/*/$(BOARD))))
-include $(ZEPHYR_BASE)/boards/$(ARCH)/$(BOARD)/Makefile.board
@ -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),$@)

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,6 @@
EMU_PLATFORM = qemu
QEMU_BIOS ?= /usr/share/qemu
QEMU_CPU_TYPE_x86 = qemu32
QEMU_X86_NO_REBOOT_y =

View file

@ -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.

View file

@ -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

View file

@ -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:
@ -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

View file

@ -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 =

View file

@ -18,7 +18,7 @@ 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
@ -26,7 +26,7 @@ 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
-------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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.
@ -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.

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -27,7 +27,7 @@ on QEMU as follows:
.. code-block:: console
$ cd samples/philosophers
$ make qemu
$ make run
Sample Output
-------------

View file

@ -19,7 +19,7 @@ on QEMU as follows:
.. code-block:: console
$ cd samples/synchronization
$ make qemu
$ make run
Sample Output
-------------

37
scripts/Makefile.qemu Normal file
View file

@ -0,0 +1,37 @@
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Abstraction of 'run' goal with Qemu
QEMU_FLAGS = $(QEMU_FLAGS_$(ARCH)) -pidfile qemu.pid
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)
else
QEMU_FLAGS += -serial mon:stdio
endif
endif
qemu: run
run: 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)

View file

@ -28,7 +28,7 @@ Listening on /tmp/bt-server-bredr
To build tester application for QEMU:
$ make pristine && make BOARD=qemu_cortex_m3 CONF_FILE=qemu.conf qemu
$ make pristine && make BOARD=qemu_cortex_m3 CONF_FILE=qemu.conf run
Note: Target board have to support enough UARTs for BTP and controller.
We recommend using qemu_cortex_m3.

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -12,7 +12,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed on QEMU as
follows:
make qemu
make run
---------------------------------------------------------------------------

View file

@ -12,7 +12,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed on QEMU as
follows:
make qemu
make run
---------------------------------------------------------------------------

View file

@ -57,7 +57,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
---------------------------------------------------------------------------

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -11,7 +11,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
--------------------------------------------------------------------------------

View file

@ -17,7 +17,7 @@ Building and Running Project:
This project outputs to the console. It can be built and executed
on QEMU as follows:
make qemu
make run
--------------------------------------------------------------------------------

View file

@ -11,7 +11,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
--------------------------------------------------------------------------------

View file

@ -11,7 +11,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
--------------------------------------------------------------------------------

View file

@ -11,7 +11,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
--------------------------------------------------------------------------------

View file

@ -12,7 +12,7 @@ Build and Run
* QEMU x86
Build & run:
make && make qemu
make run
* Arduino 101