From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: David Dgien <dgienda125@gmail.com>, Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 03/13] ARM: qemu-virt: add image for use as -bios
Date: Fri, 16 Jan 2026 17:06:26 +0100 [thread overview]
Message-ID: <20260116160654.3981425-4-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260116160654.3981425-1-a.fatoum@barebox.org>
We previously used barebox-dt-2nd.img as image for Qemu Virt.
Adding a dedicated image however allows us to use -kernel to specify,
well, a kernel, which can make some testing scenarios more straight
forward, once we implement support for barebox to lookup -kernel and
-append QEMU options.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/boards/Makefile | 1 +
arch/arm/boards/qemu-virt/Makefile | 2 +-
arch/arm/boards/qemu-virt/lowlevel.c | 80 +++++++++++++++++++++++++
images/Makefile.vexpress | 5 ++
test/arm/dt-2nd@multi_v7_defconfig.yaml | 22 +++++++
test/arm/dt-2nd@multi_v8_defconfig.yaml | 23 +++++++
test/arm/virt@multi_v7_defconfig.yaml | 4 +-
test/arm/virt@multi_v8_defconfig.yaml | 4 +-
8 files changed, 136 insertions(+), 5 deletions(-)
create mode 100644 arch/arm/boards/qemu-virt/lowlevel.c
create mode 100644 test/arm/dt-2nd@multi_v7_defconfig.yaml
create mode 100644 test/arm/dt-2nd@multi_v8_defconfig.yaml
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 4c586de2a985..dd2f2c324e25 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -189,6 +189,7 @@ obj-$(CONFIG_MACH_RK3568_EVB) += rockchip-rk3568-evb/
obj-$(CONFIG_MACH_RK3568_BPI_R2PRO) += rockchip-rk3568-bpi-r2pro/
obj-$(CONFIG_MACH_PINE64_PINETAB2) += pine64-pinetab2/
obj-$(CONFIG_MACH_PINE64_QUARTZ64) += pine64-quartz64/
+obj-$(CONFIG_BOARD_ARM_VIRT) += qemu-virt/
obj-$(CONFIG_MACH_RADXA_ROCK3) += radxa-rock3/
obj-$(CONFIG_MACH_RADXA_ROCK5) += radxa-rock5/
obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += variscite-dt8mcustomboard-imx8mp/
diff --git a/arch/arm/boards/qemu-virt/Makefile b/arch/arm/boards/qemu-virt/Makefile
index ad283446eaf1..458f5209008d 100644
--- a/arch/arm/boards/qemu-virt/Makefile
+++ b/arch/arm/boards/qemu-virt/Makefile
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/qemu-virt/lowlevel.c b/arch/arm/boards/qemu-virt/lowlevel.c
new file mode 100644
index 000000000000..d6c48e367d08
--- /dev/null
+++ b/arch/arm/boards/qemu-virt/lowlevel.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/sizes.h>
+#include <asm/barebox-arm.h>
+#include <asm/reloc.h>
+#include <compressed-dtb.h>
+#include <debug_ll.h>
+#include <console.h>
+#include <stdio.h>
+#include <debug_ll/pl011.h>
+#include <pbl.h>
+
+#define RAM_BASE 0x40000000
+#define PL011_BASE IOMEM(0x9000000)
+
+extern char __dtb_qemu_virt32_start[];
+extern char __dtb_qemu_virt64_start[];
+
+static void *find_fdt(void *r0)
+{
+ void *fdt, *ram = (void *)RAM_BASE;
+ const char *origin;
+
+ if (blob_is_fdt(ram)) {
+ origin = "-bios";
+ fdt = ram;
+ } else if (r0 >= ram && blob_is_fdt(r0)) {
+ origin = "-kernel";
+ fdt = r0;
+ } else if (IS_ENABLED(CONFIG_ARM32)) {
+ origin = "built-in";
+ fdt = __dtb_qemu_virt32_start;
+ } else {
+ origin = "built-in";
+ fdt = __dtb_qemu_virt64_start;
+ }
+
+ pr_info("Using %s device tree at %p\n", origin, fdt);
+ return fdt;
+}
+
+/*
+ * Entry point for QEMU virt firmware boot (-bios option).
+ *
+ * Memory layout:
+ * 0x00000000 - 0x08000000: Flash/ROM
+ * 0x08000000 - 0x40000000: Peripherals
+ * 0x40000000 - ...........: RAM
+ */
+static noinline void continue_qemu_virt_bios(ulong r0)
+{
+ ulong membase = RAM_BASE, memsize = SZ_32M - SZ_4M;
+ void *fdt;
+
+ pbl_set_putc(debug_ll_pl011_putc, PL011_BASE);
+
+ /* QEMU may put a DTB at the start of RAM */
+ fdt = find_fdt((void *)r0);
+
+ fdt_find_mem(fdt, &membase, &memsize);
+
+ barebox_arm_entry(membase, memsize, fdt);
+}
+
+ENTRY_FUNCTION_WITHSTACK(start_qemu_virt_bios, RAM_BASE + SZ_32M, r0, r1, r2)
+{
+
+ arm_cpu_lowlevel_init();
+
+ putc_ll('>');
+
+ if (get_pc() >= RAM_BASE)
+ relocate_to_current_adr();
+ else
+ relocate_to_adr_full(RAM_BASE + SZ_4M);
+
+ setup_c();
+
+ continue_qemu_virt_bios(r0);
+}
diff --git a/images/Makefile.vexpress b/images/Makefile.vexpress
index 11c49cca0cbd..81ab8caa4c24 100644
--- a/images/Makefile.vexpress
+++ b/images/Makefile.vexpress
@@ -10,3 +10,8 @@ image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca9.img
pblb-$(CONFIG_MACH_VEXPRESS) += start_vexpress_ca15
FILE_barebox-vexpress-ca15.img = start_vexpress_ca15.pblb
image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca15.img
+
+# Firmware image for -bios option
+pblb-$(CONFIG_BOARD_ARM_VIRT) += start_qemu_virt_bios
+FILE_barebox-qemu-virt.img = start_qemu_virt_bios.pblb
+image-$(CONFIG_BOARD_ARM_VIRT) += barebox-qemu-virt.img
diff --git a/test/arm/dt-2nd@multi_v7_defconfig.yaml b/test/arm/dt-2nd@multi_v7_defconfig.yaml
new file mode 100644
index 000000000000..891581205898
--- /dev/null
+++ b/test/arm/dt-2nd@multi_v7_defconfig.yaml
@@ -0,0 +1,22 @@
+targets:
+ main:
+ drivers:
+ QEMUDriver:
+ qemu_bin: qemu-system-arm
+ machine: virt
+ cpu: cortex-a7
+ memory: 1024M
+ kernel: barebox-dt-2nd.img
+ display: qemu-default
+ BareboxDriver:
+ prompt: 'barebox@[^:]+:[^ ]+ '
+ bootstring: 'commandline:'
+ BareboxTestStrategy: {}
+ features:
+ - virtio-mmio
+ - barebox-state
+ - testfs
+images:
+ barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+imports:
+ - ../strategy.py
diff --git a/test/arm/dt-2nd@multi_v8_defconfig.yaml b/test/arm/dt-2nd@multi_v8_defconfig.yaml
new file mode 100644
index 000000000000..8aa514fb4179
--- /dev/null
+++ b/test/arm/dt-2nd@multi_v8_defconfig.yaml
@@ -0,0 +1,23 @@
+targets:
+ main:
+ drivers:
+ QEMUDriver:
+ qemu_bin: qemu-system-aarch64
+ machine: virt,highmem=off
+ cpu: cortex-a57
+ memory: 1024M
+ kernel: barebox-dt-2nd.img
+ display: qemu-default
+ BareboxDriver:
+ prompt: 'barebox@[^:]+:[^ ]+ '
+ bootstring: 'commandline:'
+ BareboxTestStrategy: {}
+ features:
+ - virtio-mmio
+ - network
+ - barebox-state
+ - testfs
+images:
+ barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+imports:
+ - ../strategy.py
diff --git a/test/arm/virt@multi_v7_defconfig.yaml b/test/arm/virt@multi_v7_defconfig.yaml
index 891581205898..eef08a5b345b 100644
--- a/test/arm/virt@multi_v7_defconfig.yaml
+++ b/test/arm/virt@multi_v7_defconfig.yaml
@@ -6,7 +6,7 @@ targets:
machine: virt
cpu: cortex-a7
memory: 1024M
- kernel: barebox-dt-2nd.img
+ bios: barebox-qemu-virt.img
display: qemu-default
BareboxDriver:
prompt: 'barebox@[^:]+:[^ ]+ '
@@ -17,6 +17,6 @@ targets:
- barebox-state
- testfs
images:
- barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+ barebox-qemu-virt.img: !template "$LG_BUILDDIR/images/barebox-qemu-virt.img"
imports:
- ../strategy.py
diff --git a/test/arm/virt@multi_v8_defconfig.yaml b/test/arm/virt@multi_v8_defconfig.yaml
index 8aa514fb4179..2e654359709e 100644
--- a/test/arm/virt@multi_v8_defconfig.yaml
+++ b/test/arm/virt@multi_v8_defconfig.yaml
@@ -6,7 +6,7 @@ targets:
machine: virt,highmem=off
cpu: cortex-a57
memory: 1024M
- kernel: barebox-dt-2nd.img
+ bios: barebox-qemu-virt.img
display: qemu-default
BareboxDriver:
prompt: 'barebox@[^:]+:[^ ]+ '
@@ -18,6 +18,6 @@ targets:
- barebox-state
- testfs
images:
- barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+ barebox-qemu-virt.img: !template "$LG_BUILDDIR/images/barebox-qemu-virt.img"
imports:
- ../strategy.py
--
2.47.3
next prev parent reply other threads:[~2026-01-16 16:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 01/13] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 02/13] boards: qemu-virt: reserve BIOS device tree Ahmad Fatoum
2026-01-16 16:06 ` Ahmad Fatoum [this message]
2026-01-16 16:06 ` [PATCH 04/13] kbuild: build *.mod.c with -std=gnu11 Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 06/13] treewide: fix some missing EXPORT_SYMBOL Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 07/13] pci: ecam: enable build as module Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 08/13] kbuild: add support for installing and stripping modules Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 09/13] ARM32: module: handle more relocations Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 10/13] commands: pm_domain: make command tristate Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 11/13] test: conftest: add support for describing FW_CFG environment in YAML Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 12/13] defaultenv: add barebox_modules_env target Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 13/13] test: arm: add simple driver/command module test Ahmad Fatoum
2026-01-19 7:28 ` [PATCH 00/13] ARM32: modules: fix bitrot and add test Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260116160654.3981425-4-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=dgienda125@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox