ARMKernelCrossCompile

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 modifications (armhf in our case):

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

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 strictly enforce it. As a rule of thumb, remember that from Precise onward Ubuntu uses armhf, while Oneiric and previous were armel based.

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

sudo apt-get install gcc-arm-linux-gnueabi

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

the rest is identical to the armhf case.

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

It's possible to a add a suffix to kernel name modifying the changelog file. So, in our example, _before_ the 'fdr clean', 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 resulting .deb packages will have the custom "~mycustomkernel" suffix in their names. Remember, only letters and numbers are allowed.

3) Ok, but what about my Beagle/XM? How do i compile a kernel for an omap3 board?

Omap3 support is fully present in mainline, so stay in the master branch (do not switch to ti-omap4) and:

fakeroot debian/rules binary-omap

4) So far all the examples were Precise based, what about the other releases?

Feel free to pick the release you prefer from http://kernel.ubuntu.com/git (see http://wiki.ubuntu.com/Kernel/Dev/KernelGitGuide for more info).

5) After export $(dpkg-architecture -aarmhf) i get a warning, what's that?

Yes, it's something like dpkg-architecture: warning: Specified GNU system type arm-linux-gnueabi does not match gcc system type i686-linux-gnu and it's harmless. Forget about it.

6) How do i compile a vanilla/upstream arm kernel that works with an Ubuntu userspace?

i assume your cwd is a checkout of Linus git tree and we are compiling an armhf kernel for an omap3 board.

a) make ARCH=arm omap2plus_defconfig

b) edit .config and modify the following options:

CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_XATTR=y

Since 3.5 EHCI is broken for omap3 and was disabled upstream, to enable it again:

CONFIG_USB_EHCI_HCD=y
CONFIG_MFD_OMAP_USB_HOST=y
CONFIG_USB_EHCI_TT_NEWSCHED=y
CONFIG_USB_EHCI_HCD_OMAP=y
CONFIG_TWL4030_USB=y

c) make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- uImage

d) copy arch/arm/boot/uImage to the sd card first partition overwriting ubuntu stock uImage

e) insert the sd card, and reboot

KernelTeam/ARMKernelCrossCompile (last edited 2012-10-05 13:05:25 by p-pisati)