From ef55ca4075081ec2f0f740204d2b44cd1e0cb00f Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Wed, 18 Jun 2025 19:20:35 +0100 Subject: [PATCH] configs/qemu_loongarch64_virt_efi: new defconfig Add qemu_loongarch64_virt_efi_defconfig, which builds EDK2 and host QEMU to test LoongArch64 buildroot. Signed-off-by: Jiaxun Yang Reviewed-by: Romain Naour Tested-by: Romain Naour Reviewed-by: Julien Olivain Tested-by: Julien Olivain Signed-off-by: Julien Olivain --- DEVELOPERS | 2 ++ board/qemu/loongarch64-virt-efi/genimage.cfg | 30 ++++++++++++++++++ board/qemu/loongarch64-virt-efi/grub.cfg | 6 ++++ board/qemu/loongarch64-virt-efi/post-image.sh | 5 +++ board/qemu/loongarch64-virt-efi/readme.txt | 31 +++++++++++++++++++ configs/qemu_loongarch64_virt_efi_defconfig | 25 +++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 board/qemu/loongarch64-virt-efi/genimage.cfg create mode 100644 board/qemu/loongarch64-virt-efi/grub.cfg create mode 100755 board/qemu/loongarch64-virt-efi/post-image.sh create mode 100644 board/qemu/loongarch64-virt-efi/readme.txt create mode 100644 configs/qemu_loongarch64_virt_efi_defconfig diff --git a/DEVELOPERS b/DEVELOPERS index fce7c18474..99c403686a 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1645,7 +1645,9 @@ F: package/rtty/ N: Jiaxun Yang F: arch/Config.in.loongarch F: board/loongarch64-efi +F: board/qemu/loongarch64-virt-efi F: configs/loongarch64_efi_defconfig +F: configs/qemu_loongarch64_virt_efi_defconfig N: Joachim Wiberg F: configs/globalscale_espressobin_defconfig diff --git a/board/qemu/loongarch64-virt-efi/genimage.cfg b/board/qemu/loongarch64-virt-efi/genimage.cfg new file mode 100644 index 0000000000..24b9a8d943 --- /dev/null +++ b/board/qemu/loongarch64-virt-efi/genimage.cfg @@ -0,0 +1,30 @@ +image efi-part.vfat { + vfat { + file EFI { + image = "efi-part/EFI" + } + file vmlinux.efi { + image = "vmlinux.efi" + } + } + + 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 { + partition-type-uuid = root-loongarch64 + image = "rootfs.ext2" + } +} diff --git a/board/qemu/loongarch64-virt-efi/grub.cfg b/board/qemu/loongarch64-virt-efi/grub.cfg new file mode 100644 index 0000000000..dc3452fe6a --- /dev/null +++ b/board/qemu/loongarch64-virt-efi/grub.cfg @@ -0,0 +1,6 @@ +set default="0" +set timeout="5" + +menuentry "Buildroot" { + linux /vmlinux.efi root=PARTLABEL=root rootwait console=ttyS0 +} diff --git a/board/qemu/loongarch64-virt-efi/post-image.sh b/board/qemu/loongarch64-virt-efi/post-image.sh new file mode 100755 index 0000000000..fdb17ece70 --- /dev/null +++ b/board/qemu/loongarch64-virt-efi/post-image.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +BOARD_DIR="$(dirname "$0")" + +cp -f "${BOARD_DIR}/grub.cfg" "${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg" diff --git a/board/qemu/loongarch64-virt-efi/readme.txt b/board/qemu/loongarch64-virt-efi/readme.txt new file mode 100644 index 0000000000..7c35ee1efe --- /dev/null +++ b/board/qemu/loongarch64-virt-efi/readme.txt @@ -0,0 +1,31 @@ +Intro +===== + +This is a LoongArch 64bit UEFI Linux boot demo in QEMU virt machine. + +Build +===== + + make qemu_loongarch64_virt-efi_defconfig + make + +Emulation +========= + +Run the emulation with: + + qemu-system-loongarch64 \ + -M virt \ + -smp 2 \ + -m 1024 \ + -nographic \ + -bios output/images/QEMU_EFI.fd \ + -drive file=output/images/disk.img,format=raw \ + -netdev user,id=net0 \ + -device virtio-net-pci,netdev=net0 # qemu_loongarch64_virt_efi_defconfig + +Note: for information, qemu version >= 9.0.0 is needed for this UEFI +Linux demo. 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_loongarch64_virt_efi_defconfig b/configs/qemu_loongarch64_virt_efi_defconfig new file mode 100644 index 0000000000..945cb9232d --- /dev/null +++ b/configs/qemu_loongarch64_virt_efi_defconfig @@ -0,0 +1,25 @@ +BR2_loongarch64=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_12=y +BR2_GLOBAL_PATCH_DIR="board/qemu/patches" +BR2_DOWNLOAD_FORCE_CHECK_HASHES=y +BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y +BR2_SYSTEM_DHCP="eth0" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/loongarch64-virt-efi/post-image.sh board/qemu/post-image.sh support/scripts/genimage.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG) -c board/qemu/loongarch64-virt-efi/genimage.cfg" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.27" +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y +BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y +BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_SIZE="200M" +# BR2_TARGET_ROOTFS_TAR is not set +BR2_TARGET_EDK2=y +BR2_TARGET_GRUB2=y +BR2_TARGET_GRUB2_LOONGARCH64_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