Created
December 30, 2020 10:51
-
-
Save developer-guy/1be5b552e97fa31321092dfb29929e38 to your computer and use it in GitHub Desktop.
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (Sierra)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Homebrew | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# Install QEMU OSX port with ARM support | |
brew install qemu | |
export QEMU=$(which qemu-system-arm) | |
# Dowload kernel and export location | |
brew install wget | |
wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.4.34-jessie | |
export RPI_KERNEL=./kernel-qemu-4.4.34-jessie | |
# Download filesystem and export location | |
wget http://downloads.raspberrypi.org/raspbian/images/raspbian-2016-11-29/2016-11-25-raspbian-jessie.zip | |
unzip 2016-11-25-raspbian-jessie.zip | |
export RPI_FS=./2016-11-25-raspbian-jessie.img | |
# Tweak filesystem: start qemu with init flag, switch to guest window to execute tweak and close window afterwards | |
$QEMU -kernel $RPI_KERNEL \ | |
-cpu arm1176 -m 256 \ | |
-M versatilepb -no-reboot -serial stdio \ | |
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" \ | |
-drive "file=$RPI_FS,index=0,media=disk,format=raw" | |
sed -i -e 's/^/#/' /etc/ld.so.preload | |
sed -i -e 's/^/#/' /etc/fstab | |
# Emulate Raspberry Pi | |
$QEMU -kernel $RPI_KERNEL \ | |
-cpu arm1176 -m 256 \ | |
-M versatilepb -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 | |
# Login to Raspberry Pi | |
ssh -p 5022 pi@localhost | |
# Referenced from OSX raspberry pi emulation via QEMU - https://gist.github.com/JasonGhent/e7deab904b30cbc08a7d | |
# Referenced from Emulating Jessie image with 4.x.xx kernel - https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.x.xx-kernel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment