Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulating Raspberry Pi 4 with QEMU?

I want to emulate Raspberry Pi 4 using QEMU, but I am not able to find any image for RPi4. I need a kernel with which QEMU can emulate a Cortex-A72.

like image 719
Anwar Ghammam Avatar asked Nov 29 '25 16:11

Anwar Ghammam


1 Answers

I just boot raspios bullseye on a x86 ubuntu laptop, it can show the desktop, can be login in. But it's very slow.

qemu-system-aarch64 -M virt,highmem=off -smp 8 -m 2G -cpu cortex-a72 -kernel linux-stable/arch/arm64/boot/Image -append root=PARTUUID=d97f5830-02 rw console=ttyAMA0 -serial telnet:localhost:4321,server,nowait -monitor telnet:localhost:4322,server,nowait -device VGA,id=vga1 -device secondary-vga,id=vga2 -object iothread,id=io1 -device virtio-blk-pci,drive=disk0,iothread=io1 -drive data/images/2022-01-28-raspios-bullseye-arm64.img

I build the kernel image follow this guide.

https://github.com/anholt/linux/wiki/Raspberry-Pi-development-environment#building-the-Kernel

Of course, as the raspios is emulated on the x86 laptop, it's definitely slow. So, if you can virtualize it on an arm64 host, you can use the accelerator like kvm, hvf etc.

    qemu-system-aarch64 \
      -M virt,highmem=off,accel=hvf \
      -cpu host \
      -m 1G \
      -smp 4 \
      -kernel $KERNEL_IMAGE_PATH -append "root=/dev/vda2 rw console=ttyAMA0" \
      -netdev user,id=n1,ipv6=off,hostfwd=tcp::5555-:22 -device e1000,netdev=n1 \
      -hda data/images/2022-01-28-raspios-bullseye-arm64.img \
      -serial telnet:localhost:4321,server,nowait \
      -monitor telnet:localhost:4322,server,nowait \
      -device VGA,id=vga2 \
      -drive file=data/images/2021-10-30-raspios-bullseye-armhf.img,if=virtio
like image 159
Jiang Avatar answered Dec 01 '25 08:12

Jiang