Friday, January 23, 2009

Recipe of the day: Cross-compiling armel kernels

ARM kernels can be very slow to bake because:
  1. ARM HW can be memory constrained so Native compilation is slow
  2. Setting up Native compilation for several boards is rather painful, if you, like me, have to compile several flavours everyday.
  3. Compiling under QEMU is mind-numbingly slow
Here, we bake all the Ubuntu ARM kernels using a single command on you x86 PC using a cross-compiler.

Ingredients
  1. A x86 machine running Ubuntu
  2. A ready-to-use cross-compilation toolchain
  3. Something software to compile, say, a kernel
Instructions
  • Get an ARM toolchain and set it up
I was too lazy to compile mine and got one from CodeSorcery. I used the 2008q3-72 tarball.

Untar it someplace in your $HOME, say $HOME/work/toolchains. You should now have a directory $HOME/work/toolchains/2008q3-72/bin with your cross-toolchain binaries.
  • Download the Ubuntu kernel
cd $HOME/work
git clone git://zinc.ubuntu.com/ubuntu/ubuntu-jaunty.git
cd ubuntu-jaunty

  • Compile the kernel
debuild -eCROSS_COMPILE=arm-none-linux-gnueabi- --prepend-path=$HOME/work/toolchains/arm-2008q3/bin -b -aarmel
  • Bake it
Let it bake for an hour or two, depending upon the speed of you oven^Wprocessor. If everything goes according to plan, you should have several .deb cookies for the various ARMel flavours of the Ubuntu kernel. Enjoy and share with friends and family.

No comments: