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

28Jan/1220

Setting up a VM for Raspberry Pi development using Virtualbox, Scratchbox2 & qemu (Part 3)

I don't claim that the following is the best way to install scratchbox2, qemu and a seed rootfs and configure them to produce binaries that will run on the real Raspberry Pi hardware. I don't even claim it is the correct way but it works for me and I can almost do it in my sleep by now. The way I do things will probably seem a bit inefficient and in some cases just plain wrong but it's how I work and hopefully they are easy to follow and adapt to your style of working. I also make no guarantees that it will actually work for you at all. Hopefully it will but if it doesn't sorry but oh well. I made the decision when I first started building the development vm that I would place all the required software under the users home directory rather than installing it globally as

  1. Installing in subdirectories in the user's home directory makes it easy  to keep things organised.
  2. It makes things almost idiotproof when you want to upgrade the ARM toolchain, scratchbox2, qemu or change the seed rootfs etc. as it's pretty much just rename the old directory, create a new directory and if neccessary rerun sb2-init.
Share
27Jan/120

Setting up a VM for Raspberry Pi development using Virtualbox, Scratchbox2 & qemu (Part 2)

If you decided to use a Debian or Ubuntu based distro then when you booted the Raspberry Pi Development VM that you just created you will have probably noticed an error message flash on the screen saying

 piix4_smbus 0000.00.07.0: SMBus base address uninitialized - upgrade bios or use force_addr=0xaddr

 

and you'll want to fix that before doing anything else. The Fedora16 VM doesn't produce this error so Fedora users can skip straight to the guest addition installation instructions. I wrote a short post about this error last year but to save you having to go there to read that post the fix [Credit for that fix goes to http://finster.co.uk & Karl Foley] is:

  • Start a terminal
  • sudo vi /etc/modprobe.d/blacklist.conf
  • Add the line blacklist i2c_piix4 to the end of the file and save
  • sudo update-initramfs -u -k all
  • sudo reboot
Share
27Jan/121

Setting up a VM for Raspberry Pi development using Virtualbox, Scratchbox2 & qemu (Part 1)

Last week I released version 0.2 of the Raspberry Pi development VM and I thought that I could safely call it a day because in a few weeks the Raspberry Pi hardware will be available and therefore we will no longer need the VM for software development. So yesterday I announced on this blog and the Raspberry Pi forums  that I had decided to EOL the VM and would no longer be updating it as I didn't see the need and i'm not going to have the time to maintain it for the next few months as it takes about 12 to 14 hours to create, configure and upload, 8 to 10 hours of that is uploading using all my upstream bandwidth which is no longer feasible for me to do again until after June.

However, almost immediately after posting that I started to receive tweets and PM's asking me not to stop working on the VM or to at least write detailed instructions on how to create your own VM for Raspberry Pi (or other ARM based devices) from scratch. Yesterday I also finally managed to get SDL programs working correctly, not that I had actually tried that hard previously as the majority of software I was personally interested in building and porting  to the Raspberry Pi are text based and at most use ncurses. So although I really won't have time to work on upgrading, tweaking and maintaining the VM personally I have decided that it should continue to live in the form of detailed instructions on how to create your own Raspberry Pi development VM, which is almost mostly transferable to other ARM based devices as well, it's actually pretty much transferable to any device that qemu will emulate but that is beyond the scope of this how-to.

Share
20Jan/1215

New Raspberry Pi development vm version 0.2

[update (11/3/12): This version is now out of date. Please use v0.8 the torrent of which is at http://downloads.raspberrypi.org/tools/ukscone/RaspberryPi-Development%20VM%20v0.8/RaspberryPi-Development%20VM%20v0.8.torrent The readme http://downloads.raspberrypi.org/tools/ukscone/RaspberryPi-Development%20VM%20v0.8/README.txt and the sha1 http://downloads.raspberrypi.org/tools/ukscone/RaspberryPi-Development%20VM%20v0.8/RaspberryPi-Development%20VM%20v0.8.ova.sha1 ]

[update: There is a tiny little buglet in the vm that slipped passed me as it didn't crop up when I was testing that yum worked as I didn't install a library that needed to go in the top level of the rootfs. If you get a lot of errors about unpacking or mkdir... when trying to install something using yum then you'll need to do the following

cd $HOME/raspberry_pi_development/f13arm_rootfs
sudo chmod -R 777 *

and that should fix it. sorry about that.

the torrent is now available.]

I have put together a new VM for developing software for the Raspberry Pi. I've made a few tweaks and cleaned up a lot of stuff and it's a much more pleasant setup and easier to use and update without making a whole new VM. I also used fedora13 for ARM as the seed rootfs so it should be possible to just swap files from/to a real Raspberry Pi and it should just run and you can update the seed rootfs as well (hopefully I guessed Raspberry Pi standardized educational disto correctly). I was planning to use fedora16 as the guest OS in the VM but after struggling with some of it's foibles for several hours and having to rebuild it a few times i gave up and reverted back to a ubuntu based release. it's currently compressing and uploading and with my upstream speed being so rubbish it'll take about 8 to 18 hours to finish but once it is finished i'll post a link to it and hopefully someone will make a torrent of it.

http://russelldavis.org/RaspberryPi/raspberrypi_dev_vm_02.torrent

Below is the README that is included with the exported appliance.

-------

RaspberryPi Development Virtual Machine 0.2

This is an exported virtualbox virtual machine for developing software for
the RaspberryPi. It is setup using the git versions of scratcbox2 & qemu (19/01/12), the fedora 13 for ARM as rootfs seed & arm-2011.03 codesourcery toolchain.

The root password is toor and the username and password for the normal user
is raspberry/password

To compile software for the raspberrypi as you would normally on an x86 machine
prefixing sb2 to any command. e.g. instead of gcc hello.c -o hello you would type sb2 gcc hello.c -o hello

To update, install or remove libraries and software in the seed rootfs use the command sb2 -eR yum ... where update, install, remove etc.

If you want to build and install libraries to use when building other software
that are not availble via fedora yum then rather than prefixing with sb2 prefix the command with sb2 -eR e.g. sb2 -eR make && make install

You can upgrade scratchbox2, qemu, the rootfs or toolchain quite easily as they are all in seperate dirs inside the raspberry_pi_development directory. it shoudl be possible to just swap them out when/if you need/want.

I have installed apache2 adn linked the $HOME/build directory so you can download anything you build to another system. You will probably want to change the network settings for the VM from NAT to Bridged though.

An ssh server is also installed so you can ssh in to the vm if you want as well (same proviso as above though. You'll need to change from NAT to Bridged to get it working).

If you have any other questions about the VM then you can send them via my blog (http://russelldavis.org) or post on the raspberry pi forum. (http://raspberrypi.org)

I have added one of my favourite bash aliases to the .bashrc doch is very handy in case you forget to use the sudo prefix to a command. just type doch and it'll redo the command but with sudo added.

Russell Davis (ukscone) 20/01/12

Share
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