0

I am trying to emulate a Raspberry Pi 3B using QEMU 7 with the following options:

qemu-system-aarch64 \
    -M raspi3b \
    -cpu cortex-a53 \
    -append "ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" \
    -dtb bcm2710-rpi-3-b.dtb \
    -drive if=sd,format=raw,file=2022-04-04-raspios-bullseye-arm64-lite.img \
    -kernel kernel8.img \
    -m 1G -smp 4 \
    -serial mon:stdio \
    -usb -device usb-mouse -device usb-kbd \
    -device usb-net,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::5555-:22 \

But without much success as I am facing some problems.

First, I can't login with the default pi/raspberry combo. I have used the lite image, the full image and the ubuntu server one (with ubuntu/ubuntu combo) and I wasn't able to login in any of them although I have tried numerous times, I have made sure that I typed the password correctly and even copy-pasted it but to no avail.

Furthermore while booting I get an error that the kernel modules weren't loaded. I also believe that I should provide QEMU with an initrd file which I can't find on the Raspberry/firmware repository (where I got the kernel and the device tree).

PS

There is also a minor annoyance because the emulation runs in the console while the QEMU window remains pitch black.

Edit #1:

I was able to login using the Ubuntu Server image with the following options, but it doesn't connect to the internet (the PS described above persists too):

qemu-system-aarch64 \
    -M raspi3b \
    -cpu cortex-a53 \
    -m 1G -smp 4 \
    -drive if=sd,format=raw,file=ubuntu-22.04-server-raspi.img \
    -kernel vmlinuz \
    -append "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" \
    -initrd initrd.img \
    -dtb bcm2710-rpi-3-b_ubuntu.dtb \
    -serial mon:stdio \
    -usb -device usb-mouse -device usb-kbd \
    -device usb-net,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::5555-:22 \

Important for QEMU beginners that may read this in the future: Kernel image, initrd and dtb must be retrieved from the same image that is used to boot in order to avoid version mismatches. This is why the kernel modules didn't load.

Also notice that it takes a few minutes to boot, more so in the first boot/initial setup, so be patient before logging in.

2
  • i do not see a question in your post
    – jsotola
    Aug 4 at 6:46
  • @jsotola how to make it work. I fixed the modules & login issue as described in edit #1 but I can't connect to the internet, so it's still not properly emulated.
    – AQUATH
    Aug 4 at 8:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.