ARMKernelCrossCompile

Revision 1 as of 2012-03-22 15:56:10

Clear message

The following instructions show how to properly download, tweak and cross compile an Ubuntu ARM kernel from an x86 Ubuntu host.

Vanilla Ubuntu armhf omap4 kernel compilation

First install the necessary tools for source code management and compilation:

sudo apt-get install fakeroot build-essential kexec-tools kernel-wedge gcc-arm-linux-gnueabihf
sudo apt-get install gcc-arm-linux-gnueabihf libncurses5 libncurses5-dev libelf-dev 
sudo apt-get install asciidoc binutils-dev
sudo apt-get build-dep linux

Then download the code, switch to the omap4 branch and kick a build:

git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git

cd ubuntu-precise
git checkout -b ti-omap4 origin/ti-omap4

export $(dpkg-architecture -aarmhf); export CROSS_COMPILE=arm-linux-gnueabihf-
fakeroot debian/rules clean
fakeroot debian/rules binary-omap4

At the end of the process you will have an header and an image .deb in the upper level directory:

ls ../*.deb
linux-headers-3.2.0-1410-omap4_3.2.0-1410.13_armhf.deb  linux-image-3.2.0-1410-omap4_3.2.0-1410.13_armhf.deb

Config modify an Ubuntu omap4 kernel

Pretty much as above, but between the 'fdr clean' and 'fdr binary-omap4' you issue:

fakeroot debian/rules editconfigs

where 'fdr' stands for 'fakeroot debian/rules'.

Choose the architecture you want to do some modifications (armhf in our case):

[flag@newluxor ubuntu-precise]$ fakeroot debian/rules editconfigs
dh_testdir;
/bin/bash -e debian/scripts/misc/kernelconfig editconfigs
Do you want to edit config: armel/config.flavour.omap4? [Y/n]n
Running splitconfig.pl for armel

Reading config's ...
  processing config.common.armel ... done.
  processing config.flavour.omap4 ... done.

Merging lists ... 
   processing config.common.armel ... done.
   processing config.flavour.omap4 ... done.

Creating common config ... done.

Creating stub configs ...
  processing config.common.armel ... done.
  processing config.flavour.omap4 ... done.
Do you want to edit config: armhf/config.flavour.omap4? [Y/n] Y

now do the config changes, save and 'fdr binary-omap4' to start a compilation of the new kernel.

FAQ

1) What's the difference between armel and armhf? And which should i pick?

Armhf requires a cpu with an FPU unit, while armel doesn't. As a rule of thumb, remember that from Precise onward Ubuntu uses armhf, while Oneiric and previous were armel.

To create a package for armel, you need the armel toolchain (gcc-arm-linux-gnueabi) and you need an armel environment:

export $(dpkg-architecture -aarmel); export CROSS_COMPILE=arm-linux-gnueabi-

the rest is the same as for armhf.

2) How do i mark my custom kernel to distinguish form the stock one?

It's possible to a add a suffix to the kernel name, modifying the changelog file. In our case, open debian.ti-omap4/changelog look for the first line and change it from:

linux-ti-omap4 (3.2.0-1410.13) precise; urgency=low

to

linux-ti-omap4 (3.2.0-1410.13~mycustomkernel) precise; urgency=low

This way the resultind .deb packages will have the custom "~mycustomkernel" suffix in their name.