Emulating a Raspberry Pi in QEMU | Interrupt

The Raspberry Pi, a compact single-board computer, is widely used for DIY projects to industrial applications. These devices ship with a customized Linux distribution that differs from standard Linux, adding a layer of complexity for developers trying to troubleshoot application problems and dependencies.

This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/emulating-raspberry-pi-in-qemu

Neat! I especially appreciate that despite the new default password policy, you still used pi:raspberry with the new way :slight_smile:

I noticed you fired up QEMU with -nographic. Does the RPi OS GUI require extra work to bring up in QEMU? Or did you just elect not to use it for this example?

@shiva you can remove -nographic and add -device usb-mouse -device usb-kbd to make it work.

qemu-system-aarch64 -machine raspi3b -cpu cortex-a72 -dtb bcm2710-rpi-3-b-plus.dtb -m 1G -smp 4 -kernel kernel8.img -sd 2023-05-03-raspios-bullseye-arm64.img -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" -device usb-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::2222-:22 -device usb-mouse -device usb-kbd

On a dated Windows 11 AMD64 system using Docker Desktop which uses QEMU and WSL2 underneath, the following errors showed during the boot process:

[ TIME ] Timed out waiting for device /disk/by-partuuid/3e247b30-01.
[DEPEND] Dependency failed for /boot.
[DEPEND] Dependency failed for Local File Systems.
[DEPEND] Dependency failed for File…/disk/by-partuuid/3e247b30-01.

[ OK ] Finished Tell Plymouth To Write Out Runtime Data.
You are in emergency mode. After logging in, type “journalctl -xb” to view
system logs, “systemctl reboot” to reboot, “systemctl default” or “exit”
to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.

A couple of possible causes:

  1. The UUID/PARTUUID in your /etc/fstab doesn’t match the ID on the /boot partition.
  2. If not #1, then perhaps extending the timeout by adding x-systemd.mount-timeout=120 to fstab.for proc and each PARTUUID line?

It’s likely #2.

Update1: Unfortunately, on first boot, fstab isn’t built yet. It contains only this line:


fstab: 3.1.2 Remote Files ystem

Timed Out Waiting For Device During Boot

This doesn’t seem to work on the new bookworm images.
I get no console output when I run QEMU.

I verified that the offset is correct for the mount.

This is great! I’d like to use Buildroot to create my own slimmed down version of an app running on the Raspberry Pi. The goal is to boot into the app in under 5 seconds. The app would be a GUI app (Qt5). I’m looking at stripping away all unnecessary services (e.g. Wifi, Bluetooth, etc.) to achieve this goal. I know that others have done this (see furkantokac.com, IronOxider/instant-pi on Github, etc.).

Developing using Buildroot on actual Raspberry Pi hardware with an actual SD card is painful. This would relieve a lot of stress.

Have you tried Buildroot, Yocto project, or any other customization tool for the Raspberry Pi (and actually other hardware as well)?

Great stuff keep it up.