Dienstag, 15. Oktober 2013

Raspberry Pi Crosscompile-setup

The goal was to compile packages for my Raspberry Pi on my Desktop PC which is running ArchLinux. The main challange is to compile armhf-binaries on an x86_64-CPU. There are plenty of suggestions to do this...
One of them was crosstool-ng. Sadly I could not get it to work on my ArchLinux-system either. All other approaches basically involved setting up a qemu-environment to do the compiling.
Sadly binfmt_misc refused to run arm-binaries via qemu-user-static on my archlinux-system, so I gave up setup an Ubuntu-VM.

Setting up such an environment in Ubuntu is surprisingly easy:
1. Install qemu and stuff
# apt-get install qemu-kvm-extras-static
2. Install debootstrap
# apt-get install debootstrap
3. setup basic environment
# mkdir virtual-pi
# qemu-debootstrap --arch=armhf wheezy virtual-pi http://mirrordirector.raspbian.org/raspbian/
It's important to use the raspbian-mirror here. Otherwise the compiled binaries cause Segmentation Faults when copied to the Pi.
4. setup build-environment
# chroot virtual-pi
# echo deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi >> /etc/apt/sources.list
# echo deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi  >> /etc/apt/sources.list
# apt-get update
# apt-get install build-essential
Starting from here I was able to compile binaries to copy to the Raspberry Pi.