Commit graph

42 commits

Author SHA1 Message Date
Johan Hedberg c68770eda8 qemu: Use BT_UART instead of BT_NO_DRIVER to enable serial port
The CONFIG_BT_NO_DRIVER option will be going away. Use the
CONFIG_BT_UART option instead (selected by UART HCI drivers) to
determine whether to enable the qemu serial port for Bluetooth.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Dmitrii Golovanov 5008c31f8c config: qemu: Add QEMU_EXTRA_FLAGS config option
Add QEMU_EXTRA_FLAGS as QEMU board config option.

This allows Twister tests to provide additional device setup
commands to QEMU in prj.conf or testcase.yaml configuration files.

Example use case: to setup TCP or UDP network interfaces
with non-conflicting port numbers in different test suites
to avoid conflicts when Twister run tests in parallel on the
same host.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-10-20 15:03:55 +02:00
Tomasz Bursztyka 7a8a5f4a30 cmake: Add Qemu NVMe emulated device
As it is meant to be used on the tests/drivers/disk test case, it will
currently create a dummy 1Mb image on a fixed path to serve as a NVMe
disk.

It could be made of an alternate path and size, if necessary.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-04-07 13:28:47 +02:00
Abe Levkoy c9190960a2 cmake: emu: qemu: Create pipe file before using
For run_qemu and qemu_debugserver, the targets that use QEMU_PIPE,
ensure that the QEMU_PIPE file exists before passing the path to QEMU as
an argument.

Signed-off-by: Abe Levkoy <alevkoy@google.com>
2023-04-04 13:35:03 +02:00
Alp Sayin a01877c6e0 cmake: emu: qemu: start QEMU gdbserver only if relevant Kconfig is set
This removes the enforced `-s` option and only passes in a `-gdb` only if
CONFIG_QEMU_GDBSERVER_LISTEN_DEV is set. When unset, it allows users to
utilize QEMU_EXTRA_FLAGS from environment preventing a clash that occurs
if `-s` and `-gdb` are both passed to QEMU invocation.

Signed-off-by: Alp Sayin <alpsayin@gmail.com>
2023-02-20 09:48:52 +01:00
Henrik Brix Andersen b3b64e9ede cmake: emu: qemu: do not enable CAN bus on NIOS2 and LEON3
QEMU for NIOS2 and LEON3 do not provide support for the "can-bus" object
type. Skip configuring CAN bus command line arguments for these.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-11-02 22:10:05 +09:00
Henrik Brix Andersen abf82013ac drivers: can: add support for configuring CAN emulation in QEMU
Add support for configuring CAN emulation support in QEMU. For now, the
only supported CAN controller is the single-channel Kvaser PCIcan PCI card.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-11-01 15:22:31 -04:00
Daniel DeGrasse a13e5d0a2d cmake: emu: ensure that QEMU_PIPE is set when using sysbuild
Ensure that QEMU_PIPE variable is set when using sysbuild. This is required
because twister will use the "main" sysbuild application as the target for
"ninja run" when testing QEMU targets, which means that the "main" build
must be aware of any QEMU_PIPE setting passed by twister at build time.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Kumar Gala 2f031efea8 cmake: sim: Update simulator related cmake to use CONFIG_MP_MAX_NUM_CPUS
Update cmake related files that are used by simulators to use
CONFIG_MP_MAX_NUM_CPUS instead of CONFIG_MP_NUM_CPUS as we work to
phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-19 16:01:10 +02:00
Jordan Yates 070422db46 arch: common: dedicated SEMIHOST symbol
Control the usage of semihosting with a dedicated symbol, instead of
implying semihosting from the usage of `SEMIHOST_CONSOLE`. This allows
semihosting to be used without the semihost console.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-21 13:04:52 +02:00
Antony Pavlov 76769a42d0 soc: mips: add Qemu Malta support
The MIPS Malta is an ATX form factor evaluation board made by MIPS
Technologies. Malta board is the most popular platform for MIPS
full-system emulation.

See https://www.linux-mips.org/wiki/MIPS_Malta for details.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Remy Luisant <remy@luisant.ca>
2022-01-19 13:48:21 -05:00
Filip Kokosinski 94428044e2 cmake: support multiple entries in board.cmake
Currently there is no way to support running a board on multiple
emulation platforms nor to choose a desired emulation platform for the
simulation to be run on. This commit introduces a new
SUPPORTED_EMU_PLATFORMS list, which defines available emulation
platforms for a given board.

Fixes #12375.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2021-11-12 21:33:42 -05:00
Immo Birnbaum f4d41b1a6c cmake: boards: make QEMU icount sleep parameter configurable
When QEMU is running in icount mode, the behaviour regarding
the CPU being in sleep mode is configurable, with the default
value being set to 'off'. In this case, instruction counting
continues even when the CPU is sleeping or no target time is
set in the system timer. If the sleep parameter is set to
'on', instruction counting stops if the CPU is sleeping, and
the instruction count will fast-forward directly to the next
target time once it is being set.

In the Xilinx derivative of QEMU (which simulates ZynqMP and
Zynq-7000 SoCs), the default configuration causes QEMU to no
longer accept control commands via the console or remotely
whenever Zephyr enters and remains in idle mode.

Therefore, this commit makes the value of the sleep para-
meter of the icount functionality configurable, with the
default value remaining 'off'. The value can be changed at
board level alongside with the specification of the icount
shift value.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
2021-10-28 15:26:50 +02:00
Chen Peng1 ce7ebb0821 tests: add a test to verify UEFI boot on x86_64 targets.
add a config CONFIG_QEMU_UEFI_BOOT to indicate whether
the qemu will use UEFI bootable method;
add a new test "sample.basic.helloworld.uefi" to verify
UEFT bootable method on qemu_x86_64 platform.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-11 11:46:13 +02:00
Daniel Noom d2a682f372 cmake: Fix unexpected token after &
In bash a '&&' cannot follow directly after a '&'. So a task that is
run in the background should be enclosed in (curly) braces.

This:
```
west build -b qemu_x86 -d build/server samples/net/sockets/echo_server\
 -- -DOVERLAY_CONFIG=overlay-qemu_802154.conf -DPCAP=capture.pcap
west build -t server -d build/server
```
works correctly after this fix.

Fixes #29793

Signed-off-by: Daniel Noom <ggatw@outlook.com>
2021-01-18 19:08:45 +01:00
Tomasz Bursztyka 892714f818 cmake: Adds the necessary flags support for Qemu ivshmem feature
Depending whether doorbell or plain versions are enabled, it will set
the right flags to qemu.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-12-16 18:47:35 -05:00
Anas Nashif 07b4df1945 cmake: put elf files for Qemu in /zephyr
The ELF files were placed in ${CMAKE_BINARY_DIR} when all other ELF
files are actually in ${CMAKE_BINARY_DIR}/zephyr, so keep things
consistent and in one place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-13 12:42:27 -04:00
Andrew Boie a9670ab5cf boards: centralize QEMU icount management
Instead of endlessly repeating the same command line args,
centralize this and tune the shift value on a per-board
basis.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-24 20:28:36 -04:00
Stephanos Ioannidis 2c00c8e504 cmake: emu: Support QEMU semihosting console emulation
The QEMU '-semihosting' option enables the emulation of the semihosting
mechanism that can be used to interface the Zephyr RTOS to the host
operating system.

In order to support semihosting console output, the QEMU semihosting
feature is enabled and its console is connected to the console backend
chardev.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-07 23:33:38 -05:00
Stephanos Ioannidis 19965f8173 cmake: qemu: Support delayed expansion of QEMU_KERNEL_OPTION
This commit allows the `QEMU_KERNEL_OPTION` variable, which can be
overridden by the `board.cmake`, to contain references to the variables
that are not available at the time of `board.cmake` inclusion, by
expanding its escpaed variable references in `cmake/emu/qemu.cmake`
which is included nearby the end of the root `CMakeLists.txt`.

With this change, the `board.cmake` can escape variable references as
follows and allow them to be expanded later:

set(QEMU_KERNEL_OPTION "-device;loader,file=\$<TARGET_FILE:$\{...}>")

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-02 09:22:38 +02:00
Stephanos Ioannidis 04e874485b x86: intel64: Split 'locore' and 'main' kernel images for QEMU
This commit splits the 'locore' and 'main' memory regions into
separate executable images and specifies the 'locore' as the boot
kernel, in order to prevent the QEMU direct multiboot kernel loader
from overwriting the BIOS and option ROM areas located in between
the two memory regions.

The Zephyr x86-64 kernel image consists of two discontiguous load
memory regions: 'locore' at 0x8000 and 'main' at 0x100000, but the
QEMU treats these as single contiguous memory region starting at
0x8000 and ending at (0x100000 + MAIN_IMAGE_SIZE - 1).

This results in the direct multiboot kernel loader overwriting the
BIOS and option ROM areas as part of the kernel loading process, and
causes any writable system regions to be corrupted (e.g. KVMVAPIC ROM).

By splitting the two discontiguous memory regions into separate images
and specifying only the boot image (i.e. 'locore') as the '-kernel',
it is possible to work around the QEMU direct kernel loading design
limitation.

This workaround is required to support the QEMU v4.2.0 and above.

For more details, refer to the issue zephyrproject-rtos/sdk-ng#168.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-01-08 07:49:24 -06:00
Stephanos Ioannidis 244148a883 cmake: qemu: Use chardev for console
The current QEMU console configuration directly connects the console
serial port to the backend using '-serial' option.

This is less than ideal because only single console instance can be
connected to a backend and aggregation of multiple console outputs is
not possible (e.g. multiple console serial ports and semihosting
console to single console backend).

In order to solve this problem, single multiplexed chardev console
backend is declared and all consoles are connected to it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-01-04 09:18:51 -05:00
Daniel Leung b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Andrew Boie beb81885c2 qemu_x86_long: don't munge to elf32 in-place
Instead, use the QEMU_KERNEL_FILE facility to perform the
change in a new file zephyr-qemu.elf. This is what will
be sent to the emulator.

Fixes an issue where opening zephyr.elf in GDB would treat
it as a 32-bit binary instead of what it actually is,
forcing the user to override the arch setting.

Fixes: #19734

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-19 12:08:00 -07:00
Andy Ross d042a3dac7 tests/kernel/mp: Update the MP test to run on emulated platforms
This was a very early test and got bitrotten inside a esp32-only
whitelist.  Make it run generically.

SMP must be forced off by the test (it's commonly a platform default).

Add a build-time failure when the configuration is single-CPU, for
clarity.

Filter the test likewise so it runs on all supported systems.

Also, the key argument to the CPU startup function is vestigial and
the test was being too strict by requiring it to be non-zero.

Finally, the qemu command line needs to predicate the "-smp" argument
on CONFIG_MP_NUM_CPUS and not just CONFIG_SMP so we have an extra CPU
to test against.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-10-06 12:53:28 -04:00
Charles E. Youse 640c5a5e95 boards/x86: add Intel64 (64-bit long-mode) QEMU target board
Add qemu_x86_long board (with CONFIG_X86_LONGMODE=y) for testing.

This requires adding support to soc/ia32 for long mode (trivial),
and adding a quick 64- to 32-bit ELF conversion before invoking
QEMU, which apparently doesn't like 64-bit kernel files.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-15 11:33:47 +08:00
Charles E. Youse 6767563f94 arch/x86: remove support for IAMCU ABI
This ABI is no longer required by any targets and is deprecated.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-07 10:07:42 -04:00
Bradley Bolen b602e38396 cmake: emu: Allow overriding the qemu binary
The xlnx-zcu102 qemu machine is the only one that supports a Cortex-R
processor.  However, its main CPUs are Cortex A53s which requires the
aarch64 qemu binary to run.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2019-08-09 22:50:50 +02:00
Jukka Rissanen 64bdad20b6 cmake: Add serial port for ppp in qemu
In order to simplify ppp testing, use ppp specific serial port
when starting qemu.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Luiz Augusto von Dentz 769cfab694 cmake: Set NO_QEMU_SERIAL_BT_SERVER when CONFIG_BT_NO_DRIVER is set
When not driver is selected there should be no need to have a serial
attached.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-24 22:36:59 +02:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andy Ross 154c20ce7a cmake/emu: Add qemu SMP flags automatically
No need to do this in arch code, all qemu variants speak the same
command line and the kconfig values we need are easily available.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross b69d0da82d arch/x86_64: New architecture added
This patch adds a x86_64 architecture and qemu_x86_64 board to Zephyr.
Only the basic architecture support needed to run 64 bit code is
added; no drivers are added, though a low-level console exists and is
wired to printk().

The support is built on top of a "X86 underkernel" layer, which can be
built in isolation as a unit test on a Linux host.

Limitations:

+ Right now the SDK lacks an x86_64 toolchain.  The build will fall
  back to a host toolchain if it finds no cross compiler defined,
  which is tested to work on gcc 8.2.1 right now.

+ No x87/SSE/AVX usage is allowed.  This is a stronger limitation than
  other architectures where the instructions work from one thread even
  if the context switch code doesn't support it.  We are passing
  -no-sse to prevent gcc from automatically generating SSE
  instructions for non-floating-point purposes, which has the side
  effect of changing the ABI.  Future work to handle the FPU registers
  will need to be combined with an "application" ABI distinct from the
  kernel one (or just to require USERSPACE).

+ Paging is enabled (it has to be in long mode), but is a 1:1 mapping
  of all memory.  No MMU/USERSPACE support yet.

+ We are building with -mno-red-zone for stack size reasons, but this
  is a valuable optimization.  Enabling it requires automatic stack
  switching, which requires a TSS, which means it has to happen after
  MMU support.

+ The OS runs in 64 bit mode, but for compatibility reasons is
  compiled to the 32 bit "X32" ABI.  So while the full 64 bit
  registers and instruction set are available, C pointers are 32 bits
  long and Zephyr is constrained to run in the bottom 4G of memory.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Tomasz Bursztyka 05368dc16c cmake: Enable server/client rules in case of 802.15.4 UPIPE driver
Networking apps may require these rules (as echo apps) even on
non-Ethernet based configuration.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-08 11:25:33 +02:00
Jukka Rissanen 421505c7e3 net: qemu: Allow SLIP or normal ethernet connectivity
Introduce new Kconfig option for selecting either slip or ethernet
connectivity to host.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-10 09:13:45 -05:00
Anas Nashif 1d4e089498 qemu: support alternate path of qemu binaries
Support using an alternate QEMU path for when we want to use a qemu
version not available in the SDK.

To use the alternate qemu version, export QEMU_BIN_PATH and point it
to the bin directory which contains the qemu executables.

For example:

export QEMU_BIN_PATH=/usr/local/bin

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-22 15:44:53 -07:00
Pedro Martucci a495b31ee0 sample: net: RPL mesh sample over QEMU
Create a net sample to setup a multi-node RPL mesh network using QMEU.
To enable this, it was necessary implement a hw filter on IEEE 802.15.4
UART Pipe driver and create a QEMU pipe management on cmake.

This sample use a tool developed on zephyr net-tools repository called
virtual-hub.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-02-20 14:47:14 +02:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Sebastian Bøe d5fe808a09 cmake: net: qemu: Don't pass "-serial none" to qemu
I don't know why we have been passing "-serial none" to qemu but it
does not seem to be doing anything useful. So I propose we remove it.

According to the qemu documenation it should be disabling all serial
ports;

"-serial dev
Redirect the virtual serial port to host character device dev. The
default device is vc in graphical mode and stdio in non graphical
mode.

This option can be used several times to simulate up to 4 serial
ports.

Use -serial none to disable all serial ports."

But when we use "-serial none", we always combine it with "-serial
pipe", or "-serial unix", to redirect the serial port, so clearly it
is not disabling all serial ports as it attempting to do.

"-serial none" was first introduced to Zephyr in this commit:
0b54f984b8

As far I can tell, pinging an echo_server works fine without it, so I
suspect that our second -serial flag is overriding it and that it has
no effect.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 09:41:54 -05:00
Sebastian Bøe dfe5cb731c cmake: qemu: Don't use the '\$' hack with Ninja
Using the '\$' technique to accept make variables corrupts Ninja build
systems, so avoid using it when generating Ninja files. Not using it
with Ninja means we need to come up with some other mechanism to
support build-time configuration of the QEMU CLI with Ninja.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-30 11:29:24 -05:00
Anas Nashif fd276aeb42 cmake: cleanup qemu runner configuration
All runner logic was implemented in qemu.cmake, remove the generic stuff
and make qemu.cmake qemu specific.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif c15d3c9126 cmake: support other emulation platforms/runners
Right now we are hardcoded to only qemu, with the native port, we make
this more generic and support this in a plugin mode where a running has
its own cmake definitons implementing the various targets.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2017-12-27 14:16:08 -05:00
Renamed from cmake/qemu/CMakeLists.txt (Browse further)