From 1b2498fa91b752f4cc3578600bc653ece734c001 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Fri, 22 Dec 2023 11:56:55 +0100 Subject: [PATCH] boot/edk2: add support for RISC-V 64bit architecture RISC-V 64bit qemu virt machine support has been added in edk2 version "stable202302". See [1]. Since edk2-stable202308, introduced in buildroot in commit 5c9f310 "boot/edk2: bump to version edk2-stable202308", it is now possible to boot the edk2 UEFI shell in qemu. This commit adds this early RISC-V support to edk2. The RISC-V edk2 UEFI shell can be booted in Buildroot with the following commands: # Build EDK2 images cat > .config <= 8.0.0 is needed to properly start edk2. A qemu version on the host system might not be sufficient. This is why the Buildroot host-qemu is built in this config example. [1] https://github.com/tianocore/edk2/releases/tag/edk2-stable202302 Signed-off-by: Julien Olivain Signed-off-by: Thomas Petazzoni --- boot/edk2/Config.in | 10 ++++++++++ boot/edk2/edk2.mk | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in index bed503b168..4e6e7d122c 100644 --- a/boot/edk2/Config.in +++ b/boot/edk2/Config.in @@ -2,6 +2,7 @@ config BR2_TARGET_EDK2_ARCH_SUPPORTS bool default y if BR2_aarch64 default y if BR2_i386 + default y if BR2_RISCV_64 default y if BR2_x86_64 config BR2_TARGET_EDK2 @@ -20,6 +21,7 @@ if BR2_TARGET_EDK2 choice prompt "Platform" default BR2_TARGET_EDK2_PLATFORM_OVMF_I386 if BR2_i386 + default BR2_TARGET_EDK2_PLATFORM_OVMF_RISCV if BR2_RISCV_64 default BR2_TARGET_EDK2_PLATFORM_OVMF_X64 if BR2_x86_64 default BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU if BR2_aarch64 @@ -31,6 +33,14 @@ config BR2_TARGET_EDK2_PLATFORM_OVMF_I386 This platform will boot from flash address 0x0. It should therefore be used as the first bootloader. +config BR2_TARGET_EDK2_PLATFORM_OVMF_RISCV + bool "RISC-V" + depends on BR2_RISCV_64 + help + Platform configuration for RISC-V QEMU targeting the Virt + machine. This platform will only boot from flash address + 0x0. It should therefore be used as the first bootloader. + config BR2_TARGET_EDK2_PLATFORM_OVMF_X64 bool "x86-64" depends on BR2_x86_64 diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk index 186854a14c..efdb4d02ce 100644 --- a/boot/edk2/edk2.mk +++ b/boot/edk2/edk2.mk @@ -136,6 +136,12 @@ define EDK2_PRE_BUILD_QEMU_SBSA ln -srf $(BINARIES_DIR)/{bl1.bin,fip.bin} $(EDK2_BUILD_PACKAGES)/Platform/Qemu/Sbsa/ endef +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_RISCV),y) +EDK2_ARCH = RISCV64 +EDK2_PACKAGE_NAME = OvmfPkg/RiscVVirt +EDK2_PLATFORM_NAME = RiscVVirtQemu +EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME) + endif EDK2_BASETOOLS_OPTS = \