Last active
March 24, 2024 14:36
-
-
Save JasonGhent/e7deab904b30cbc08a7d to your computer and use it in GitHub Desktop.
OSX raspberry pi emulation via QEMU. v2 attempt @ https://gist.github.com/JasonGhent/922f38f57c8cb77b10f3
This file contains 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
# pulled from http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/ | |
# expanded via http://superuser.com/questions/690060/how-to-enable-network-with-a-raspberry-pi-emulated-on-qemu | |
# tested with 2015-02-16-raspbian-wheezy.zip on OSX Mavericks | |
# OSX terminal | |
brew install qemu | |
# kernel-qemu is a linux kernel compiled with ARM1176 support. | |
# learn more here: http://xecdesign.com/compiling-a-kernel/ | |
curl -OL http://xecdesign.com/downloads/linux-qemu/kernel-qemu | |
curl -o raspbian_latest.zip -L http://downloads.raspberrypi.org/raspbian_latest | |
unzip raspbian_latest.zip | |
mv 20* raspbian_latest.img | |
# not easily possible to mount ext4 to make the following change to the image, so we load the filesystem by running the image | |
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda raspbian_latest.img | |
# QEMU window (guest) - spawned by previous line | |
sed -i -e 's/^/#/' /etc/ld.so.preload | |
# TODO: clean this up with a bash var for path | |
touch /etc/udev/rules.d/90-qemu.rules | |
echo 'KERNEL=="sda", SYMLINK+="mmcblk0"' >> /etc/udev/rules.d/90-qemu.rules | |
echo 'KERNEL=="sda?", SYMLINK+="mmcblk0p%n"' >> /etc/udev/rules.d/90-qemu.rules | |
echo 'KERNEL=="sda2", SYMLINK+="root"' >> /etc/udev/rules.d/90-qemu.rules | |
exit | |
# OSX terminal (host) | |
# start the final raspberry pi image and specify a network mapping | |
# of local port 5022 to the pi's port 22 | |
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda raspbian_latest.img -redir tcp:5022::22 | |
# QEMU (guest) - raspberry pi emulation | |
# @FIXME | |
# for some reason it drops out of the startup procedure | |
# and dumps you to the terminal prematurely | |
exit | |
# if this is not first-run, we are done.. | |
# else we are ushered into raspi-config (first run only) | |
# select "Finish" when done configuring | |
# OSX terminal (host) | |
ssh -p 5022 pi@localhost | |
# If we want to create a Heroku-like atmosphere, we can do | |
# with Dokku | |
## Still figuring this part out.. |
I wanna ask how to make the network able to work : (
Hello guys! Check this project out: Raspi Simulator (not mine). If you see in package contents, its all shell scripts in a wrapper.
I wasn't able to get a working init
using this process. I had more luck with these instructions, although they are incomplete, and I don't have permission to edit the page. I had to mount the Ubuntu cloud image using qemu-nbd xenial-server-cloudimg-arm64-uefi1.img --connect=/dev/nbd0
and manually add a password for the ubuntu
account as shown here, and wait for cloud-init to time out, before I could log into the machine and apt remove cloud-init
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mariohmol update image, edit
/etc/ld.so.preload
and comment line#/usr/lib/arm-linux-gnueabihf/libarmmem.so
source: http://blog.3mdeb.com/2015/12/30/emulate-rapberry-pi-2-in-qemu/