How to cross compile ARM kernel under Ubuntu 10.10

So you got ARM device and want to build kernel for it? There are few ways how you can do it under Ubuntu 10.10 (or higher).

First you need proper cross compiler. After “apt-get install gcc-arm-linux-gnueabi” you will get proper one.

Next step is compilation of kernel. I will cover 2 things: Ubuntu kernel packages and own kernel.

So… to cross compile Ubuntu kernel we need to have some libraries installed in ARM versions. Simplest way is to use “xdeb” for it:

# apt-get install xdeb
# xdeb -aarmel --only-explicit --apt-source linux-linaro

This will fetch some libraries and install it in host system. But it will not build kernel for us :( Filled bug to not lose track of it.

NOTE: check “dpkg -l *elf*-armel-cross” after xdeb run. If it does not return anything then you need to edit “/etc/apt/source.list” and add line with “deb-src” so APT will know where to go for sources. Do not forget to run “apt-get update” after edit.

Next step is quite simple — all is needed is:

$ cd linux-linaro-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

After some time kernel will be cross compiled and packaged.

If you want official Ubuntu kernel instead of Linaro one then use:

$ apt-get source linux-source-2.6.35
$ cd linux-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

Other way (not supported by Ubuntu developers) is to build kernel from source outside of Ubuntu. Once you got sources unpacked and configured you need just one command: “ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make uImage modules” to build kernel (replace uImage with zImage if your device does not use U-Boot).

cross-compiler linaro linux ubuntu