http://mark.ossdl.de/2009/09/cross-compiling-for-the-sheevaplug-kernel-distcc/

cross-compiling for the SheevaPlug (kernel, distcc)


Compiling on the SheevaPlug can take long but is not neccessary if you have already your desktop pc running (which will be referred to as “workstation”). Unfortunately it will most probably not being run by an ARM processor, therefore you have cross-compile for the plug.

In this post I describe how to install a recent GCC version for cross-compiling, how to compile the latest kernel for the plug and how to enable distributed cross-compiling. By the latter you invoke compiling commands on the SheevaPlug and they will be executed by another machine transparently.

My workstation runs Gentoo Linux and listens on 192.168.1.6; the SheevaPlug runs Gentoo, too. By command emerge packages are installed, therefore if you used Debian you have to replace that call by apt-get and find out appropriate package names.

Install crossdev and setup a cross-compiling suite for the armv5tel-softfloat-linux-gnueabi architecture, which powers the SheevaPlug:

1.emerge portage-utils crossdev dev-embedded/u-boot-tools
2.crossdev armv5tel-softfloat-linux-gnueabi

This will take long as the latest GCC, binutils and the such will be compiled from scratch for the SheevaPlug.

  1. After having done that fetch kernel sources and review the default configuration for the plug shipped with it:
    1.emerge --oneshot >=sys-kernel/gentoo-sources-2.6.31
    2.# or >=sys-kernel/vanilla-sources-2.6.31
    3.cd /usr/src/linux
    4.make ARCH=arm kirkwood_defconfig menuconfig

    Starting from Linux 2.6.31 all patches for the SheevaPlug are included in the main tree, therefore you can virtually use every kernel flavour since that.

  2. In a hurry? You can download my kernel configuration file here.
  3. After configuration you will have to compile the kernel into an uImage:
    1.make -j4 ARCH=arm CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- uImage
  4. If you enabled dynamic module loading, you will have to compile modules as well. I did it, so here are the commands:
    1.make -j4 ARCH=arm CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- modules
    2.make -j4 ARCH=arm CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- INSTALL_MOD_PATH=.. modules_install

    It is very important to set INSTALL_MOD_PATH, or modules will be installed at your workstation. We want them in a separate folder for they will be copied to where they belong – the SheevaPlug.

The kernel should be compiled by now. Therefore log into your SheevaPlug and copy kernel and modules to it:

1.scp 192.168.1.6://usr/src/linux-2.6.31-gentoo/arch/arm/boot/uImage /boot/uImage-2.6.31-gentoo-mark
2.rsync -azuv -e ssh 192.168.1.6://usr/src/lib/modules /lib/
3.cat /boot/uImage-2.6.31-gentoo-mark > /dev/mtdblock1

The latter command will write the new kernel into the plug’s flash. You could leave that command out and have the kernel loaded from SD card or external USB drive, but it supports more USB devices (such as hubs) than your plug’s booting system. Consequently loading it from flash means less trouble in future.

Reboot your plug, smile. Cross-compiling has not been that hard. For your convenience, here’s my compiled kernel and modules for download. It includes iptables and samba support.


Setting up distributed cross-compiling is even easier. Do this on your workstation:

1.emerge distcc
2.nano /etc/conf.d/distccd
3.# add allow=192.168.1.0/24
4.nano /etc/distcc/hosts
5.# add localhost, don't add the sheevaplug! no work shall be distributed to it
6./etc/init.d/distccd start
7.rc-update add distccd default

That’s all for the workstation. We will make sure armv5tel-softfloat-linux-gnueabi-gcc and the such will be selected automatically.

  1. Repeat the above step on the SheevaPlug:
    1.emerge distcc
    2.# last time we will compile something on the plug alone
    3.nano /etc/conf.d/distccd
    4.# same subnet, same allow string
    5.nano /etc/distcc/hosts
    6.# 192.168.1.6/4,lzo -- don't specify localhost here! everything shall be delegated
    7./etc/init.d/distccd start
    8.rc-update add distccd default

    But wait, that’s not all or calls of gcc will be executed by the wrong compiler on your workstation.

  2. We have redirect that calls by a wrapper script (copied from this manual):
    1.cd /usr/lib/distcc/bin
    2.nano /usr/lib/distcc/bin/arch-wrapper
    3.    #!/bin/bash
    4.    exec /usr/lib/distcc/bin/armv5tel-softfloat-linux-gnueabi-g${0:$[-2]} "$@"
  3. Now come the symlinks:
    1.chmod a+x /usr/lib/distcc/bin/arch-wrapper
    2.ln -sf arch-wrapper c++
    3.ln -sf arch-wrapper cc
    4.ln -sf arch-wrapper gcc
    5.ln -sf arch-wrapper g++

Voila! Compiling will happen at your workstation, even if you invoked emerge on the plug.
Just make sure workstation and SheevaPlug use the same GCC version.

4 Comments so far

  1. mark on September 20th, 2009


    That’s how you can do distributed cross-compiling for any other architectures.
    Just crossdev something other replace armv5tel-softfloat-linux-gnueabi appropriately on the target.

    The workstation can run many cross-compiling suites.


  2. [...] Setup a cross-compiling suite for the SheevaPlug. You can compile the Linux kernel parallel to installing GNU/Gentoo. [...]

  3. roby on November 20th, 2009


    please add a note to apply this patch to the kernel:
    http://computingplugs.com/index.php/Fixing_SDHC_access_in_the_Orion/Mainline_kernel
    because there is a bug in the sdhc handling that make it brutally crash!

  4. mark on November 23rd, 2009


    Thanks for the pointer! I have already had incorporated that patch in my kernel trees, amongst others for SDHC cards.


Reply via email to