# Install QEMU OSX port with ARM support ``` /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew update && brew install qemu export QEMU=$(which qemu-system-arm) brew install wget ``` #### *get stretch kernel, device tree and raspbian image* ``` wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.9.59-stretch export RPI_KERNEL=./kernel-qemu-4.9.59-stretch wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb.dtb wget http://downloads.raspberrypi.org/raspbian/images/raspbian-2018-11-15/2018-11-13-raspbian-stretch.zip unzip 2018-11-13-raspbian-stretch.zip export RPI_FS=./2018-11-13-raspbian-stretch.img ``` #### *Here make sure to reference the .img file in the last EXPORT and not the .zip file as per original instructions.* #### *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 \ -dtb versatile-pb.dtb \ -M versatilepb \ -no-reboot -serial stdio \ -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" \ -drive "file=2018-11-13-raspbian-stretch.img,index=0,media=disk,format=raw" ``` #### *So at this point you should get the emulator window and a terminal you can add the following commands in.* ``` sed -i -e 's/^/#/' /etc/ld.so.preload sed -i -e 's/^/#/' /etc/ld.so.conf sed -i -e 's/^/#/' /etc/fstab ``` #### *Exit that and the next command will start the actual raspberry pi emulation.* # *Emulate Raspberry Pi* ``` $QEMU \ -kernel $RPI_KERNEL \ -cpu arm1176 -m 256 \ -dtb versatile-pb.dtb -M versatilepb \ -no-reboot -serial stdio \ -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \ -drive "file=2018-11-13-raspbian-stretch.img,index=0,media=disk,format=raw" \ -net user,hostfwd=tcp::5022-:22 -net nic ``` #### *Available over network with this SSH command.* #### **Login to Raspberry Pi** ``` ssh -p 5022 pi@localhost ```