Skip to content

HOWTO: Build the kernel

erasmux edited this page Sep 1, 2011 · 6 revisions

Prerequisites:

I assume, you already have a linux machine properly configured to build an android kernel.
Good places to start if you need more details on the prerequisites are:
Cyanogen’s “Building Kernel from source
Build your own kernel package from source” by gbhil (aging but still excellent)

toolchain

Currently I use this toolchain to build the kernel:
Sourcery G++ Lite 2011.03-42 for ARM EABI

Note: If you are not using an older toolchain, you will get an error about the -mno-unaligned-access compilation flag and you should remove it from the Makefile.

Sources

git clone git://github.com/erasmux/hero-2.6.29-flykernel.git

Config

make ARCH=arm hero_defconfig
(To build the BFS version use the hero-bfs_defconfig instead)

Build

make -j8 ARCH=arm CROSS_COMPILE=PATH_TO_TOOLCHAIN/bin/arm-none-eabi-

The gzipped kernel built can be found at `arch/arm/boot/zImage`
The kernel modules built (to be put in the /system/lib/modules):
$ find . -name "*.ko"
./fake/tiap_drv.ko
./fake/sdio.ko
./net/ipv4/ip_gre.ko
./fs/cifs/cifs.ko
./fs/fuse/fuse.ko
./drivers/staging/ramzswap/ramzswap.ko
./drivers/hid/hid-dummy.ko
./drivers/net/wireless/tiwlan1251/wlan.ko

Packaging

To create kernel image, you need to exact (and optionally edit) the boot.img-ramdisk.gz from a working kernel (using split_bootimg for example).
If you are not familiar with this subject, see the "HOWTO: Unpack, Edit, and Re-Pack Boot Images". Note that for the hero you need to add --base 0x19200000 to the mkbootimg command.

For example the command I use is something like:
PATH_TO_ANDROID/out/host/linux-x86/bin/mkbootimg --kernel arch/arm/boot/zImage --ramdisk boot.img-ramdisk.gz --cmdline "no_console_suspend=1 console=null" -o out/boot.img --base 0x19200000

Clone this wiki locally