= render "pages/arm/menu" %h1= title "How to configure Qemu" %h2 Target Pi on Mac %p So even the idea is to run software on the Pi, not everyone has a Pi (yet :-) %p Others, like me, prefer to develop on a laptop and not carry the Pi around. %p For all those, this here explains how to emulate the Pi on a Mac. %p Even if you have a Pi, =link_to "this explains", "remote_pi.html" a nice way to develop with it. %p We'll more or less follow a =ext_link "blog post", "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/" i found, with small additions. %h3 Qemu %p Get the Qemu. There may be other emulators out there, and i have read of armulator, but this is what i found described and it works and is “easy enough”. %pre %code :preserve brew install qemu %h3 Pi images %p Create a directory for the stuff on your mac, ie pi. %pre %code mkdir pi pi is in the gitignore, and the scripts in bin, will assume pi. %p Get the latest Raspian image. The =ext_link "lite version" "https://www.raspberrypi.org/downloads/raspbian/" without Gui is fine, and smaller. %p Change the file format with something like: %pre %code qemu-img convert -f raw -O qcow2 2017-08-16-raspbian-stretch-lite.img raspbian-stretch-lite.qcow So we can then resize the file, without it taking extra space %pre %code qemu-img resize raspbian-stretch-lite.qcow +6G Put the resulting file into the pi directory. %h3 Kernel %p One still needs a kernel (even there is one on the image?), and Druv kindly keeps a repository of them. Since we downloaded the stretch image, grap the =ext_link "stretch kernel" , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.9.59-stretch" and also the mysterious =ext_link "tdb file." , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb.dtb" Both go into the pi directory. %h3 Boot %p There is quite a bit to the command line to boot the pi. There is a script in the bin directory, but here it is: %pre %code :preserve qemu-system-arm -kernel pi/kernel-qemu-4.9.59-stretch -dtb pi/versatile-pb.dtb -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda pi/raspbian-stretch-lite.qcow -net nic -net user,hostfwd=tcp::2222-:22 %ul %li the cpu is what broadcom specifies, ok %li memory is unfortunately hardcoded in the versatilepb “machine” %li the kernel is the file name of the kernel you downloaded (or extracted) %li raspbian.img is the image you downloaded. Renamed as it probably had the datestamp on it %li the "-net user,hostfwd=tcp::2222-:22" redircts the port 2222 to let you log into the pi %p So %pre %code :preserve ssh -p 2222 -l pi localhost %p will get you “in”. Ie username pi (password raspberry is the default) and port 2222 %p Qemu bridges the network (that it emulates), and so your pi is now as connected as your mac. %h3 Working on the pi %p You'll probably want to log in by ssh at some point. If for no other reason than Ctl-C will stop the emulator when you are logged in, and not the program you are running on the emulator. This gets old _really_ quickly. %p To configure the ssh server on the pi, log in and run %pre %code sudo raspi-config and enable ssh in the interface options. There is another text on how to =link_to "work on" , "/arm/remote_pi.html" the pi. Off course google is good , and raspian site can help too. %h2#links Links %ul#selector %li=ext_link "Post used for instructions", "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/" %li=ext_link "stretch kernel" , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.9.59-stretch" %li=ext_link "Rasbian image file", "http://www.raspberrypi.org/downloads/"