@@ -1713,11 +1713,13 @@ F: configs/ts7680_defconfig
F: package/paho-mqtt-c
N: Julien Olivain <ju.o@free.fr>
+F: board/qemu/riscv64-virt-efi/
F: board/spike/
F: board/technexion/imx8mmpico/
F: board/technexion/imx8mpico/
F: configs/imx8mmpico_defconfig
F: configs/imx8mpico_defconfig
+F: configs/qemu_riscv64_virt_efi_defconfig
F: configs/spike_riscv64_defconfig
F: package/fluid-soundfont/
F: package/fluidsynth/
new file mode 100755
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+set -e
+
+BOARD_DIR="$(dirname "$0")"
+
+cp -f "${BOARD_DIR}"/grub.cfg "${BINARIES_DIR}"/efi-part/EFI/BOOT/grub.cfg
+
+# The QEMU riscv64 virt machine expects flash devices to be 32M.
+truncate -s 32M "${BINARIES_DIR}"/RISCV_VIRT_CODE.fd
+truncate -s 32M "${BINARIES_DIR}"/RISCV_VIRT_VARS.fd
new file mode 100644
@@ -0,0 +1,34 @@
+image efi-part.vfat {
+ vfat {
+ file EFI {
+ image = "efi-part/EFI"
+ }
+
+ file Image {
+ image = "Image"
+ }
+ }
+
+ size = 64M
+}
+
+image disk.img {
+ hdimage {
+ partition-table-type = "gpt"
+ }
+
+ partition boot {
+ image = "efi-part.vfat"
+ partition-type-uuid = U
+ offset = 32K
+ bootable = true
+ }
+
+ partition root {
+ # For partition-type-uuid value, see:
+ # https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
+ # SD_GPT_ROOT_RISCV64
+ partition-type-uuid = 72ec70a6-cf74-40e6-bd49-4bda08e8f224
+ image = "rootfs.ext2"
+ }
+}
new file mode 100644
@@ -0,0 +1,6 @@
+set default="0"
+set timeout="5"
+
+menuentry "Buildroot" {
+ linux /Image root=PARTLABEL=root rootwait
+}
new file mode 100644
@@ -0,0 +1,36 @@
+Intro
+=====
+
+This is a RISC-V 64bit UEFI Linux boot demo in QEmu virt machine.
+
+Build
+=====
+
+ make qemu_riscv64_virt_efi_defconfig
+ make
+
+Emulation
+=========
+
+Run the emulation with:
+
+ qemu-system-riscv64 \
+ -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
+ -smp 4 \
+ -m 1024 \
+ -nographic \
+ -blockdev node-name=pflash0,driver=file,read-only=on,filename=output/images/RISCV_VIRT_CODE.fd \
+ -blockdev node-name=pflash1,driver=file,filename=output/images/RISCV_VIRT_VARS.fd \
+ \
+ -drive file=output/images/disk.img,format=raw,id=hd0 \
+ -device virtio-blk-device,drive=hd0 \
+ \
+ -netdev user,id=net0 \
+ -device virtio-net-device,netdev=net0 # qemu_riscv64_virt_efi_defconfig
+
+Note: for information, qemu version >= 8.0.0 is needed for this UEFI
+Linux demo. It introduced the two pflash memories (previous versions
+had only one). The host-qemu package in Buildroot (enabled in this
+defconfig) is sufficient to run this demo. In case another qemu is
+used (for example, from the host OS), make sure to check the version
+requirement.
new file mode 100644
@@ -0,0 +1,19 @@
+BR2_riscv=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh board/qemu/riscv64-virt-efi/assemble-flash-images support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG) -c board/qemu/riscv64-virt-efi/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.69"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_EDK2=y
+BR2_TARGET_GRUB2=y
+BR2_TARGET_GRUB2_RISCV64_EFI=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
This defconfig enables edk2 UEFI shell and grub2 riscv64-efi boot of a Linux Kernel. Signed-off-by: Julien Olivain <ju.o@free.fr> --- Patch series tested on branch master at commit 50eed20 with commands: make check-package ... 0 warnings generated make qemu_riscv64_virt_efi_defconfig make output/images/start-qemu.sh Once logged as root in emulator: dmesg | grep -i efi mount -t efivarfs efivarfs /sys/firmware/efi/efivars ls -al /sys/firmware/efi/efivars --- DEVELOPERS | 2 ++ .../riscv64-virt-efi/assemble-flash-images | 11 ++++++ board/qemu/riscv64-virt-efi/genimage.cfg | 34 ++++++++++++++++++ board/qemu/riscv64-virt-efi/grub.cfg | 6 ++++ board/qemu/riscv64-virt-efi/readme.txt | 36 +++++++++++++++++++ configs/qemu_riscv64_virt_efi_defconfig | 19 ++++++++++ 6 files changed, 108 insertions(+) create mode 100755 board/qemu/riscv64-virt-efi/assemble-flash-images create mode 100644 board/qemu/riscv64-virt-efi/genimage.cfg create mode 100644 board/qemu/riscv64-virt-efi/grub.cfg create mode 100644 board/qemu/riscv64-virt-efi/readme.txt create mode 100644 configs/qemu_riscv64_virt_efi_defconfig