From dc93fe21d8600c482a05067615b0869d12ecd664 Mon Sep 17 00:00:00 2001 From: David Hu Date: Tue, 31 May 2022 08:29:59 -0700 Subject: [PATCH] Arm qemu board, arm64 equivalent to qemu/x86_64 TODO: * flash config can be trimmed down to minimal * aarch64 qemu startup options can be trimmed down Signed-off-by: David Hu --- mainboards/qemu/arm64/Makefile | 45 ++++++++++++++++ mainboards/qemu/arm64/flash.config | 84 ++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 mainboards/qemu/arm64/Makefile create mode 100644 mainboards/qemu/arm64/flash.config diff --git a/mainboards/qemu/arm64/Makefile b/mainboards/qemu/arm64/Makefile new file mode 100644 index 0000000..ae245b4 --- /dev/null +++ b/mainboards/qemu/arm64/Makefile @@ -0,0 +1,45 @@ +flashinitramfs.cpio: flashkernel core.cpio + GO111MODULE=off GOARCH=arm64 u-root -o $@ \ + -files flashkernel \ + -files core.cpio \ + -files /usr/bin/gzip \ + github.com/u-root/u-root/cmds/boot/pxeboot \ + github.com/u-root/u-root/cmds/core/cat \ + github.com/u-root/u-root/cmds/core/elvish \ + github.com/u-root/u-root/cmds/core/init \ + github.com/u-root/u-root/cmds/core/ip \ + github.com/u-root/u-root/cmds/core/ls \ + github.com/u-root/u-root/cmds/core/kexec \ + github.com/u-root/u-root/cmds/core/pci \ + github.com/u-root/u-root/cmds/core/wget + +core.cpio: flash.config Makefile + GO111MODULE=off GOARCH=arm64 u-root -o $@ + +flashkernel: flash.config core.cpio + cp $< linux/.config + echo CONFIG_CMDLINE_BOOL=y >> linux/.config + echo CONFIG_CMDLINE_OVERRIDE=y >> linux/.config + (cd linux && make ARCH=arm64 olddefconfig && make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j32) + cp linux/arch/arm64/boot/Image $@ + +testflashkernel: flashkernel flashinitramfs.cpio + qemu-system-aarch64 -device VGA,edid=on -device qemu-xhci -device usb-tablet -device usb-kbd \ + -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ + -nographic -machine virt -cpu cortex-a57 -m 512 -serial mon:stdio -serial null \ + -initrd flashinitramfs.cpio \ + -kernel flashkernel \ + -append console=ttyAMA0,115200 \ + -monitor $(MONITOR) $(EXTRA) + +fetch: getkernel geturoot + +installdep: + sudo apt install gcc-aarch64-linux-gnu + +getkernel: + rm -rf linux + git clone --depth=1 -b v5.11 https://github.com/torvalds/linux + +geturoot: + GO111MODULE=off go get -u github.com/u-root/u-root diff --git a/mainboards/qemu/arm64/flash.config b/mainboards/qemu/arm64/flash.config new file mode 100644 index 0000000..9a203e5 --- /dev/null +++ b/mainboards/qemu/arm64/flash.config @@ -0,0 +1,84 @@ +# Copyright 2022 the u-root Authors. All rights reserved +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. +# +# If you copy this to your Linux directory, run +# make olddefconfig +# to fill in the blanks. +# +# This is not intended to be a minimal Linux configuration, but perhaps it comes +# close to listing requirements for certain things. +# +# EFI +CONFIG_EFI_STUB=y +CONFIG_EFI=y +CONFIG_EFI_ESRT=y +CONFIG_EFI_PARAMS_FROM_FDT=y +CONFIG_EFI_RUNTIME_WRAPPERS=y +CONFIG_EFI_ARMSTUB=y +CONFIG_EFI_ARMSTUB_DTB_LOADER=y +CONFIG_EFI_EARLYCON=y +# Config settings specific to ARM hardware: +CONFIG_MMU=y +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARCH_VIRT=y +CONFIG_ARM_AMBA=y +CONFIG_ARM64_VA_BITS_48=y +# Minimal kernel config needed for Go and serial port: +CONFIG_SERIAL_AMBA_PL011=y +CONFIG_SERIAL_AMBA_PL011_CONSOLE=y +CONFIG_CMDLINE="console=ttyAMA0,115200" +# vfat filesystem: +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NLS=y +CONFIG_MSDOS_FS=y +# Loop device for tcz: +CONFIG_BLK_DEV_LOOP=y +CONFIG_MISC_FILESYSTEMS=y +CONFIG_SQUASHFS=y +# GPIO test - mock GPIO libraries +CONFIG_GPIOLIB=y +CONFIG_GPIO_MOCKUP=y +CONFIG_GPIO_SYSFS=y +# For the kernel being kexec'ed +CONFIG_RELOCATABLE=y +# For the kernel doing the kexec'ing +# CONFIG_KEXEC needs more stuff on ARM +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +CONFIG_SUSPEND=y +CONFIG_HOTPLUG_CPU=y +# BMC IPMI Support +CONFIG_IPMI_HANDLER=y +CONFIG_IPMI_DEVICE_INTERFACE=y +CONFIG_IPMI_SI=y +CONFIG_IPMI_SSIF=y +CONFIG_IPMI_DMI_DECODE=y +CONFIG_IPMI_PLAT_DATA=y +# Enable SMMUv3 +CONFIG_IOMMU_IOVA=y +CONFIG_IOMMU_API=y +CONFIG_IOMMU_SUPPORT=y +CONFIG_IOMMU_DMA=y +CONFIG_OF_IOMMU=y +CONFIG_IOMMU_IO_PGTABLE=y +CONFIG_IOMMU_IO_PGTABLE_LPAE=y +CONFIG_ARM_SMMU_V3=y +# Enable EFI RTC +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_EFI=y +# Hotremove needed for ProdID +CONFIG_MEMORY_HOTPLUG=y +CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y +CONFIG_MIGRATION=y +CONFIG_MEMORY_HOTREMOVE=y + +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_COMPRESSION=".xz" +CONFIG_INITRAMFS_COMPRESSION_XZ=y +# seem required, other make will do prompt and ask again. +ARM64_PTR_AUTH=n +ARM64_TLB_RANGE=y +ARM64_MTE=y