The first step in cross-compiling software is to get a working environment that you can use for it. I am setting up my environment to cross compile for the Drobo FS using the latest Ubuntu Lucid and used this article Building MediaTomb for the Drobo using Ubunutu to get my system working and to create this guide.
First, I setup an Ubuntu 10.04 installation within a VM image as I tend to change computers and laptops frequently and would like to keep this image for Drobo FS development. As in the noted article, everything will be done within a chroot environment and then copied to the Drobo FS.
# install schroot and debootstrap
sudo apt-get install schroot debootstrap
# create new root
sudo mkdir -p /var/chroot/drobofs
# create /etc/schroot/chroot.d/drobofs
cat << END_OF_DROBOFS > /etc/schroot/chroot.d/drobofs [drobofs] description=Ubunutu Intrepid for DroboApps on Drobo FS location=/var/chroot/drobofs priority=3 users=<Your Username> groups=<Your Group> root-groups=root run-setup-scripts=true run-exec-scripts=true END_OF_DROBOFS
# create system in chroot jail
sudo debootstrap --variant=buildd --arch i386 intrepid /var/chroot/drobofs
# download the toolchain
# extract the toolchain
cd /var/chroot/drobofs/usr/local # DroboShare sudo tar -xjf arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 # Drobo FS sudo tar -xjf arm-2007q1-21-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 ## the resulting toolchain is put into a /usr/local/arm-xxx directory ## must either move the files to the parent or put them in the path setting
# copy resolv.conf into the chroot environment
sudo cp /etc/resolv.conf /var/chroot/drobofs/etc/resolv.conf
# Optional: if run_setup_scripts is not used for chroot, Mount the required filesystems
sudo mount -o bind /proc /var/chroot/drobofs/proc
# Activate the chroot to complete setup
sudo schroot -c drobofs -d /root
# Load some extra packages
apt-get install vim apt-get install wget apt-get install automake autoconf libtool autotools-dev m4
# type exit to leave the chroot
exit
When cross-compiling, you want to use the system's binaries for running development tools but make the compiler and linker using the ARM headers, libraries, and binaries.
From the Drobo FS SDK 1.0:
The following steps can be used to create an application build environment or depending on your needs, you can change the build folders as desired when building multiple applications or targets.
# create a directory for code (or use the specific application name)
sudo mkdir -p /var/chroot/drobofs/home/build
# create a directory for resulting binaries (or use a specific application name)
sudo mkdir -p /var/chroot/drobofs/usr/arm
# Activate the chroot to build application
sudo schroot -c drobofs -d /root
The following environment variables will help with building to a non-standard directory:
export CFLAGS="-I/usr/arm/include -march=armv5te" export CPPFLAGS=${CFLAGS} export LDFLAGS="-L/usr/arm/lib" export CC=arm-none-linux-gnueabi-gcc # replace /usr/arm as needed to match your build output path