From 59f661b8faf1ac0892dd46875732b9d5591f1d85 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Wed, 18 Jun 2025 19:20:32 +0100 Subject: [PATCH] configs/loongarch64_efi: new defconfig Introduce bread new loongarch64-efi board, with skeleton from aarch64-efi board. It corverd most LoongArch64 systems. Linux 6.12, as the most recent LTS kernel, was chosen to ensure proper architecture support is included. This board config is validated on my Lemote A2101 Loongson 3A5000 board. A developer entry is created for myself for future contacts as well. Signed-off-by: Jiaxun Yang Reviewed-by: Romain Naour Signed-off-by: Julien Olivain --- DEVELOPERS | 2 + board/loongarch64-efi/genimage-efi.cfg | 30 +++++++++++++++ board/loongarch64-efi/grub.cfg | 6 +++ .../patches/linux-headers/linux-headers.hash | 1 + .../loongarch64-efi/patches/linux/linux.hash | 2 + board/loongarch64-efi/post-image.sh | 5 +++ board/loongarch64-efi/readme.txt | 38 +++++++++++++++++++ configs/loongarch64_efi_defconfig | 22 +++++++++++ 8 files changed, 106 insertions(+) create mode 100644 board/loongarch64-efi/genimage-efi.cfg create mode 100644 board/loongarch64-efi/grub.cfg create mode 120000 board/loongarch64-efi/patches/linux-headers/linux-headers.hash create mode 100644 board/loongarch64-efi/patches/linux/linux.hash create mode 100755 board/loongarch64-efi/post-image.sh create mode 100644 board/loongarch64-efi/readme.txt create mode 100644 configs/loongarch64_efi_defconfig diff --git a/DEVELOPERS b/DEVELOPERS index f232b52867..fce7c18474 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1644,6 +1644,8 @@ F: package/rtty/ N: Jiaxun Yang F: arch/Config.in.loongarch +F: board/loongarch64-efi +F: configs/loongarch64_efi_defconfig N: Joachim Wiberg F: configs/globalscale_espressobin_defconfig diff --git a/board/loongarch64-efi/genimage-efi.cfg b/board/loongarch64-efi/genimage-efi.cfg new file mode 100644 index 0000000000..24b9a8d943 --- /dev/null +++ b/board/loongarch64-efi/genimage-efi.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/loongarch64-efi/grub.cfg b/board/loongarch64-efi/grub.cfg new file mode 100644 index 0000000000..2006f6d60d --- /dev/null +++ b/board/loongarch64-efi/grub.cfg @@ -0,0 +1,6 @@ +/set default="0" +set timeout="5" + +menuentry "Buildroot" { + linux /vmlinux.efi root=PARTLABEL=root rootwait console=ttyS0,115200 +} diff --git a/board/loongarch64-efi/patches/linux-headers/linux-headers.hash b/board/loongarch64-efi/patches/linux-headers/linux-headers.hash new file mode 120000 index 0000000000..5808d92afe --- /dev/null +++ b/board/loongarch64-efi/patches/linux-headers/linux-headers.hash @@ -0,0 +1 @@ +../linux/linux.hash \ No newline at end of file diff --git a/board/loongarch64-efi/patches/linux/linux.hash b/board/loongarch64-efi/patches/linux/linux.hash new file mode 100644 index 0000000000..381f3427a6 --- /dev/null +++ b/board/loongarch64-efi/patches/linux/linux.hash @@ -0,0 +1,2 @@ +# From https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc +sha256 a9b020721778384507010177d3929e7d4058f7f6120f05a99d56b5c5c0346a70 linux-6.12.32.tar.xz diff --git a/board/loongarch64-efi/post-image.sh b/board/loongarch64-efi/post-image.sh new file mode 100755 index 0000000000..fdb17ece70 --- /dev/null +++ b/board/loongarch64-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/loongarch64-efi/readme.txt b/board/loongarch64-efi/readme.txt new file mode 100644 index 0000000000..8b92f620f9 --- /dev/null +++ b/board/loongarch64-efi/readme.txt @@ -0,0 +1,38 @@ +The loongarch64_efi_defconfig allows to build a minimal Linux system that +can boot on all loongarch64 systems providing an New World [1] EFI firmware. + +This includes almost all LoongArch Loongson-3 series workstations and servers, +see [2] for hardware and firmware information. + +Building and booting +==================== + +$ make loongarch64_efi_defconfig +$ make + +The file output/images/disk.img is a complete disk image that can be +booted, it includes the grub2 bootloader, Linux kernel and root +filesystem. + +Testing under Qemu +================== + +This image can also be tested using Qemu: + +qemu-system-loongarch64 \ + -M virt \ + -cpu la464 \ + -nographic \ + -bios \ + -drive file=output/images/disk.img,if=none,format=raw,id=hd0 \ + -device virtio-blk-pci,drive=hd0 \ + -netdev user,id=eth0 \ + -device virtio-net-pci,netdev=eth0 + +Note that needs to point to a valid loongarch64 UEFI +firmware image for qemu. +It may be provided by your distribution as a edk2-loongarch64 package, +in path such as /usr/share/edk2/loongarch64/QEMU_EFI.fd . + +[1]: https://areweloongyet.com/en/docs/old-and-new-worlds/ +[2]: https://github.com/loongson/Firmware diff --git a/configs/loongarch64_efi_defconfig b/configs/loongarch64_efi_defconfig new file mode 100644 index 0000000000..c98699330d --- /dev/null +++ b/configs/loongarch64_efi_defconfig @@ -0,0 +1,22 @@ +BR2_loongarch64=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_12=y +BR2_GLOBAL_PATCH_DIR="board/loongarch64-efi/patches" +BR2_DOWNLOAD_FORCE_CHECK_HASHES=y +BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/loongarch64-efi/post-image.sh support/scripts/genimage.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/loongarch64-efi/genimage-efi.cfg" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.32" +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_4=y +BR2_TARGET_ROOTFS_EXT2_SIZE="200M" +# BR2_TARGET_ROOTFS_TAR is not set +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