Jump to content

Welcome, Guest!

twiq

A Raspberry Pi emulated environment on OSX Lion

Recommended Posts

A Raspberry Pi emulated environment on OSX Lion


To set up an emulated environment of the Raspberry Pi software on OSX one will need:
  1. A Cross-Compiling Tool for the CPU architecture of RPi. ( eg. ARM EABI Toolchain )
  2. The RPi Kernel.
  3. The RPi root filesystem.
  4. The Emulator (QEMU).

  • 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...

168875_3816411726685_337207833_n.jpg

Happy hacking kids!


 

Share this post


Link to post
Share on other sites

Sincerely, I don't have any idea on how it could work on windows. I've ordered my tiny computer already, but couldn't wait for it to mess up with configurations and kernel tweaking! :P

Share this post


Link to post
Share on other sites

Sincerely, I don't have any idea on how it could work on windows. I've ordered my tiny computer already, but couldn't wait for it to mess up with configurations and kernel tweaking! :P

 

Congrats. I think maybe it could work over Virtual Machine or something.

 

What's the ETA of your Pi?

Share this post


Link to post
Share on other sites

Congrats. I think maybe it could work over Virtual Machine or something.

 

What's the ETA of your Pi?

 

Ordered it 3 days ago. 11 weeks until dispatch. :)

Share this post


Link to post
Share on other sites

Hi! I've been working my way through the tutorial today. Thanks for putting it together, I wouldn't even have known where to start!

 

Unfortunately, I'm ending up building a version of qemu which hangs on the initial white screen. I'm pretty sure homebrew is passing the correct flags for gcc to ./configure for qemu: I can see this on the console just before homebrew runs make:

 

==> ./configure --prefix=/usr/local/Cellar/qemu/1.3.0 --cc=/usr/bin/gcc-4.2 --host-cc=/usr/bin/gcc-4.2 --enable-cocoa --

 

But still the hang when I run qemu :( Any obvious gotchas I might be falling over?

Share this post


Link to post
Share on other sites

When I build using

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

I get this error:

scripts/link-vmlinux.sh: line 44: ~/rpi/arm-cs-tools/bin/arm-none-eabi-ld: No such file or directory

make: *** [vmlinux] Error 1
make: Target `_all' not remade because of errors.
 
But the file ~/rpi/arm-cs-tools/bin/arm-none-eabi-ld is there
Can anyone help ?
Tx

Share this post


Link to post
Share on other sites

I tried to setup everything according to the description above but ran into a compilation issue when executing 

PREFIX=$HOME/rpi/arm-cs-tools make install-cross

 

The error message that is coming up is:

gcc -DHAVE_CONFIG_H     -DPROFILE=1 -DWITH_PROFILE=-1          -DDEFAULT_INLINE=0           -DMODET -DNEED_UI_LOOP_HOOK -DSIM_TARGET_SWITCHES   -I. -I../../../../gdb-2013.05/sim/arm -I../common -I../../../../gdb-2013.05/sim/arm/../common -I../../include -I../../../../gdb-2013.05/sim/arm/../../include -I../../bfd -I../../../../gdb-2013.05/sim/arm/../../bfd -I../../opcodes -I../../../../gdb-2013.05/sim/arm/../../opcodes -I../../intl -g -O2 -c -o thumbemu.o -MT thumbemu.o -MMD -MP -MF .deps/thumbemu.Tpo ../../../../gdb-2013.05/sim/arm/thumbemu.c
../../../../gdb-2013.05/sim/arm/armsupp.c:639:7: error: non-void function 'ARMul_MRC' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.
make[4]: *** [armsupp.o] Error 1
make[4]: *** Waiting for unfinished jobs....
1 warning generated.
3 warnings generated.
3 warnings generated.

 

I'm on OS X 10.8.5 Build 12F37 using XCode 5.0 (5A1413) with Command Line Tools installed.

 

Has anyone encountered a similar issue and knows how to fix this?

 

Thanks for your support.

Share this post


Link to post
Share on other sites

Just to know whether there is a solution for Snow Leopard? it doesnt work on mine without any error message / feedback.

 

click

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

About Us

Bringing you the latest Raspberry Pi news, tutorials and user forum.

The Fruity Computer

×