openwrt/target/linux/armvirt
Mathew McBride 0bedcbb9ff
build: enable vmdk/vmware images for arm64 target
This is useful for VMware's ARM64 products, e.g Fusion for M1/ARM Macs.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
(cherry picked from commit f899e0e024)
2023-06-13 14:12:30 +02:00
..
32 armvirt: add EFI support 2023-06-13 14:12:23 +02:00
64 armvirt: add EFI support 2023-06-13 14:12:23 +02:00
base-files armvirt: remove model name override 2023-06-13 14:12:29 +02:00
image armvirt: set kernel partition as the EFI system partition 2023-06-13 14:12:28 +02:00
patches-5.15 armvirt: disable LD dead code elimination on ARM32 2023-06-13 14:12:24 +02:00
config-5.15 kernel: Activate CONFIG_GPIOLIB in generic configuration 2022-08-10 21:36:17 +02:00
Makefile build: enable vmdk/vmware images for arm64 target 2023-06-13 14:12:30 +02:00
README armvirt: update README with new image names 2023-06-13 14:12:25 +02:00

This target generates images that can be used on ARM machines with EFI
support (e.g EDKII/TianoCore or U-Boot with bootefi).

The kernel and filesystem images can also be used directly by QEMU:

Run with qemu-system-arm

	# boot with initramfs embedded in
	qemu-system-arm -nographic -M virt -m 64 -kernel openwrt-armvirt-32-generic-initramfs-kernel.bin

	# boot with accel=kvm
	qemu-system-arm -nographic -M virt,accel=kvm -cpu host -m 64 -kernel
	openwrt-armvirt-32-generic-initramfs-kernel.bin

	# boot with a separate rootfs
	qemu-system-arm -nographic -M virt -m 64 -kernel openwrt-armvirt-32-generic-kernel.bin \
	  -drive file=openwrt-armvirt-32-generic-ext4-rootfs.img,format=raw,if=virtio -append 'root=/dev/vda rootwait'

	# boot with local dir as rootfs
	qemu-system-arm -nographic -M virt -m 64 -kernel openwrt-armvirt-32-generic-kernel.bin \
	  -fsdev local,id=rootdev,path=root-armvirt/,security_model=none \
	  -device virtio-9p-pci,fsdev=rootdev,mount_tag=/dev/root \
	  -append 'rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p'

Run with kvmtool

	# start a named machine
	lkvm run -k openwrt-armvirt-32-zImage -i openwrt-armvirt-32-rootfs.cpio --name armvirt0

	# start with virtio-9p rootfs
	lkvm run -k openwrt-armvirt-32-zImage -d root-armvirt/

	# stop "armvirt0"
	lkvm stop --name armvirt0

	# stop all
	lkvm stop --all

The multi-platform ARMv8 target can be used with QEMU:

	qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic \
		-kernel openwrt-armvirt-64-generic-initramfs-kernel.bin \

With a EDKII or U-Boot binary for the QEMU ARM virtual machines, you can use these
images in EFI mode:

32-bit:
gunzip -c bin/targets/armvirt/32/openwrt-armvirt-32-generic-ext4-combined.img.gz > openwrt-arm-32.img
qemu-system-arm -nographic \
    -cpu cortex-a15 -machine virt \
    -bios QEMU_EFI_32.fd \
    -smp 1 -m 1024 \
    -device virtio-rng-pci \
    -drive file=openwrt-arm-32.img,format=raw,index=0,media=disk \
    -netdev user,id=testlan -net nic,netdev=testlan \
    -netdev user,id=testwan -net nic,netdev=testwan

64-bit:
gunzip -c bin/targets/armvirt/64/openwrt-armvirt-64-generic-ext4-combined.img.gz > openwrt-arm-64.img
qemu-system-aarch64 -nographic \
    -cpu cortex-a53 -machine virt \
    -bios QEMU_EFI_64.fd \
    -smp 1 -m 1024 \
    -device virtio-rng-pci \
    -drive file=openwrt-arm-64.img,format=raw,index=0,media=disk \
    -netdev user,id=testlan -net nic,netdev=testlan \
    -netdev user,id=testwan -net nic,netdev=testwan

One can find EFI/BIOS binaries from:
- Compile mainline U-Boot for the QEMU ARM virtual machine (qemu_arm_defconfig/qemu_arm64_defconfig)
- From distribution packages (such as qemu-efi-arm and qemu-efi-aarch64 in Debian)
- Community builds, like retrage/edk2-nightly: https://retrage.github.io/edk2-nightly/