Qemu VM

Qemu provides qemu-system-aarch64 command to emulate aarch64 device.

Serial tty address is /dev/ttyAMA0.

Installation

U-Boot

Clone u-boot git repo and cd to it. Configure and build with:

make CROSS_COMPILE=aarch64-linux-gnu- qemu_arm64_defconfig
make CROSS_COMPILE=aarch64-linux-gnu-

Copy u-boot.bin to directory you will run qemu from

Installation

All you need for working qemu image is to create disk image, partiton it as you wish and unpack rootfs archive.

U-boot searches for boot script (boot.scr) on partitions it can read from (FAT32, ext2 / 3 /4). Create boot.cmd like following:

setenv bootargs "root=/dev/<partname> rw rootwait console=ttyAMA0"
load scsi 0:1 ${kernel_addr_r} /Image
load scsi 0:1 ${ramdisk_addr_r} /initramfs-linux.img
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr}

If your disk image is attached using virtio bus, replace scsi with virtio in this file. If you created loopback drive image (e.g. you formatted the whole disk file as single partition w/0 partition scheme) you should use 0:0 instead of 0:1 as device address. To create script run command:

mkimage -A arm -T ramdisk -d boot.cmd boot.scr

Running

If running on x86-64 machine, use the command like following:

qemu-system-aarch64 -machine virt -cpu cortex-a53 -smp 2 -m 1024 -bios u-boot.bin

You may use other cpu model (see “qemu-system-aarch64 -machine virt -cpu help” for full list).

On aarch64 you can use kvm:

qemu-system-aarch64 -machine virt,accel=kvm -cpu host -smp 2 -m 1024 -bios u-boot.bin

If you want your disk to be connected as scsi, add the following to your qemu command line:

-drive id=disk,file=root.img,format=raw,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0