Live data from Hacker News

How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

gist.github.com

11–20 of 27 posts

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#11
post #7
post #6

Earlier quoted context omitted.

Am I misreading or are you chrooting to an x86 build of Raspbian?

Good observation :) it's the raspbian arm build -- you are chroot-ing into the exact SD card that you put into the Pi. I don't know how exactly this sorcery works either. But I think chroot just "knows" that it needs to invoke qemu when it sees the binfmt of /bin/bash being arm.

If you read the script, it copies the relevant qemu binary on line 52 to the chroot's /usr/bin/.

What's happening here is binfmt-support on the host has a path registered for arm binaries as the file you just copied to /usr/bin - whenever the chroot tries to run anything, the host directs it to this bianry which is your arm emulator :).

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#12
post #11
post #7

Earlier quoted context omitted.

Good observation :) it's the raspbian arm build -- you are chroot-ing into the exact SD card that you put into the Pi. I don't know how exactly this sorcery works either. But I think chroot just "knows" that it needs to invoke qemu when it sees the binfmt of /bin/bash being arm.

If you read the script, it copies the relevant qemu binary on line 52 to the chroot's /usr/bin/. What's happening here is binfmt-support on the host has a path registered for arm binaries as the file you just copied to /usr/bin - whenever the chroot tries to run anything, the host directs it to this bianry which is your arm emulator :).

That's an awesome explanation - thanks! I just copied and pasted from other people's code and prettified it a bit so it's easier to use, but I didn't really understand why it worked. Now I do a bit better.

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#13
post #9
post #2

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/files…

Do you know which RPis used this CPU? Just the original? I'm looking for a way of emulating a RPi2/3 so I can run the arm version of Ubuntu Mate. Any idea if a method like this will work for me?

[deleted]

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#14
post #4

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 scri…

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).

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#16
post #8
post #2

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/files…

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

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...

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#18
post #4

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 scri…

Thank you! I'm developing a project involving rpi0 now; this will simplify things so much!

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#19
post #9

Earlier quoted context omitted.

Do you know which RPis used this CPU? Just the original? I'm looking for a way of emulating a RPi2/3 so I can run the arm version of Ubuntu Mate. Any idea if a method like this will work for me?

Only the original, and the Zero(W). RPi2/3 use ARMv7 and ARMv8 cores, much more mainstream so easier to simulate.

[deleted]

Re: How to Emulate a Raspberry Pi (Raspbian Jessie) on Mac OS X

#20
post #8

Earlier quoted context omitted.

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

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...

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

https://github.com/bztsrc/qemu-raspi3

Post reply on HN