cross-compiling for the SheevaPlug (kernel, distcc)

Update 2012-02-17: All relevant patches have been integrated into the official Linux kernel (Torvald’s repository). You don’t need to merge different sources anymore.
Update 2010-05-17: Emerging gentoo-sources has been replaced by fetching them by GIT and merging Marvell’s and my patches into them.
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. On your workstation do:
emerge portage-utils crossdev dev-embedded/u-boot-tools 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.
- After having done that fetch kernel sources and review the default configuration for the plug shipped with it:
cd /usr/src git clone http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-for-plug cd linux-for-plug git remote add -t master -f marvell-orion git://git.marvell.com/orion.git git remote add -t master -f mark http://git.ossdl.de/r/linux/linux-2.6-gentoo-mark.git git merge marvell-orion/master mark/master make ARCH=arm kirkwood_defconfig menuconfig
Starting from Linux 2.6.31 all essential patches for the SheevaPlug are included in the main tree, therefore you can virtually use every kernel flavour since that.
- In a hurry? You can download my kernel configuration file here or the latest here; or compiled kernels here.
- After configuration you will have to compile the kernel into an uImage:
make -j4 ARCH=arm CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- uImage
- If you enabled dynamic module loading, you will have to compile modules as well. I did it, so here are the commands:
make -j4 ARCH=arm CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- modules 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 (or fetch pre-compiled kernels here). Therefore log into your SheevaPlug and copy kernel and modules to it:
scp 192.168.1.6://usr/src/linux/linux*/arch/arm/boot/uImage /boot/uImage-2.6.31-gentoo-mark rsync -azuv -e ssh 192.168.1.6://usr/src/lib/modules /lib/ 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:
emerge distcc nano /etc/conf.d/distccd # add allow=192.168.1.0/24 nano /etc/distcc/hosts # add localhost, don't add the sheevaplug! no work shall be distributed to it /etc/init.d/distccd start 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.
- Repeat the above step on the SheevaPlug:
emerge distcc # last time we will compile something on the plug alone nano /etc/conf.d/distccd # same subnet, same allow string nano /etc/distcc/hosts # 192.168.1.6/4,lzo -- don't specify localhost here! everything shall be delegated /etc/init.d/distccd start 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.
- We have redirect that calls by a wrapper script (copied from this manual):
cd /usr/lib/distcc/bin nano /usr/lib/distcc/bin/arch-wrapper #!/bin/bash exec /usr/lib/distcc/bin/armv5tel-softfloat-linux-gnueabi-g${0:$[-2]} "$@" - Now come the symlinks:
chmod a+x /usr/lib/distcc/bin/arch-wrapper ln -sf arch-wrapper c++ ln -sf arch-wrapper cc ln -sf arch-wrapper gcc 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.

Follow me on Twitter
That’s how you can do distributed cross-compiling for any other architectures.
Just crossdev something other replace
armv5tel-softfloat-linux-gnueabiappropriately on the target.The workstation can run many cross-compiling suites.
[...] Setup a cross-compiling suite for the SheevaPlug. You can compile the Linux kernel parallel to installing GNU/Gentoo. [...]
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!
Thanks for the pointer! I have already had incorporated that patch in my kernel trees, amongst others for SDHC cards.
Hi I am a new owner of a Sheevaplug (debian 2.6.30.2) and I am trying to use a open source program called MediaInfo – It looks like there is no armv5tel version available so I was thinking of compiling my own… any pointers??
corncrake, if your question was more specific I could help you more.
Given you didn’t replace the Linux distribution on your plug and you only want this program, try to compile it. First, install prerequisities by:
By that you should have everything needed to compile dependencies and the application itself.
If it requires X11 (KDE, Gnome, Fluxbox… any window manager) you will either have to buy an USB attachable display or install VNC and connect from another computer to the SheevaPlug to see the ‘picture’. But then, due to the limited flash storage, better attach an external harddrive and install X11 (…) there.
Perhaps any of my readers knows something similar that runs on console and depends on libmediainfo?
Thanks Mark,
The background to this is that I am trying to get the Sheevaplug to run the following program – YAMJ – http://code.google.com/p/moviejukebox/ YAMJ is a CLI moviejukebox program that scans your video library in order to extract information like: year, summary, posters etc… It has a Linux version that requires java 1.6 and MediaInfo – http://mediainfo.sourceforge.net/en . Java supports the ARM architecture but MediaInfo only has the i386 complied for download. So I was wonder could I use your approach to compile a version suitable for the Sheeva, but as I am a beginner at this I wanted to see if there was a obvious reason why this would not work…
Solved, compiled and working – thanks for your help
For paragraph #1 of the nonSheevaPlug,
# or emerge –oneshot “>=sys-kernel/vanilla-sources-2.6.31″
3.cd /usr/src/linux
might read
3.cd /usr/src/linux/linux-2.6.31.12 (or whatever version your oneshot emerge installed)
Updated the blog post with instructions on how to obtain the latest source along with patches for SheevaPlug.
John, thank you for the hints. I hope the new instructions yield in an even better result than compiling stock kernel sources.
[...] this post on how to compile kernel for the SheevaPlug. Fetch my current Linux kernels with modules and SATA support: download Linux kernel [...]
$ git merge git://git.marvell.com/orion.git
fatal: ‘http://git.ossdl.de/r/linux-2.6-gentoo-mark.git’ does not point to a commit
I get this no matter if I use stable or unstable x86 git. Same error for the next repository in step 1. Any hint? Thanks.
The link reads correctly on git.ossdl.de, but was wrong in this post. The URL is /r/linux/linux-2.6-gentoo-mark.git. Corrected, thanks!
I’m also getting this git ‘does not point to a commit’ error:
# git merge git://git.marvell.com/orion.git
fatal: ‘git://git.marvell.com/orion.git’ does not point to a commit
# git merge http://git.ossdl.de/r/linux/linux-2.6-gentoo-mark.git
fatal: ‘http://git.ossdl.de/r/linux/linux-2.6-gentoo-mark.git’ does not point to a commit
any idea what i’m doing wrong?
Nightmonkey and Kai, I’ve reproduced your issue and corrected the post by inserting
git remote add ...; git fetch ...; git merge .../master. Do the new steps work for you?If merging results in conflicts and you cannot figure them out by yourself, you can still
git clonethe sources from my repository alone.In addition to that I’ve put a fast proxy in front of git.ossdl.de to speed up downloads.
Thanks mark, now the checkout works but i get conflicts while merging
ERROR: content conflict in drivers/usb/serial/usb-serial.c
ERROR: content conflict in include/linux/fb.h
I’m not so confident with git and kernel sources….
So you said that i can just clone your sources and proceed like normal kernel building?
Kai, positive. Just clone my sources.
You can expect my sources being updated in a week or two, though.
By the way, most conflicts are trivial. Whitespace changes for example or another device ID so you have to establish an order between the present and the new.
Okay, i’ll give it a try with your kernel sources. By now, your kernel image & modules works just fine for me and the distcc works also, even if it’s not often used while emerging packages (gentoo doc mentioned that also)…
By the way, i was wondering if there is a way to build a binhost for sheevaplug on my own because portage lacks the possibility to check the used USE-flags in bin-packages and i have some packages i’m planning to use with specific USE-flags set. I already set up a binhost for other devices (intel atom) but there i don’t need to crosscompile, just different make.conf (other CFLAGS, CHOST, USE-flags etc…) and that worked great.
How did you set up your binhost? did you build the packages with sheevaplug & distcc, after that copied the packages to your binhost?
Kai, I’ve a post about the binhost, too. Please ask further questions there.
You don’t need to do anything special to set up a binhost in this case. The package, although cross-compiled somewhere else, is ultimatively build on the SheevaPlug/ARM machine. There you set the FEATURES.
My configuration usually looks like this:
/usr/portage and /var/portage are exported by NFSv4 (LAN only) so if you have more than one machine running Gentoo you don’t have to download soruces twice and this spares you setting up a webserver for having the binaries served.
You might want to check out Ceph as replacement for NFSv4, though. It is already included in my (pre-compiled) SheevaPlug kernels.
[...] possible e.g., to run a copy of one machine’s hdd as other’s system. Even distributed cross-compiling is no [...]
Warning.
You need to be careful about the command:
crossdev armv5tel-softfloat-linux-gnueabi
For instance, I just built Gentoo on a Dell Inspiron i17 and when I executed:
crossdev armv5tel-softfloat-linux-gnueabi
it installed gcc 4.5.1.
The current gcc on my SheevaPlug and another cross compiler is 4.4.5. Therefore, executing the crossdev without specifying the gcc compiler lead to a mismatch of compilers which the makers of distcc say should be avoided.
Consequently, I executed:
crossdev –gcc 4.4.5 armv5tel-softfloat-linux-gnueabi
It may be that the other libraries, e.g. binutils, libc:
* binutils: binutils-[latest]
* gcc: gcc-4.4.5
* headers: linux-headers-[latest]
* libc: glibc-[latest]
need to be specified, too.