- Download
2020-08-20-raspios-buster-armhf-lite.zip
from the official site - Install required tools
sudo pacman -S unzip util-linux qemu qemu-arch-extra
Minimal required QEMU version is 5.1
qemu-system-aarch64 --version
# QEMU emulator version 5.1.0
Ethernet is shared with USB controller on Raspberry Pi 3, but the changelog for QEMU 5.1 states:
The Raspberry Pi boards now support the USB controller.
unzip 2020-08-20-raspios-buster-armhf-lite.zip
sudo losetup --show -fP 2020-08-20-raspios-buster-armhf-lite.img
# i.e. /dev/loop0
sudo mkdir /mnt/raspios
sudo mount /dev/loop0p1 /mnt/raspios
cp /mnt/raspios/kernel8.img /mnt/raspios/bcm2710-rpi-3-b.dtb .
sudo umount /mnt/raspios
sudo losetup -d /dev/loop0
Run with QEMU
- Resize the raw image (2, 4, 8, 16 ... GB)
qemu-img resize 2020-08-20-raspios-buster-armhf-lite.img 4GB
- Run the image
sudo qemu-system-aarch64 \
-m 1024 \
-M raspi3 \
-kernel kernel8.img \
-dtb bcm2710-rpi-3-b.dtb \
-sd 2020-08-20-raspios-buster-armhf-lite.img \
-append "console=ttyAMA0 root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4" \
-nographic \
-device usb-net,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22
The guest is ARM64 with networking available
uname -m
# aarch64
lsusb
# Bus 001 Device 003: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
ip addr
#2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
# link/ether 40:54:00:12:34:57 brd ff:ff:ff:ff:ff:ff
# inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute eth0
We are running in arm64 mode
- Enabe the ssh daemon
sudo systemctl enable ssh --now
Interact with the image
Copy the ssh credentials over, password is raspberry
ssh-copy-id -p 2222 pi@localhost
ssh -p 2222 pi@localhost
Done!
Links
- https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device/496576#496576
- https://raspberrypi.stackexchange.com/questions/100384/running-raspbian-buster-with-qemu
- https://github.com/raspberrypi/firmware
- https://www.raspberrypi.org/forums/viewtopic.php?t=195565&start=50
- https://bugs.launchpad.net/qemu/+bug/1772165
- https://lore.kernel.org/qemu-devel/20200428022232.18875-1-pauldzim@gmail.com/
- https://metebalci.com/blog/bare-metal-rpi3-network-boot/