Building and Deploying a Linux Kernel

Kernel development is ongoing within the Linaro organization.

1 - Obtain the source code

You can usually find a working kernel at:

  • Identify a kernel you want to start with and use git to make a copy.
    • For this example I started with the linaro 3.1 kernel.

git clone git://

2 - Create a suitable .config file

There are many ways to generate .config files. Here are three.

From Linaro sources

The official Linaro .config file is the concatenation of the config.common.ubuntu, config.common.armel, and a config file for OMAP, MX51, S5PV310, U8500, or VEXPRESS.

#The base URL for all of the files:

#The two common files for all .configs:

#Pick one of these for your target:

# Example to generate an omap .config:

The correct tree to set for BASE depends on the kernel tree you are getting the source code from:

Source code tree

Base tree for config





Copying an existing config

If you have used linaro-media-create to make a bootable SD card then there is a copy of the config file used to create that kernel on the card. 
If the SD card is mounted on your host system the copy of the config file is in:

From a generic base

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap2plus_defconfig

Linaro packaged kernel builds for OMAP use the Thumb-2 instruction set, which is not supported by OMAP2 platforms. If you want to enable this configuration, you must do the following:

  • Disable CONFIG_ARCH_OMAP2 (System Type -> TI OMAP Common Features -> TI OMAP2/3/4 Specific Features -> TI OMAP2)

  • Enable CONFIG_THUMB2_KERNEL (Kernel Features -> Compile the kernel in Thumb-2 mode)

For Thumb-2 kernels on some other platforms, you may also need:



Tweaking a Config

Here's a cool trick to updating individual config options in your kernel.

3 - Build the Kernel

  • Build the kernel. For this example, I deployed to the Gumstix Overo COM.

(If you are using a custom .config file skip the first step.)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap2plus_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules

Note: You will need a cross toolchain for this step. See Installing Cross Toolchain on 10.04(Lucid) and 10.10(Maverick) or Installing Cross Toolchain on 11.04(Natty) and later.

4 - Deploy the Kernel

Deploy the new kernel using scp

  • Target side (in booted system):

dhclient eth0
ntpdate-debian (optional)
apt-get install ssh
mount /dev/mmcblk0p1 /mnt
cd /mnt
scp <username>@<host ipaddr>:<host-build-dir>/arch/arm/boot/uImage .
  • You will probably get warnings about mismatched /lib/modules/, that can be bypassed with the following commands:

mkdir /lib/modules/`uname -r`
depmod -a

Deploying the kernel to the SD card

This procedures assumes you have already deployed once using linaro-media-create.

  • Insert the SD card and see where it automounts (it usually mounts to /media/)
  • On the host, go to the kernel directory and install the kernel and kernel parts to the SD card using these commands:

cp arch/arm/boot/uImage /media/boot/
cp .config /media/boot/config-<kernel_name>

If your kernel name is 2.6.38-1002-linaro-omap, you should have: cp.config /media/boot/config-2.6.38-1002-linaro-omap

  • If you need modules and the other kernel pieces, run these commands:

make ARCH=arm INSTALL_MOD_PATH=/media/rootfs/ modules_install
make ARCH=arm INSTALL_FW_PATH=/media/rootfs/lib/firmware/ firmware_install
  • On the target, stop the boot process in the bootloader and make the following changes:

setenv loadbootscript ''   // This disables the UUID validation of the kernel/rootfs
setenv console 'ttyO2,115200n8' // Depends on the console for your platform
run bootcmd
  • These settings will not be saved to flash. If you want to save them type before 'run bootcmd':

  • Then umount the SD card, install in target and boot.

  • Use the commands given below for the initramfs creation.

Deploy the kernel in u-boot using tftp

  • This is a temporary deploy. You can't write to the boot partition from u-boot, so this just runs the kernel from RAM.
  • Make sure you have a tftp server setup on your host. There is a lot of help on how to do this, just google and find some setup instructions.
  • Host side:

cp arch/arm/boot/uImage /tftpboot/
  • Target side (in uboot):

set ipaddr <>
set serverip <>
tftpboot uImage
setenv console 'ttyO2,115200n8' // Depends on the console for your platform
run mmcboot

Creating Initramfs

The Linaro boot script (boot.scr) passes an initramfs image to the kernel at boot up. This image includes kernel modules that may be used at start up. You may create this image on the target system after you first boot into it with:

# Generate a file named /boot/initrd.img-<KERNEL VERSION>
$ update-initramfs -c -k `uname -r`

# Now package and copy it into your boot partition with:
$ mount /dev/mmcblk0p1 /mnt
$ cp /mnt/uInitrd /mnt/uInitrd-bak
$ mkimage -A arm -T ramdisk -C none -n "MY RAMDISK" -d /boot/initrd.img-`uname -r` /mnt/uInitrd

You should now have an image that will be usable by this kernel on the next boot.

5 - Create a Kernel Debian Package

There are several guides for creating a debian package of a kernel. Here are 2 created by Linaro employees.

6 - Board Specific Kernel Packaging

Some of the Landing Teams have created packaging guides directed to their hardware.


Resources/HowTo/KernelDeploy (last modified 2013-04-17 21:24:26)