[Buildroot] [PATCH v2 2/2] configs/qemu_riscv64_virt_efi: new defconfig

Yann E. MORIN yann.morin.1998 at free.fr
Sun Dec 24 16:57:24 UTC 2023


Julien, All,

On 2023-12-23 22:29 +0100, Julien Olivain spake thusly:
> This defconfig enables edk2 UEFI shell and grub2 riscv64-efi boot
> of a Linux Kernel.
> 
> Signed-off-by: Julien Olivain <ju.o at free.fr>

After tracking the EDK2 build issue with per-package the whole day, and
conluding that it was not specific to this defconfig, I applied to
master, thanks!

Regards,
Yann E. MORIN.

> ---
> Changes v1 -> v2:
> - Remove BR2_TOOLCHAIN_EXTERNAL=y in defconfig.
>   (it was an incorrect leftover from a test)
> - Add BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1 in defconfig.
> 
> Patch series tested on branch master at commit 1667987 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
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index bad07d51aa..cfd8b7bd8f 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1713,11 +1713,13 @@ F:	configs/ts7680_defconfig
>  F:	package/paho-mqtt-c
>  
>  N:	Julien Olivain <ju.o at 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/
> diff --git a/board/qemu/riscv64-virt-efi/assemble-flash-images b/board/qemu/riscv64-virt-efi/assemble-flash-images
> new file mode 100755
> index 0000000000..abcaa2c93b
> --- /dev/null
> +++ b/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
> diff --git a/board/qemu/riscv64-virt-efi/genimage.cfg b/board/qemu/riscv64-virt-efi/genimage.cfg
> new file mode 100644
> index 0000000000..46950591e0
> --- /dev/null
> +++ b/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"
> +	}
> +}
> diff --git a/board/qemu/riscv64-virt-efi/grub.cfg b/board/qemu/riscv64-virt-efi/grub.cfg
> new file mode 100644
> index 0000000000..d99e19c4cd
> --- /dev/null
> +++ b/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
> +}
> diff --git a/board/qemu/riscv64-virt-efi/readme.txt b/board/qemu/riscv64-virt-efi/readme.txt
> new file mode 100644
> index 0000000000..6b9651a011
> --- /dev/null
> +++ b/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.
> diff --git a/configs/qemu_riscv64_virt_efi_defconfig b/configs/qemu_riscv64_virt_efi_defconfig
> new file mode 100644
> index 0000000000..79aadf78ca
> --- /dev/null
> +++ b/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
> -- 
> 2.43.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



More information about the buildroot mailing list