
How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X - hfreire
https://gist.github.com/hfreire/5846b7aa4ac9209699ba
======
pm215
I think it's worth noting that this isn't actually emulating a Raspberry Pi.
The option "-M versatilepb" to QEMU tells it to emulate a VersatilePB, which
is an Arm development board that's now a decade or more old. It happens that
this can be set up to use an ARM1176 CPU, which is the same as the one in the
RPi. So you can run a kernel built for the VersatilePB on a VersatilePB model,
and use the same userspace/filesystem as the RPi, provided that your userspace
doesn't rely on any particular characteristics of the rpi hardware beyond the
CPU type. Luckily for most uses that's close enough...

~~~
moyix
Also (and I know you know this, pm215) you can actually emulate a Raspberry Pi
2 machine (i.e. the bcm2836 SoC) in recent versions of QEMU with the "raspi2"
machine type. There are instructions that worked for me here:

[https://raspberrypi.stackexchange.com/a/71172](https://raspberrypi.stackexchange.com/a/71172)

~~~
thisacctforreal
Any idea of a raspi3 machine type in the works? or where to contribute to one?

It has a BCM2837, which has a 64-bit ARM CPU Core, and 400MHz VideoCore IV
versus 250MHz in the raspi2.

A comparison table can be found by searching "What is new" in
[https://media.digikey.com/pdf/Data%20Sheets/Seeed%20Technolo...](https://media.digikey.com/pdf/Data%20Sheets/Seeed%20Technology/Raspberry_Pi_3_Model_B_WikiWeb.pdf)

~~~
moyix
I don't know, but a quick google search finds:

[https://github.com/bztsrc/qemu-raspi3](https://github.com/bztsrc/qemu-raspi3)

------
jimmies
On Linux, it's even easier (lol, who would have guessed?).

I recently had the need to compile quite a bit of software to run on the Pi
zero, and the ability to be able to "chroot" to the Pi on my PC has made the
experience so much more pleasant. Everything compiles ten times faster!

I also noticed that none of the available guides work well with Ubuntu 17.04
(and possibly newer/older), so I put together a simple script to do that on
Ubuntu for anyone who is interested. It will always work when you chroot on
the sdcard:

[https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e4...](https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e436eb)

You can theoretically chroot into the image directly, but the resizing the
partitions operation is unreliable on the host for some reason, and it might
cause the image to not be bootable. I've found myself better off booting the
sd card once with the vanilla image on the Pi first so it resizes itself
before chrooting into the SD card.

~~~
kingosticks
I had this problem with my similar script until I added 'sync; sleep 1;
partprobe' after the writing the new partition information (before running
e2fsck).

~~~
jimmies
Great, I will check it out :)

------
stuaxo
As mentioned below newer versions of QEMU can emulate the CPUs in newer Pis.

The main thing missing is proprietary graphics API "dispmanx".

I didn't try and emulate the GPIO, but assume that is also not possible ?

------
nly
I've looked in to this before to build rPi binaries on a more powerful x86
machine, but i've never been able to get Jenkins/Java running under QEMU

~~~
ChickeNES
Why do you need Jenkins running in QEMU? Just use this:
[https://hub.docker.com/r/sdthirlwall/raspberry-pi-cross-
comp...](https://hub.docker.com/r/sdthirlwall/raspberry-pi-cross-compiler/)

------
ramconx
why this old version of raspbian?
[https://downloads.raspberrypi.org/raspbian/images/](https://downloads.raspberrypi.org/raspbian/images/)

~~~
jimmies
From what I see from the script, the version of the raspbian distro shouldn't
matter that much. The kernel should be compatible.

