I am trying to emulate a Raspberry Pi zero W with Qemu based on an image I used on a real Raspberry Pi zero W.

The command I am using is:

sudo qemu-system-arm \                                                                                                                                                       
-kernel ./qemu-rpi-kernel/kernel-qemu-4.9.59-stretch \
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
-hda pi_zero_kinetic_raspbian.qcow \
-cpu arm1176 -m 512 \
-M versatilepb \
-no-reboot \
-serial stdio \
-net nic -net user \
-net tap,ifname=vnet0,script=no,downscript=no

But Qemu complain that Error: unrecognized/unsupported machine ID (r1 = 0x00000183)

So added this option:

-dtb linux/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts

But In this case:

qemu-system-arm: Unable to copy device tree in memory
Couldn't open dtb file qemu-rpi-kernel/tools/linux/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts

So I tried to compile the dts in order to get the dtb with:

dtc -O dtb -o bcm2835-rpi-zero-w.dtb bcm2835-rpi-zero-w.dts

But the compilation fail and I get:

Error: bcm2835-rpi-zero-w.dts:13.1-9 syntax error
FATAL ERROR: Unable to parse input tree

I couldn't find any tutorial about Pi zero and all the tutorial about the first Rapsberry Pi seems to be outdated. I am not sure that compiling the dtb on my own is the way to go. Any input would be appreciated, thanks!


This works for me on MacOS Mojave,

Create a file called qemu_script.sh and copy-paste the code below

nano qemu_script.sh

give execution perms and execute,

$ chmod +x qemu_script.sh
$ ./qemu_script.sh



brew install qemu

export QEMU=$(which qemu-system-arm)
export TMP_DIR=~/tmp/qemu-rpi
export RPI_KERNEL=${TMP_DIR}/kernel-qemu-4.14.79-stretch
export RPI_FS=${TMP_DIR}/2018-11-13-raspbian-stretch-lite.img
export PTB_FILE=${TMP_DIR}/versatile-pb.dtb
export IMAGE_FILE=2018-11-13-raspbian-stretch-lite.zip
export IMAGE=http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2018-11-15/${IMAGE_FILE}

mkdir -p $TMP_DIR; cd $TMP_DIR

wget https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.14.79-stretch?raw=true \
        -O ${RPI_KERNEL}

wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb.dtb \
        -O ${PTB_FILE}

wget $IMAGE

$QEMU -kernel ${RPI_KERNEL} \
    -cpu arm1176 -m 256 -M versatilepb \
    -dtb ${PTB_FILE} -no-reboot \
    -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
    -drive "file=${RPI_FS},index=0,media=disk,format=raw" \
    -net user,hostfwd=tcp::5022-:22 -net nic \

You should get: enter image description here

  • What's that? Can you explain please? – Ingo Feb 11 '19 at 20:39
  • Ok, added steps and resulting image in MacOS – user9869932 Feb 11 '19 at 23:17
  • You don't need export in your script. – Pierre Thibault Oct 31 '19 at 20:40
  • @PierreThibault feel free to modify the post if you tested it and works for you – user9869932 Nov 1 '19 at 2:21
  • @user9869932 I made a Python script so it can also work on Windows. I cannot share it. – Pierre Thibault Nov 1 '19 at 21:02
  1. You are still using "versatilepb". If you want to emulate a Raspberry Pi, use "raspi"
  2. The precompiled DTB files can be downloaded from the foundation firmware github. Direct link for the Pi Zero DTB here.
  • Thanks for the answer. If I use the "raspi" machine I got unsupported machine type. And raspi is not listed as supported machine. Is there a way to add it? – Snemed Sep 19 '18 at 10:13
  • I even tried with the latest version of Qemu (from source 3.0.50) and there is only raspi2 no raspi – Snemed Sep 19 '18 at 12:51
  • 2
    what happened when you tried raspi2? – jsotola Sep 20 '18 at 23:44

I share my updated version of the script for Raspbian-buster-lite guest on Ubuntu host.


QEMU=$(command -v qemu-system-arm)

mkdir -p $TMP_DIR

wget https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/${RPI_KERNEL}?raw=true \
        -O ${RPI_KERNEL_FILE}

wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/$PTB \
        -O ${PTB_FILE}

wget http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-09-30/$IMAGE \
        -O ${IMAGE_FILE}

$QEMU -kernel ${RPI_KERNEL_FILE} \
    -cpu arm1176 -m 256 -M versatilepb \
    -dtb ${PTB_FILE} -no-reboot \
    -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
    -drive "file=${RPI_FS},index=0,media=disk,format=raw" \
    -net user,hostfwd=tcp::5022-:22 -net nic

What I did was modify the QEMU source to add support for RPi Zero W recompile. https://github.com/igwtech/qemu

  • 3
    Please be more specific than "I did some modifications"! – MatsK Apr 10 '20 at 16:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.