All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Support booting modern EDK2 on raspi3b board
@ 2026-08-19 12:26 opensource
  2026-08-19 12:26 ` [PATCH 1/4] hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response opensource
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: opensource @ 2026-08-19 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé,
	Frederik van Hövell

From: Frederik van Hövell <frederik@fvhovell.nl>

This series fixes raspi3b board behaviour when using EDK2 firmware:
- fix framebuffer base response: firmware (and linux kernel) expects
  returned address as seen from VC4 GPU memory view.
- fix firmware revision response: EDK2 firmware expects a valid epoch
  timestamp after year 2000, where previous used value was far too old.

NB: Due to incomplete emulation it does not yet work for raspi4b
(missing RNG200 and GENETv5, amongst other issues).

As convenience it fixes starting raspi3ap, raspi3b and raspi4b boards
with firmware using '-bios RPI_EFI.fd' (as was already possible using
'-loader file=RPI_EFI.fd,force-raw=true').

Finally it adds an functional test for running EDK2 firmware using new
parameter -bios on raspi3b and bumps RPi3 EDK2 release to latest v1.52.

Frederik van Hövell (4):
  hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response
  hw/misc/bcm2835_property: fix RPI_FWREQ_GET_FIRMWARE_REVISION response
  hw/arm/raspi: implement booting firmware at 0x0 using -bios on boards
    3ap, 3b and 4b
  tests/functional/aarch64/test_raspi3: update firmware to v1.52

 docs/system/arm/raspi.rst               | 12 ++++++++++++
 hw/arm/raspi.c                          | 17 +++++++++++------
 hw/misc/bcm2835_property.c              |  6 ++++--
 include/hw/display/bcm2835_fb.h         |  3 ++-
 tests/functional/aarch64/test_raspi3.py | 18 +++++++++++++++---
 5 files changed, 44 insertions(+), 12 deletions(-)

-- 
2.55.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response
  2026-08-19 12:26 [PATCH 0/4] Support booting modern EDK2 on raspi3b board opensource
@ 2026-08-19 12:26 ` opensource
  2026-08-19 12:27 ` [PATCH 2/4] hw/misc/bcm2835_property: fix RPI_FWREQ_GET_FIRMWARE_REVISION response opensource
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: opensource @ 2026-08-19 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé,
	Frederik van Hövell

From: Frederik van Hövell <frederik@fvhovell.nl>

The value is used as framebuffer base address, but seen from the VideoCore[4-6] processor view of memory.
This GPU view uses an offset of 0xc0000000 (i.e. bits 30 and 31 always set to 1), compared to the CPU memory view.
Above interpretation can be found in below kernels:
  - UEFI firmware [edk2-platforms](https://github.com/tianocore/edk2-platforms/blob/306137738faf9f31eba9823d0f818397755cedaf/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c#L1045)
  - [Upstream linux](https://github.com/torvalds/linux/blob/0031c06807cfa8aa51a759ff8aa09e1aa48149af/drivers/gpu/drm/vc4/vc4_drv.c#L312)
  - [RaspberryPi linux](https://github.com/raspberrypi/linux/blob/3e44c7fdf879208adf51be589d60962269d25d18/drivers/video/fbdev/bcm2708_fb.c#L464C1-L466C29)

Signed-off-by: Frederik van Hövell <frederik@fvhovell.nl>
---
 hw/misc/bcm2835_property.c      | 3 ++-
 include/hw/display/bcm2835_fb.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index 216a746c2bd..a90c7e6c863 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -168,7 +168,8 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
         /* Frame buffer */
 
         case RPI_FWREQ_FRAMEBUFFER_ALLOCATE:
-            stl_le_phys(&s->dma_as, value + 12, fbconfig.base);
+            stl_le_phys(&s->dma_as, value + 12,
+                        fbconfig.base | BCM2836_DMA_DEVICE_OFFSET);
             stl_le_phys(&s->dma_as, value + 16,
                         bcm2835_fb_get_size(&fbconfig));
             resplen = 8;
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
index f7ef076f1f4..bcc87ad5390 100644
--- a/include/hw/display/bcm2835_fb.h
+++ b/include/hw/display/bcm2835_fb.h
@@ -15,7 +15,8 @@
 #include "hw/core/sysbus.h"
 #include "qom/object.h"
 
-#define UPPER_RAM_BASE 0x40000000
+#define UPPER_RAM_BASE            0x40000000
+#define BCM2836_DMA_DEVICE_OFFSET 0xc0000000
 
 #define TYPE_BCM2835_FB "bcm2835-fb"
 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB)
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] hw/misc/bcm2835_property: fix RPI_FWREQ_GET_FIRMWARE_REVISION response
  2026-08-19 12:26 [PATCH 0/4] Support booting modern EDK2 on raspi3b board opensource
  2026-08-19 12:26 ` [PATCH 1/4] hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response opensource
@ 2026-08-19 12:27 ` opensource
  2026-08-19 12:27 ` [PATCH 3/4] hw/arm/raspi: implement booting firmware at 0x0 using -bios on boards 3ap, 3b and 4b opensource
  2026-08-19 12:27 ` [PATCH 4/4] tests/functional/aarch64/test_raspi3: update firmware to v1.52 opensource
  3 siblings, 0 replies; 5+ messages in thread
From: opensource @ 2026-08-19 12:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé,
	Frederik van Hövell

From: Frederik van Hövell <frederik@fvhovell.nl>

The returned value for revision is interpreted as an unix epoch timestamp after year 2000 by EDK2 for RPi3/4 boards.
EDK2 firmware uses the revision to show as human-readable 'year.month', and asserted to have year between 2000 and 2255 (both inclusive).

See [PlatformSmbiosDxe.c](https://github.com/tianocore/edk2-platforms/blob/master/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c#L763).

Signed-off-by: Frederik van Hövell <frederik@fvhovell.nl>
---
 hw/misc/bcm2835_property.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index a90c7e6c863..a705e44b1fe 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -52,7 +52,8 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
         case RPI_FWREQ_PROPERTY_END:
             break;
         case RPI_FWREQ_GET_FIRMWARE_REVISION:
-            stl_le_phys(&s->dma_as, value + 12, 346337);
+            // Use timestamp of first released Raspberry Pi as minimum 'revision': 2012-02-29T00:00:00.000Z
+            stl_le_phys(&s->dma_as, value + 12, 1330473600);
             resplen = 4;
             break;
         case RPI_FWREQ_GET_BOARD_MODEL:
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] hw/arm/raspi: implement booting firmware at 0x0 using -bios on boards 3ap, 3b and 4b
  2026-08-19 12:26 [PATCH 0/4] Support booting modern EDK2 on raspi3b board opensource
  2026-08-19 12:26 ` [PATCH 1/4] hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response opensource
  2026-08-19 12:27 ` [PATCH 2/4] hw/misc/bcm2835_property: fix RPI_FWREQ_GET_FIRMWARE_REVISION response opensource
@ 2026-08-19 12:27 ` opensource
  2026-08-19 12:27 ` [PATCH 4/4] tests/functional/aarch64/test_raspi3: update firmware to v1.52 opensource
  3 siblings, 0 replies; 5+ messages in thread
From: opensource @ 2026-08-19 12:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé,
	Frederik van Hövell

From: Frederik van Hövell <frederik@fvhovell.nl>

Signed-off-by: Frederik van Hövell <frederik@fvhovell.nl>
---
 docs/system/arm/raspi.rst               | 12 ++++++++++++
 hw/arm/raspi.c                          | 17 +++++++++++------
 tests/functional/aarch64/test_raspi3.py | 12 ++++++++++++
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/docs/system/arm/raspi.rst b/docs/system/arm/raspi.rst
index 44eec3f1c33..fb912da129b 100644
--- a/docs/system/arm/raspi.rst
+++ b/docs/system/arm/raspi.rst
@@ -43,3 +43,15 @@ Missing devices
  * Pulse Width Modulation (PWM)
  * PCIE Root Port (raspi4b)
  * GENET Ethernet Controller (raspi4b)
+
+Boot options
+------------
+
+The Raspberry Pi models support booting via either a Linux kernel (``-kernel``)
+or UEFI/EDK2 firmware images (``-bios rpi_efi.fd``).
+
+When booting Raspberry Pi 3 (``raspi3b``, ``raspi3ap``) and Raspberry Pi 4 (``raspi4b``)
+boards with EDK2 firmware via ``-bios``, the firmware image is loaded at physical
+memory address ``0x0``, matching the platform expectations. Older 32-bit models
+(``raspi0``, ``raspi1ap``, ``raspi2b``) load firmware at their respective legacy addresses
+(``0x8000``).
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 3f99e87428c..c0b177f8cb1 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -33,8 +33,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
 #define SMPBOOT_ADDR    0x300 /* this should leave enough space for ATAGS */
 #define MVBAR_ADDR      0x400 /* secure vectors */
 #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
-#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
-#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
+#define KERNEL_ADDR_PI2 0x8000 /* Pi 2 loads kernel.img here by default */
 #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
 
 struct RaspiMachineState {
@@ -193,7 +192,7 @@ static void setup_boot(MachineState *machine, ARMCPU *cpu,
                        RaspiProcessorId processor_id, size_t ram_size)
 {
     RaspiBaseMachineState *s = RASPI_BASE_MACHINE(machine);
-    int r;
+    ssize_t r;
 
     s->binfo.ram_size = ram_size;
 
@@ -226,9 +225,15 @@ static void setup_boot(MachineState *machine, ARMCPU *cpu,
      * the normal Linux boot process
      */
     if (machine->firmware) {
-        hwaddr firmware_addr = processor_id <= PROCESSOR_ID_BCM2836
-                             ? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3;
-        /* load the firmware image (typically kernel.img) */
+        hwaddr firmware_addr;
+        if (processor_id <= PROCESSOR_ID_BCM2836) {
+            // For RPi 0/1/2 (arm, 32 bit mode) support kernel.img loading at default address
+            firmware_addr = KERNEL_ADDR_PI2;
+        } else {
+            // For RPi 3 or newer boards (aarch64), support edk2 firmware
+            firmware_addr = 0x0;
+        }
+        /* Load the firmware image (typically kernel.img or edk2 firmware) */
         r = load_image_targphys(machine->firmware, firmware_addr,
                                 ram_size - firmware_addr, NULL);
         if (r < 0) {
diff --git a/tests/functional/aarch64/test_raspi3.py b/tests/functional/aarch64/test_raspi3.py
index ae9eed3589f..709c7221fa4 100755
--- a/tests/functional/aarch64/test_raspi3.py
+++ b/tests/functional/aarch64/test_raspi3.py
@@ -29,6 +29,18 @@ def test_aarch64_raspi3_atf(self):
         self.vm.launch()
         self.wait_for_console_pattern('version UEFI Firmware v1.15')
 
+    def test_aarch64_raspi3_bios(self):
+        efi_name = 'RPI_EFI.fd'
+        efi_fd = self.archive_extract(self.ASSET_RPI3_UEFI, member=efi_name)
+
+        self.set_machine('raspi3b')
+        self.vm.set_console(console_index=1)
+        self.vm.add_args('-cpu', 'cortex-a53',
+                         '-nodefaults',
+                         '-bios', efi_fd)
+        self.vm.launch()
+        self.wait_for_console_pattern('version UEFI Firmware v1.15')
+
 
 if __name__ == '__main__':
     LinuxKernelTest.main()
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] tests/functional/aarch64/test_raspi3: update firmware to v1.52
  2026-08-19 12:26 [PATCH 0/4] Support booting modern EDK2 on raspi3b board opensource
                   ` (2 preceding siblings ...)
  2026-08-19 12:27 ` [PATCH 3/4] hw/arm/raspi: implement booting firmware at 0x0 using -bios on boards 3ap, 3b and 4b opensource
@ 2026-08-19 12:27 ` opensource
  3 siblings, 0 replies; 5+ messages in thread
From: opensource @ 2026-08-19 12:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé,
	Frederik van Hövell

From: Frederik van Hövell <frederik@fvhovell.nl>

Signed-off-by: Frederik van Hövell <frederik@fvhovell.nl>
---
 tests/functional/aarch64/test_raspi3.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/functional/aarch64/test_raspi3.py b/tests/functional/aarch64/test_raspi3.py
index 709c7221fa4..ffc6f2517fd 100755
--- a/tests/functional/aarch64/test_raspi3.py
+++ b/tests/functional/aarch64/test_raspi3.py
@@ -14,8 +14,8 @@ class Aarch64Raspi3Machine(LinuxKernelTest):
 
     ASSET_RPI3_UEFI = Asset(
         ('https://github.com/pbatard/RPi3/releases/download/'
-         'v1.15/RPi3_UEFI_Firmware_v1.15.zip'),
-        '8cff2e979560048b4c84921f41a91893240b9fb71a88f0b5c5d6c8edd994bd5b')
+         'v1.52/RPi3_UEFI_Firmware_v1.52.zip'),
+        '20b894d15cdb42e055872a7ee6a850aa9373aedcfefd27f19767d975ce4f7371')
 
     def test_aarch64_raspi3_atf(self):
         efi_name = 'RPI_EFI.fd'
@@ -27,7 +27,7 @@ def test_aarch64_raspi3_atf(self):
                          '-nodefaults',
                          '-device', f'loader,file={efi_fd},force-raw=true')
         self.vm.launch()
-        self.wait_for_console_pattern('version UEFI Firmware v1.15')
+        self.wait_for_console_pattern('version UEFI Firmware v1.52')
 
     def test_aarch64_raspi3_bios(self):
         efi_name = 'RPI_EFI.fd'
@@ -39,7 +39,7 @@ def test_aarch64_raspi3_bios(self):
                          '-nodefaults',
                          '-bios', efi_fd)
         self.vm.launch()
-        self.wait_for_console_pattern('version UEFI Firmware v1.15')
+        self.wait_for_console_pattern('version UEFI Firmware v1.52')
 
 
 if __name__ == '__main__':
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-19 12:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 12:26 [PATCH 0/4] Support booting modern EDK2 on raspi3b board opensource
2026-08-19 12:26 ` [PATCH 1/4] hw/misc/bcm2835_property: fix RPI_FWREQ_FRAMEBUFFER_ALLOCATE response opensource
2026-08-19 12:27 ` [PATCH 2/4] hw/misc/bcm2835_property: fix RPI_FWREQ_GET_FIRMWARE_REVISION response opensource
2026-08-19 12:27 ` [PATCH 3/4] hw/arm/raspi: implement booting firmware at 0x0 using -bios on boards 3ap, 3b and 4b opensource
2026-08-19 12:27 ` [PATCH 4/4] tests/functional/aarch64/test_raspi3: update firmware to v1.52 opensource

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.