Jump to content

Welcome to Raspberry Pi Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

Tutorial info Visit support topic

  • Added on: Jul 15 2012 09:26 PM
  • Views: 11432
 


* * * * *
1 Ratings

A Raspberry Pi emulated environment on OSX Lion

This tutorial sets up a cross compilation and emulation environment for the ARM architecture and the Raspberry Pi root filesystem.

Posted by twiq on Jul 15 2012 09:26 PM
To set up an emulated environment of the Raspberry Pi software on OSX one will need:
  • The Cross-Compiling Tool for the ARM architecture.
Assuming one already have the latest Xcode and command line tools from Apple Developer and homebrew installed, then should install the dependencies:

brew install mpfr gmp libmpc libelf texinfo

Grab and compile the tool:

mkdir ~/rpi
mkdir ~/rpi/arm-cs-tools
git clone https://github.com/jsnyder/arm-eabi-toolchain.git
cd arm-eabi-toolchain
PREFIX=$HOME/rpi/arm-cs-tools make install-cross
make clean
echo “export PATH=$HOME/rpi/arm-cs-tools/bin:$PATH” » ~/.bash_profile
  • The RPi Kernel Compilation
mkdir ~/rpi/kernel
cd ~/rpi/kernel
git clone https://github.com/raspberrypi/linux.git
cd linux

Grab the config file and configure the kernel:

cp arch/arm/configs/bcmrpi_cutdown_defconfig .config
make ARCH=arm CROSS_COMPILE=~/rpi/arm-cs-tools/bin/arm-none-eabi- menuconfig

Save the configuration and let’s build the kernel afterwards. Note that the compilation should fail and complain about an <elf.h> inclusion in scripts/mod/mk_elfconfig. If it does, one must create the file:

sudo touch /usr/local/include/elf.h

Edit it and write the following:


#include <libelf.h>

#define R_386_NONE 0
#define R_386_32 1
#define R_386_PC32 2
#define R_ARM_NONE 0
#define R_ARM_PC24 1
#define R_ARM_ABS32 2
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6


and follow through the building process:


make ARCH=arm CROSS_COMPILE=~/rpi/arm-cs-tools/bin/arm-none-eabi- -k


The image file is created and located as arch/arm/boot/zImage.
  • The Emulator
Due to a bug of a white screen hanging QEMU if compiled with llvm one must install the package apple-gcc42 from the homebrew’s dupes repository.

brew install homebrew/dupes/apple-gcc42

And then compile and install qemu like:

brew install qemu —use-gcc

Now we’re left with all we need to start the RPi distribution so let’s start it like:

qemu-system-arm -M versatilepb -cpu arm1176 -hda debian6-19-04-2012.img -kernel zImage -append “root=/dev/sda2” -serial stdio -usbdevice tablet

and...

Posted Image

Happy hacking kids! :)

Powered by Tutorials 1.5.1 © 2013, by Michael McCune