qemu arm

qemu    arm 笔记待整理

qemu-system-arm -m 1G,slots=3,maxmem=4G \
    -machine type=orangepi-pc -cpu cortex-a7 -dtb dtb/sun8i-h3-nanopi-neo.dtb \
    -smp 4 \
    -kernel vmlinuz-5.10.12-sunxi 
    -initrd uInitrd-5.10.12-sunxi 
    -append "earlyprintk #loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/mmcblk0p1" \
    -no-reboot -nographic -serial stdio -monitor none \
    -hda Armbian_21.02.1_Nanopineo_buster_current_5.10.12.img \
    -nic user,model=allwinner-sun8i-emac,hostfwd=tcp::50022-:22



Works like a charm. If you have an sd-card raw image of armbian, you just need to replace -hda Armbian_21.02.1_Nanopineo_buster_current_5.10.12.img with -drive format=raw,file=sdcard.raw

The answer is a bit late, but it may be useful to someone else, because this page is the first in google for "armbian qemu".

Running image for orange-pi one - Armbian_5.90_Orangepione_Ubuntu_bionic_next_4.19.57.7z:

Extrart Armbian image:

7z e Armbian_5.90_Orangepione_Ubuntu_bionic_next_4.19.57.7z Armbian_5.90_Orangepione_Ubuntu_bionic_next_4.19.57.img


Extract kernel, initrd and dtb:

7z e boot/vmlinuz-4.19.57-sunxi boot/initrd.img-4.19.57-sunxi boot/dtb-4.19.57-sunxi/sun4i-a10-cubieboard.dtb



Run qemu:

qemu-system-arm \
  -M cubieboard -m 1024 -cpu cortex-a8 -dtb sun4i-a10-cubieboard.dtb \
  -kernel vmlinuz-4.19.57-sunxi -initrd initrd.img-4.19.57-sunxi \
  -append 'earlyprintk loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/sda1' \
  -nographic -serial stdio -monitor none \
  -drive file=Armbian_5.90_Orangepione_Ubuntu_bionic_next_4.19.57.img,format=raw,if=none,id=d1 \
  -device ide-hd,drive=d1 \
  -nic user,model=allwinner-emac,hostfwd=tcp::50022-:22


It was tested in qemu 3.1

There’s another way to do this, in Linux at least.

Install qemu-user-static and (if not automatically installed) binfmt. Then copy the Armbian rootfs of the Orange Pi model you want to use to a directory on your PC, e.g. opi-rootfs.

You can now chroot into this directory and it will behave (almost) the same as if you’re on a real Orange Pi

The proper command is ‘sudo chroot opi-rootfs /bin/bash’

You can also mount /dev, /sys, /proc to the same directories in opi-rootfs but for compiling stuff this is not really necessary I think.

Instead of chroot you can also do ‘systemd-nspawn -D opi-rootfs’


相关参考连接

https://wp.dejvino.com/2020/07/orange-pi-zero-running-in-qemu/

https://raspberrypi.stackexchange.com/questions/73699/run-armbian-in-qemu

https://www.qemu.org/docs/master/system/arm/orangepi.html

https://raspberrypi.stackexchange.com/questions/117234/how-to-emulate-raspberry-pi-in-qemu


qemu-system-arm -m 1G,slots=3,maxmem=4G \
    -machine type=orangepi-pc -cpu cortex-a7 -dtb dtb/sun8i-h3-nanopi-neo.dtb \
    -smp 4 \
    -kernel vmlinuz-5.10.12-sunxi 
    -initrd uInitrd-5.10.12-sunxi -append "earlyprintk #loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/mmcblk0p1" \
    -no-reboot -nographic -serial stdio -monitor none \
    -hda Armbian_21.02.1_Nanopineo_buster_current_5.10.12.img \
    -nic user,model=allwinner-sun8i-emac,hostfwd=tcp::50022-:22


set path="E:\Program Files\qemu";%path%
qemu-system-arm -m 1G,slots=3,maxmem=4G -machine type=orangepi-pc -cpu cortex-a7 -dtb dtb/rk3566-orangepi-cm4.dtb -smp 4  -kernel vmlinuz-5.10.160-rockchip-rk356x -initrd initrd.img-5.10.160-rockchip-rk356x -append "earlyprintk #loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/mmcblk0p1"  -no-reboot -nographic -serial stdio -monitor none -hda Orangepicm4.img  -nic user,model=allwinner-sun8i-emac,hostfwd=tcp::50022-:22
qemu-system-arm -m 1G,slots=3,maxmem=4G -machine type=orangepi-pc -cpu cortex-a7 -dtb dtb/rk3566-orangepi-cm4.dtb -smp 4  -kernel vmlinuz-5.10.160-rockchip-rk356x -initrd initrd.img-5.10.160-rockchip-rk356x -append "earlyprintk #loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/mmcblk0p1"  -no-reboot -nographic -serial stdio -monitor none -drive file=Orangepicm4.img,format=raw,if=none,id=d1   -nic user,model=allwinner-sun8i-emac,hostfwd=tcp::50022-:22
qemu-system-arm -M cubieboard -m 1024 -cpu cortex-a8 -dtb dtb/rk3566-orangepi-cm4.dtb -kernel vmlinuz-5.10.160-rockchip-rk356x -initrd initrd.img-5.10.160-rockchip-rk356x -append 'earlyprintk loglevel=8 earlycon=uart8250,mmio32,0x1c28000,115200n8 console=ttyS0 root=/dev/sda1' -nographic -serial stdio -monitor none -drive file=Orangepicm4.img,format=raw,if=none,id=d1 -device ide-hd,drive=d1 -nic user,model=allwinner-emac,hostfwd=tcp::50022-:22
qemu-system-arm -M cubieboard -m 1024 -cpu cortex-a8 -dtb dtb/rk3566-orangepi-cm4.dtb -kernel vmlinuz-5.10.160-rockchip-rk356x -initrd initrd.img-5.10.160-rockchip-rk356x  -nographic -serial stdio -monitor none -drive file=Orangepicm4.img,format=raw,if=none,id=d1 -device ide-hd,drive=d1 -nic user,model=allwinner-emac,hostfwd=tcp::50022-:22
# -drive file=Armbian_5.90_Orangepione_Ubuntu_bionic_next_4.19.57.img,format=raw,if=none,id=d1 \