To get started make sure you have the following items installed in your development environment. At the time of this writing I am running Xcode v5.02 on OS X 10.9 Mavericks.
QEMU is a generic and open source machine emulator and virtualizer. QEMU will allow us to emulate the ARM environment that is needed to run the version of Debian Linux for the Raspberry Pi called Raspbian. This is not specific to Raspbian and you can use QEMU to run other ARM environments or virtualize other architecture. Lets get started.
Update Brew Formulae (Optional):
The default gcc compiler that is part of Mavericks throws errors when building QEMU. If you attempt to install QEMU in Homebrew with Xcode 5 you may get the following errors.
Mavericks gcc compile error:
To get around this we are going to install
gcc-4.2 with Homebrew and use that version to install QEMU. This will not have any effect on your default gcc compiler.
Now we can install QEMU without issue using the
Install QEMU (Note the gcc-4.2 flag):
At this point you may want to crete a working directory that will store the kernel image and the Raspbian image. This next step will be slightly different for everybody depending on your directory location. I am using
Make a working directory for kernel and Raspbian images:
Grab the Linux kernel:
Download the latest Raspbian binaries and unzip to the same directory
~/dev/rpi/ in my case. At the time of writing the latex Raspbian image is
Booting the Machine
We are going to run a first boot to help complete the initial Pi setup and to add a better resolution to work in with Xorg. I am borrowing most of the information in this step from Here and for the Xorg tweak from this post here.
Upon initial boot you may be prompted to complete the initial setup. Just follow the instructions, no changes necessary. When complete you should be kicked out to the terminal shell with a root prompt. We are going to comment out one line in
/etc/ld.so.preload. In the shell type the following:
Comment out the one line below by putting a
# in front of the line.
To save the file in nano hit
Ctrl+X and then
Enter to save file. We are going to make a couple more edits. Back in the shell do the following:
This will create a new file so it should be blank. Add the following lines to the file, save and close out.
Now we can add the following lines to
/etc/X11/xorg.conf to bump up the resolution to 800x600. Use nano again to edit
xorg.conf and add the following:
xorg.conf you can safely shutdown the machine at this point:
Now we can boot up a second time and we are ready to go. If you opted to not boot to a graphical interface in the initial setup in the first boot step you can load the graphical interface by entering
startx at the shell after the boot up completes.
To boot the machine for the second time, and subsequently thereafter: