This guide explains how to emulate a Raspberry Pi and its ARM-based hardware stack under macOS Mojave – running the recent Raspbian Buster 1.
The light QEMU open-source Quick Emulator framework, will be used.
Homebrew as well as some basic level shell-fu is required.
- Installing required Software
- Create the System Disk Image
- Running QEMU
- Fixing the System Partition Layout
- Author
Create a working directory at /Users/username/qemu
.
$ mkdir ~/qemu
Open a Terminal and install Homebrew
.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install qemu
via Homebrew.
$ brew install qemu
Grab the operating system by downloading 3 separate components: Kᴇʀɴᴇʟ, Sʏsᴛᴇᴍ Iᴍᴀɢᴇ und Dᴇᴠɪᴄᴇ Tʀᴇᴇ Bɪɴᴀʀʏ.
$ cd ~/qemu
$ curl --remote-name-all --location \
https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.14.79-stretch \
https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb.dtb \
https://downloads.raspberrypi.org/raspbian/images/raspbian-2019-07-12/2019-07-10-raspbian-buster.zip
Unpack the operating system disk image.
$ unzip ~/qemu/2019-07-10-raspbian-buster.zip
Increase the disk size to 8GB (or larger – as required).
$ qemu-img resize -f 'raw' ~/qemu/2019-07-10-raspbian-buster.img '8G'
Start QEMU by running `qemu-system-arm.
$ qemu-system-arm \
-kernel ~/qemu/kernel-qemu-4.14.79-stretch \
-dtb ~/qemu/versatile-pb.dtb \
-drive file=~/qemu/2019-07-10-raspbian-buster.mod.img,index=0,media=disk,format=raw \
-cpu 'arm1176' \
-m '256' \
-M 'versatilepb' \
-serial 'mon:stdio' \
-net 'nic' \
-net 'user,hostfwd=tcp::5022-:22' \
-append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' \
-no-reboot \
-vga 'std'
When the boot process concludes after a few minutes, log in using the default credentials:
- user:
pi
, password:raspberry
).
In order to access the entirety of the free space just assigned to the disk image, its operating system needs to know about it. We'll now slightly adjust the filesystem partition layout from within the emulator, using the
raspi-config
utility .
By default,
raspi-config
refuses its service because it cannot find any SD-card based filesystems (the Pi's main means of storage). Thus, we'll apply a small tweak to make it comply.
Create a backup of raspi-config
:
$ cp -v /usr/bin/raspi-config /usr/bin/raspi-config.backup
Find all textual occurences to SD-card-type filesystems (/dev/mmcblk0p
) within /usr/bin/raspi-config
and replace them with references to the standard filesystem type, /dev/sda
:
$ sed -E 's/mmcblk0p?/sda/' /usr/bin/raspi-config
Now, start raspi-config
:
$ sudo /usr/bin/raspi-config
Within raspi-config
...
-
Select
[Aᴅᴠᴀɴᴄᴇᴅ Options]
, then[Exᴘᴀɴᴅ Fɪʟᴇsʏsᴛᴇᴍ]
, then confirm. -
Wait until after the resizing process has finished.
-
Select
[Qᴜɪᴛ]
and confirm the reboot request.
Any suggestions? Drop me an e-mail, create a document fork or
Copyright © 2019 sidneys.
Licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.