浏览代码

configs/qemu_riscv64_virt_efi: new defconfig

This defconfig enables edk2 UEFI shell and grub2 riscv64-efi boot
of a Linux Kernel.

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Julien Olivain 1 年之前
父节点
当前提交
8219955118

+ 2 - 0
DEVELOPERS

@@ -1713,11 +1713,13 @@ F:	configs/ts7680_defconfig
 F:	package/paho-mqtt-c
 F:	package/paho-mqtt-c
 
 
 N:	Julien Olivain <ju.o@free.fr>
 N:	Julien Olivain <ju.o@free.fr>
+F:	board/qemu/riscv64-virt-efi/
 F:	board/spike/
 F:	board/spike/
 F:	board/technexion/imx8mmpico/
 F:	board/technexion/imx8mmpico/
 F:	board/technexion/imx8mpico/
 F:	board/technexion/imx8mpico/
 F:	configs/imx8mmpico_defconfig
 F:	configs/imx8mmpico_defconfig
 F:	configs/imx8mpico_defconfig
 F:	configs/imx8mpico_defconfig
+F:	configs/qemu_riscv64_virt_efi_defconfig
 F:	configs/spike_riscv64_defconfig
 F:	configs/spike_riscv64_defconfig
 F:	package/fluid-soundfont/
 F:	package/fluid-soundfont/
 F:	package/fluidsynth/
 F:	package/fluidsynth/

+ 11 - 0
board/qemu/riscv64-virt-efi/assemble-flash-images

@@ -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

+ 34 - 0
board/qemu/riscv64-virt-efi/genimage.cfg

@@ -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"
+	}
+}

+ 6 - 0
board/qemu/riscv64-virt-efi/grub.cfg

@@ -0,0 +1,6 @@
+set default="0"
+set timeout="5"
+
+menuentry "Buildroot" {
+	linux /Image root=PARTLABEL=root rootwait
+}

+ 36 - 0
board/qemu/riscv64-virt-efi/readme.txt

@@ -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.

+ 19 - 0
configs/qemu_riscv64_virt_efi_defconfig

@@ -0,0 +1,19 @@
+BR2_riscv=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=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