I needed a way to run an Orange Pi Zero SD-Card image of Armbian as a virtual machine. And this is actually possible with QEMU!
This is the command I used:
qemu-system-arm \ -M orangepi-pc -m 1024 -cpu cortex-a7 -dtb boot/dtb/sun8i-h3-orangepi-pc.dtb \ -kernel boot/vmlinuz-5.4.45-sunxi -initrd boot/initrd.img-5.4.45-sunxi \ -append 'earlyprintk loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/mmcblk0p1' \ -nographic -serial stdio -monitor none \ -drive file=Armbian_20.05.3_Orangepizero_buster_current_5.4.45.img,format=raw,if=none,id=d1 \ -device sd-card,drive=d1 \ -nic user,model=allwinner-sun8i-emac,hostfwd=tcp::50022-:22
Original source: https://forum.armbian.com/topic/7547-run-armbian-into-qemu/?tab=comments#comment-86797
You need to get the contents of the
/boot directory from the SD Card image so that you can start booting it. I just used
scp to copy it from a running Orange Pi Zero to my main machine. The command above doesn’t actually run an Orange Pi Zero board, it runs an Orange Pi PC, though this is almost the same thing. At least the CPU is the same (note: Allwinner H2+ and H3 are binary compatible). But it has more memory!
Why run Armbian in QEMU?
I wanted to compile an application written in Rust. The problem was that installing it the official way through
rustup (or more precisely
rustup-init) resulted in an error:
info: installing component 'cargo' info: Defaulting to 139.4 MiB unpack ram thread 'main' panicked at 'RUSTUP_UNPACK_RAM must be larger than 220000000', src/dist/component/package.rs:200:13 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'main' panicked at 'No process instance', src/currentprocess.rs:126:17
The newer versions of rust required more memory than the Orange Pi Zero had! Mine had 256 MB (since I thought I’d take this as a challenge instead of going with the 512 MB version). Rustup needed at least 220 MB on its own.
Alternatively I could get some cross-compilation toolchain. But that seemed even harder; I couldn’t find anything usable.