Building AROS hosted for Raspbian

The Raspberry Pi platform really looks very suitable for running AROS. I wanted to play with this setup and build a Raspbian (armhf) release from source (so I can hack on if I like to). I chose the Linux hosted version of AROS as it is already available in the source tree and Raspi’s Linux kernel is a very good hardware abstraction layer for all Raspi peripherals. (The native Raspi AROS version exactly suffers from this: It has to implement all peripheral drivers that are already available in Linux – and that is a daunting task).

I had a look at the AROS Raspberry Pi Docs, but unfortunately the compilation details given there didn’t work for me. I have a xubuntu 12.04 VM running here on my Mac and it seems that this version does not support the multiarch compile given in the docs not very well… (I even had a quick check with the fresh release 13.04 but that one does not work either… so things don’t look good with this approach): The problem I encountered was that the multiarch setup does not allow to install libpng-dev for i386 and libx11-dev/libsdl-dev for armhf simulatenously. But both are required for a full compile of AROS…

I played around with the build process and found an own way to perform the build on my system. This post gives you the details…

Prerequisites

  • First prepare an (X)Ubuntu system on your PC or in a VM. I used version 12.04 and tested 13.04, but other debian-based releases should work, too
  • We’ll use a working directory typically in your home that is called $WORKDIR in the following. Make sure this directory exists and is empty:
export WORKDIR=<abs/path/to/your/work/dir>

1. Install base packages

  • You need the following local developer packages installed
> sudo apt-get install build-essential git-core flex bison netpbm autoconf \
                       debootstrap qemu-user-static schroot sudo python libsdl-dev

2. Clone AROS sources

  • I cloned the AROS sources from the Git repository as described in the EvilWiki
> cd $WORKDIR
> git clone git://repo.or.cz/AROS.git

3. Get the official Raspi cross-compiler

> mkdir $WORKDIR/raspi
> cd $WORKDIR/raspi
> git clone https://github.com/raspberrypi/tools.git

4. Install root file system of raspbian in Ubuntu

> cd $WORKDIR
> sudo qemu-debootstrap --arch armhf wheezy chroot-raspbian-armhf http://archive.raspbian.org/raspbian

5. Access raspbian root via schroot

  • We use a secure chroot to enter the raspbian root file system
  • This allows us to run an emulated ARM apt there and install/update packages
> sudo vi /etc/schroot/schroot.conf
  • Add the following to schroot config and expand the variables $WORKDIR and $USER!
[raspbian]
type=directory
directory=$WORKDIR/chroot-raspbian-armhf
users=$USER
root-users=$USER
aliases=default
  • Now you can enter the Raspbian root in a shell with:
> schroot -u root
(raspian)#
  • Setup packet management in raspian:
(raspbian)# vi /etc/apt/sources.list
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
  • Update packet list and install required target packets:
(raspbian)# apt-get update
(raspbian)# apt-get install libx11-dev libsdl-dev
(raspbian)# exit

6. Fix “sysroot” of cross compiler

  • The cross-compiler has its own sysroot. We’ll use the one of the rapsbian root file system to get all includes and libs installed there for the cross-compiler:
> cd $WORKDIR/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf
> mv libc libc.old
> ln -s $WORKDIR/chroot-raspbian-armhf libc

7. A fix for global /lib references

  • Some build steps refer to /lib/arm-linux-gnueabihf so let’s create this link and point into raspbian root
> cd /lib
> sudo ln -s $WORKDIR/chroot-raspbian-armhf/lib/arm-linux-gnueabihf

8. Convenience Link for Toolchain

  • With this link we can use raspi/bin to reach all commands of the toolchain
> cd $WORKDIR/raspi
> ln -s $WORKDIR/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin

9. Patch AROS

  • Current AROS trunk didn’t build out of box for me. Here is a fix.
  • Create a file raspi.patch with the following contents:
diff --git a/configure.in b/configure.in
index 07211d3..cd6fa26 100644
--- a/configure.in
+++ b/configure.in
@@ -1954,7 +1954,8 @@ AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),

 if test "$aros_kernel_includes" = ""; then
     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
-        aros_kernel_includes="-isystem $aros_target_incl"
+	kernel_tool_prefix_no_dash=`echo "$kernel_tool_prefix" | sed -e 's/-$//g'`
+	aros_kernel_includes="-isystem $aros_target_incl -isystem $aros_target_incl/$kernel_tool_prefix_no_dash"
     fi
 fi

@@ -1971,10 +1972,6 @@ if test "$aros_kernel_includes" != "" ; then
             if test -d "$aros_kernel_cc_includes"-fixed; then
                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
             fi
-            # Check for specific includes directory. Neede for Ubuntu 11.10
-            if test -d "/usr/include/i386-linux-gnu"; then
-                aros_kernel_cc_includes+=" -isystem /usr/include/i386-linux-gnu"
-            fi
         else
             # The directory doesn't exist, we need to do some more work.
             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
  • Now you can apply this patch to the source tree and regenerate the configure script:
> cd $WORKDIR/AROS
> patch -p1 < raspi.patch
> autoconf  # remake configure

10. Configure AROS Build

  • Configure the build system
> mkdir $WORKDIR/build
> cd $WORKDIR/build
> export PATH=$WORKDIR/raspi/bin:$PATH
> RASPBIAN_ROOT=$WORKDIR/chroot-raspbian-armhf
> ../AROS/configure --target=linux-armhf \
      --with-cpu=armv6 --with-fpu=vfp --with-float=hard \
      --x-includes=$RASPBIAN_ROOT/usr/include --enable-x11-hidd \
      --x-libraries=$RASPBIAN_ROOT/usr/lib/arm-linux-gnueabihf \
      --enable-includes=$RASPBIAN_ROOT/usr/include \
      --with-resolution=800x600x16
  • The resolution entry matches my Raspi desktop size. So adjust this value if yours differ

11. Build

  • If configure went well then let’s run the build
> cd $WORKDIR/build
> make

12. Install on your Raspi

  • The resulting AROS directory now contains all files needed on the target
  • I copy all files with rsync to my raspi directly into the $HOME directory
> cd $WORKDIR/build/bin/linux-arm
> rsync -av AROS pi@raspberrypi:

13. Run on Raspi

  • First make sure X11 is running
  • Then you can launch AROS with the bootstrap loader
raspi> startx
raspi> export DISPLAY=:0.0
raspi> cd AROS
raspi> boot/AROSbootstrap -v
  • That’s it. Enjoy AROS!

4 thoughts on “Building AROS hosted for Raspbian

Leave a Reply