Executing Gummiworms The trials and tribulations of a grumpy curmudgeonly old git

10Sep/1122

Virtualbox VM for RaspberryPi development

[update: this vm is obsolete. please use the one in the follow post http://russelldavis.org/2012/01/20/new-raspberry-pi-development-vm-v0-2/ ] I am currently in the process of uploading a have uploaded created virtual machine running debian with lxde in which I have installed and configured scratchbox2, qemu and the codesourcery toolchain so that it is possible to build software for the RaspberryPi (although noone actually has one other than the lucky few developers that have access to a alphaboard).

The vm file will be is available from about (it's about 1.3GB so is about 7 hours from completing the upload)  11pm 10/09/11 (uk date format) at http://russelldavis.org/RaspberryPi/RaspberryPi.zip and as a torrent (created by #raspberrypi user obarthelemy)

http://thepiratebay.org/torrent/6667294

http://www.demonoid.me/files/details/2726361/

Although this virtual machine is meant to be used for developing for the RaspberryPi it should be usable for any ARM based device especially if you have a rootfs from the device that you can use to seed the scratchbox2 environment (see http://russelldavis.org/2010/10/20/setting-up-scratchbox2-to-build-software-for-zubuntu/ & http://russelldavis.org/2010/11/03/mounting-a-raw-disk-image/ & http://russelldavis.org/2011/09/07/setting-up-scratchbox2-from-scratch-for-the-raspberry-pi/ ).

I did forget a couple of important things in the included README. I have installed apache2 and symbolic linked $HOME/raspberrypi-development/build into /var/www and you should build everything in (or under) the $HOME/raspberrypi-development/build directory.

Share
7Sep/1110

Setting up Scratchbox2 from scratch (for the Raspberry Pi)

It has been confirmed that binaries built using this method will run on real Raspberry Pi hardware (alphaboard).

Below is the method i used to setup Scratchbox2. I am doing this using a Ubuntu 11.4 virtual machine in VirtualBox. It works for me but YMMV.

Because the version of Scratchbox2 and qemu available in the Ubuntu repositories are pretty old and the version of qemu available doesn't have support for the arm1176 I am going to use the git versions of qemu and Scratchbox2.

mkdir RaspberryPi
cd RaspberryPi
git clone git://gitorious.org/scratchbox2/scratchbox2.git
git clone git://git.qemu.org/qemu.git

 

You'll also need an ARM toolchain. Unless you want to build your own ARM toolchain you'll want to download the codesourcery ARM toolchain. https://sourcery.mentor.com/sgpp/lite/arm/portal/release1803

cd ~/RaspberryPi
wget https://sourcery.mentor.com/sgpp/lite/arm/portal/package8739/public/arm-none-linux-gnueabi/arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
tar xjvf arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

 

You will now have the codesourcery ARM toolchain in the directory ~/RaspberryPi/arm-2011.03

Now that you have a toolchain available it's time to build Scratchbox2 and qemu. Earlier you cloned the latest git versions available and if you haven't already got them installed you'll need to install "fakeroot" and "realpath" using your distributions package management system. To build and install Scratchbox2.

cd ~/RaspberryPi/scratchbox2
mkdir ../sb2
./autogen.sh
make install prefix=$HOME/RaspberryPi/sb2

Then build and install qemu

cd ~/RaspberryPi/qemu
./configure --prefix=$HOME/RaspberryPi/sb2 --target-list=arm-linux-user
make && make install

Now that your toolchain, scratchbox2 and qemu are installed you'll need to seed your development environment with some libs, include files and binaries and initilize Scratchbox2

mkdir ~/RaspberryPi/devel
cd ~/RaspberryPi/devel
export PATH=$HOME/RaspberryPi/sb2/bin:$PATH
cp -a ~/RaspberryPi/arm-2011.03/arm-none-linux-gnueabi/libc/{lib,etc,usr} .
sb2-init Raspi $HOME/RaspberryPi/arm-2011.03/bin/arm-none-linux-gnueabi-gcc
This will generate a working target configuration. If anything fails you can redo it again manually after fixing the problem.

You'll probably want to add

export PATH=$HOME/RaspberryPi/sb2/bin:$PATH

to your .bashrc as well

Now you have a working cross compile environment for the RaspberryPi (it isn't optimised or tweaked for the hardware but it's good enough for now and can be improved at a later date when we have more details about the hardware in particular the GPU and CPU).

To actually test that everything is working correctly write a small program (a hello, world program is a good choice).

raspberry@raspberrypi-VirtualBox:~/RaspberryPi/devel$ gcc hello.c -o hello
raspberry@raspberrypi-VirtualBox:~/RaspberryPi/devel$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
raspberry@raspberrypi-VirtualBox:~/RaspberryPi/devel$ sb2 gcc hello.c -o hello
raspberry@raspberrypi-VirtualBox:~/RaspberryPi/devel$ file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
raspberry@raspberrypi-VirtualBox:~/RaspberryPi/devel$ sb2 ./hello
hello, world
If you have any questions you can find me on the raspberrypi forum, the irc channel or contact me via this blog.

[Addendum: Instead of seeding usign the libs and include files etc. from the codesourcery toochain you can use a rootfs of any ARM based distro. Just download an ARM rootfs from somewhere (exercise left for the user) and as root extract it into the ~RaspberryPi/devel directory and then chown -R user ~/RaspberryPi/devel and chgrp -R user ~/RaspberryPi/devel -- If you user a debian based rootfs (squeeze) the you can use apt to update and upgrade the files in the rootfs using the command

sb2 -eR apt-get update
sb2 -eR apt-get upgrade

]

 

Share