Set up a cross-build machine for the Raspberry Pi

Prerequisites

This document focuses on Debian hosts. Debian derivatives such as Ubuntu should work with minor changes. Install the following packages:

git
cdebootstrap
binfmt-support
qemu-user-static

Choose a directory for the raspi tools, firmware and filesystem, then make RASPI_SDK_ROOT point to it. For instance:

export RASPI_SDK_ROOT=/home/sam/raspi

Then add the following directory to PATH:

$RASPI_SDK_ROOT/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin

Install Raspi tools

Get the Raspberry firmware and tools:

git clone https://github.com/raspberrypi/firmware.git
git clone https://github.com/raspberrypi/tools.git

Install Raspbian

As root, install a minimal Raspbian filesystem:

cd $RASPI_SDK_ROOT
sudo cdebootstrap --foreign --allow-unauthenticated --flavour=minimal \
                  --arch=armhf stable chroot http://archive.raspbian.org/raspbian
sudo cp /usr/bin/qemu-arm-static ./chroot/usr/bin
sudo chroot ./chroot /sbin/cdebootstrap-foreign
sudo chroot ./chroot dpkg-divert --add --rename /usr/lib/arm-linux-gnueabihf/libc.so
sudo chroot ./chroot dpkg-divert --add --rename /usr/lib/arm-linux-gnueabihf/libpthread.so

Now to install packages inside the chroot:

alias raspi-get="sudo chroot $RASPI_SDK_ROOT/chroot apt-get"

raspi-get update
raspi-get upgrade
raspi-get install zsh

Build Lol Engine

Make sure the required packages are installed:

raspi-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev

Then just run the following:

./build/build-raspi

Build autoconf projects

For simple autoconf projects (using ./configure ; make) the following command can now be used:

RASPI_INCLUDES="$RASPI_SDK_ROOT/firmware/opt/vc/include"
RASPI_LIBS="$RASPI_SDK_ROOT/firmware/opt/vc/lib"

./configure --host=arm-bcm2708hardfp-linux-gnueabi \
    CPPFLAGS="-I$RASPI_INCLUDES -I$RASPI_INCLUDES/interface/vcos/pthreads" \
    LDFLAGS="-L$RASPI_LIBS"

make

If you need to use Raspbian packages, add the following to CPPFLAGS in the configure line:

-I$RASPI_SDK_ROOT/chroot/usr/include

And the following to LDFLAGS:

-L$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf
-Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf
-L$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf
-Wl,--unresolved-symbols=ignore-in-shared-libs

Bitten configuration

For Lol Engine autobuilders, add the following section to the bitten machine file:

[raspi]
version = 0
Last modified 5 years ago Last modified on Apr 23, 2014, 5:25:51 PM