From d938d5af4e1d4a860c80d3ecfbe0288c60858cb9 Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Mon, 10 Nov 2025 21:12:37 +0100 Subject: [PATCH] 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 --- ports/qemu/Makefile | 3 ++- ports/qemu/README.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ports/qemu/Makefile b/ports/qemu/Makefile index ba9c53841a..c8ce3de872 100644 --- a/ports/qemu/Makefile +++ b/ports/qemu/Makefile @@ -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) diff --git a/ports/qemu/README.md b/ports/qemu/README.md index bf5788961d..a7134d0eb8 100644 --- a/ports/qemu/README.md +++ b/ports/qemu/README.md @@ -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.