There are two supported methods of booting FreeBSD/arm64 under QEMU: using U-Boot, or using an UEFI firmware image. To use U-Boot, install u-boot-qemu-arm64 package, and then run:

    % qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt  \
        -bios /usr/local/share/u-boot/u-boot-qemu-arm64/u-boot.bin \
        -serial telnet::4444,server -nographic \
        -drive if=none,file=VMDISK,id=hd0 \
        -device virtio-blk-device,drive=hd0 \
        -device virtio-net-device,netdev=net0 \
        -netdev user,id=net0

Be sure to replace "VMDISK" with the path to the virtual machine image.

Prepopulated images are available under https://download.freebsd.org/releases/VM-IMAGES/ or https://download.freebsd.org/snapshots/VM-IMAGES/

Qemu comes with a UEFI firmware image. To boot the VM image run:

    % qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt  \
        -bios edk2-aarch64-code.fd -serial telnet::4444,server -nographic \
        -drive if=none,file=VMDISK,id=hd0 \
        -device virtio-blk-device,drive=hd0 \
        -device virtio-net-device,netdev=net0 \
        -netdev user,id=net0

Be sure to replace "VMDISK" with the path to the virtual machine image.

NOTE: if you are booting a 12.x image, use -device virtio-blk,drive=hd0 and -device virtio-net,netdev=net0 instead, e.g.:

    % qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt  \
        -bios edk2-aarch64-code.fd -serial telnet::4444,server -nographic \
        -drive if=none,file=VMDISK,id=hd0 \
        -device virtio-blk,drive=hd0 \
        -device virtio-net,netdev=net0 \
        -netdev user,id=net0

To connect to the virtual console run telnet localhost 4444.

To boot on ThunderX under KVM:

    % qemu-system-aarch64 -m 4096M -cpu host,pmu=off -M virt,gic-version=3 \
        -bios QEMU_EFI.fd -serial telnet::4444,server -nographic \
        -drive if=none,file=VMDISK,id=hd0 \
        -device virtio-blk-device,drive=hd0 \
        --enable-kvm

To boot on Apple Silicon hardware (M1, M2) and macOS with HVF acceleration:

    % qemu-system-aarch64 -m 4096M -cpu host -M virt,accel=hvf \
        -bios edk2-aarch64-code.fd -serial telnet::4444,server -nographic \
        -drive if=virtio,file=VMDISK,id=hd0 \
        -device virtio-net,netdev=net0 -netdev user,id=net0


CategoryVirtualization

arm64/QEMU (last edited 2023-01-05T20:29:29+0000 by LiWenHsu)