2

Goal

I'd like to emulate the boot process (any boot process) in AArch64 (ARM64) on the actual, real, AArch64 hardware as I'm working on a bootloader and an emulation workflow is much faster.

Problem

Every attempt to use QEMU results in a blank screen. I have tried running bootloaders, and tried to boot Linux directly. There are no error messages.

Various Attempts

First attempt:

# sudo apt-get install qemu qemu-system-arm qemu-efi-aarch64 qemu-utils qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 some-aarch64-linux.iso # Blank screen. Press ctrl+a c to exit. 

Second attempt:

# Create an EFI bootloader dd if=/dev/zero of=flash0.img bs=1M count=64 dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \ -drive file=flash0.img,format=raw,if=pflash # Blank screen. Press ctrl+a c to exit. 

Third attempt:

qemu-img create -f qcow2 alpine.img 8G wget -O alpine-virt.iso http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/aarch64/alpine-virt-3.12.1-aarch64.iso sudo kvm -machine virt -hda alpine.img -cdrom alpine-virt.iso -m 512 > KVM is not supported for this guest CPU type > kvm_init_vcpu failed: Invalid argument 

Fourth attempt:

qemu-img create -f qcow2 alpine.img 8G wget -O alpine-virt.iso http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/aarch64/alpine-virt-3.12.1-aarch64.iso qemu-system-aarch64 -nographic -machine virt -hda alpine.img -cdrom alpine-virt.iso -m 512 # Blank screen. Press ctrl+a c to exit. 

Fifth attempt with Docker on an x86-64 machine:

docker run -it --rm --name qemu-container \ -e QEMU_ARCH=aarch64 \ -e QEMU_HDA=/tmp/hda.qcow2 \ -e QEMU_HDA_SIZE=1G \ -e QEMU_CPU=4 \ -e QEMU_RAM=512 \ -v ${PWD}/alpine-virt-3.12.1-aarch64.iso:/tmp/os.iso:ro \ -e QEMU_CDROM=/tmp/os.iso \ -e QEMU_BOOT='order=d' \ -e QEMU_PORTS='2375 2376' \ tianon/qemu start-qemu -machine virt # Results: # + qemu-img create -f qcow2 -o preallocation=off /tmp/hda.qcow2 1G # Formatting '/tmp/hda.qcow2', fmt=qcow2 cluster_size=65536 preallocation=off compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16 # + exec qemu-system-aarch64 -smp 4 -m 512 -drive file=/tmp/hda.qcow2,index=0,media=disk,discard=unmap,detect-zeroes=unmap,if=none,id=hda -device virtio-scsi-pci -device scsi-hd,drive=hda -cdrom /tmp/os.iso -boot order=d -netdev user,hostname=30047d3b64c0,hostfwd=tcp::22-:22,hostfwd=udp::22-:22,hostfwd=tcp::2375-:2375,hostfwd=udp::2375-:2375,hostfwd=tcp::2376-:2376,hostfwd=udp::2376-:2376,id=net -device virtio-net-pci,netdev=net -serial stdio -vnc :0 # Frozen. Press ctrl+c to send a signal 

Prior Research:

3
  • 1
    You say you want to work on a bootloader, but then you try to boot Linux. So I don't understand what you're trying to do. Which stage bootloader are you working on? You seem to be keen on EFI: does your real hardware have EFI? Arm bootloaders aren't standardized across manufacturers so a Linux image for a particular kind of hardware might not work on Qemu: you need an image for Qemu — but that would come with a bootloader as a black box. Commented Nov 7, 2020 at 21:53
  • Honestly, at this point, I'm just trying to get anything but a blank screen. But yes, I need to compile U-Boot from source, so if my bootloader functions, then I can boot linux. From my attempts with QEMU I'm just trying to get anything but a blank screen. Commented Nov 7, 2020 at 22:04
  • @Gilles'SO-stopbeingevil' "I'd like to emulate the boot process (any boot process)" if that clarifies your comment. Commented Nov 8, 2020 at 2:00

1 Answer 1

5

Failure (Results in a blank screen):

qemu-system-aarch64 \ -machine virt \ -serial stdio \ -bios u-boot.bin 

Success (The bootloader runs):

qemu-system-aarch64 \ -machine virt \ -serial stdio \ -cpu cortex-a53 \ -bios u-boot.bin 

Solution:

On dissimilar architectures between the host and the guest, add a CPU flag so QEMU doesn't default to the host CPU virtualization:

-cpu cortex-a53 

On identical host hardware to emulation, this flag shouldn't be needed (not needed on x86-64 emulation/hardware?), but in my case it is. Adding this parameter to QEMU emulating AArch64 on real AArch64 hardware allowed the bootloader to run and show output to the console:

~$ qemu-system-aarch64 -machine virt -serial stdio -cpu cortex-a53 -bios u-boot.bin U-Boot 2021.01-rc1-g896cc5aa (Nov 06 2020 - 23:33:35 -0800) DRAM: 128 MiB Flash: 128 MiB *** Warning - bad CRC, using default environment In: pl011@9000000 Out: pl011@9000000 Err: pl011@9000000 Net: No ethernet found. Hit any key to stop autoboot: 0 starting USB... No working controllers found USB is stopped. Please issue 'usb start' first. scanning bus for devices... ... 

Running qemu-system-aarch64 -cpu help:

Available CPUs: arm1026 arm1136 arm1136-r2 arm1176 arm11mpcore arm926 arm946 cortex-a15 cortex-a53 cortex-a57 cortex-a7 cortex-a8 cortex-a9 cortex-m3 cortex-m4 cortex-r5 pxa250 pxa255 pxa260 pxa261 pxa262 pxa270-a0 pxa270-a1 pxa270 pxa270-b0 pxa270-b1 pxa270-c0 pxa270-c5 sa1100 sa1110 ti925t host (only available in KVM mode) 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.