qemu/Makefile: Allow usage of a custom QEMU binary to run code.

This commit introduces a new optional makefile variable to let the build
system know that, when running code, a custom QEMU binary must be used
instead of the one provided by the system's PATH.

Given that the CI machine won't keep up with QEMU updates unless its
base image tracks a new version of QEMU itself, sometimes it is needed
to use a custom QEMU build to be able to test new code in an emulated
context rather than having to perform on-device testing during
development.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-11-10 21:12:37 +01:00
committed by Damien George
parent cb9d8fcc31
commit d938d5af4e
2 changed files with 6 additions and 1 deletions

View File

@@ -153,7 +153,8 @@ endif
################################################################################
# Project specific settings and compiler/linker flags
QEMU_SYSTEM = qemu-system-$(QEMU_ARCH)
QEMU_BASE ?= qemu-system-
QEMU_SYSTEM = $(QEMU_BASE)$(QEMU_ARCH)
QEMU_ARGS += -machine $(QEMU_MACHINE) -nographic -monitor null -semihosting
QEMU_ARGS += $(QEMU_EXTRA)

View File

@@ -157,6 +157,10 @@ The following options can be specified on the `make` command line:
- `CFLAGS_EXTRA`: pass in extra flags for the compiler.
- `RUN_TESTS_EXTRA`: pass in extra flags for `run-tests.py` and `run-natmodtests.py`
when invoked via `make test` or `make test_natmod`.
- `QEMU_BASE`: pass an optional partial path of the qemu binary to run code with, eg.
`/opt/custom-directory/qemu/bin/qemu-system-`, similar to how a cross compiler name
is passed to the MicroPython makefile. By default it will use the appropriate QEMU
binary found through the system's PATH environment variable.
- `QEMU_DEBUG=1`: when running qemu (via `repl`, `run` or `test` target), qemu
will block until a debugger is connected. By default it waits for a gdb connection
on TCP port 1234.