Kernel Building

If you chose to build your own kernel you have to options: 1. Native build 2. cross-compiling

native build

#tested only for u-boot!#

First you need to get the kernel source:

cd /usr/src
git clone git://git.openmoko.org/git/kernel.git linux-2.6
cd linux-2.6
git checkout --track -b andy-tracking origin/andy-tracking

Now we need to configure our kernel:

ls -s /usr/src/linux-2.6 /usr/src/linux #for compiling stuff that will ask for your kernel
cp arch/arm/configs/gta02_packaging_defconfig ./.config
#tomboy64 suggested and I didn't tried without.
make oldconfig
make menuconfig

And now for building the kernel, this will take hour-s- so don't wait for this. but first grub mkimage, place it at your location of choice or emerge dev-embedded/u-boot-tools.

cd /usr/src/linux
make && make modules_install
#now you need to make a kernel that u-boot can boot from.
#first we will back-up our old working kernel
cp /boot/uImage.bin /boot/working_uImage.bin
#now create bin from the new kernel
mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 300080e0 -n "uImage.bin" -d /usr/src/linux/arch/arm/boot/zImage /boot/uImage.bin

cross-compiling

#tested only for u-boot!#

Please note that I have been maintaining a kernel in flash memory space, and have modified u-boot to boot kernels larger than 2MB to support that. You can find instructions for that here:

http://wiki.openmoko.org/wiki/Android_on_Freerunner#Modify_Uboot_as_Bootloader_for_more_than_2MB

First you need to get the kernel source (I keep the kernel source in my home directory, and symlink into the cross root

cd ~/
mkdir openmoko_kernel
cd openmoko_kernel
git clone git://git.openmoko.org/git/kernel.git linux-2.6
cd linux-2.6
git checkout --track -b andy-tracking origin/andy-tracking
cd /usr/armv4tl-softfloat-linux-gnueabi/usr/src
ln -s ~/openmoko_kernel/linux-2.6 linux

Now copy over the kernel config file (I use the moredrivers kernel config, with some additional menuconfig items):

cd /usr/armv4tl-softfloat-linux-gnueabi/usr/src
cp arch/arm/configs/gta02_packaging_defconfig .config

You can optionally edit the kernel configuration using menuconfig:

make ARCH=arm CROSS_COMPILE=armv4tl-softfloat-linux-gnueabi- menuconfig

To build the kernel:

make INSTALL_MOD_PATH=/usr/armv4tl-softfloat-linux-gnueabi/ ARCH=arm CROSS_COMPILE=armv4tl-softfloat-linux-gnueabi-

To build and install the modules into your cross root:

make INSTALL_MOD_PATH=/usr/armv4tl-softfloat-linux-gnueabi/ ARCH=arm CROSS_COMPILE=armv4tl-softfloat-linux-gnueabi- modules_install

To make u-boot image of kernel, you'll need u-boot-tools:

emerge dev-embedded/u-boot-tools

To build a uImage file:

armv4tl-softfloat-linux-gnueabi-objcopy -O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinux linux.bin
export BRANCH=`git branch | grep ^\* | cut -d' ' -f2 | sed s/-hist//g`
export HEAD=`git show --pretty=oneline | head -n1 | cut -d' ' -f1 | cut -b1-16`
mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008000 -n "OM GTA02 $BRANCH""_$HEAD" -d linux.bin uImage.bin

You can then use dfu-util to flash the kernel to your phone, or, and this is untested by me, you can copy the kernel image to your cross root /boot partition.

http://wiki.openmoko.org/wiki/Flashing_the_Neo_FreeRunner#Flashing_the_Kernel

This gives you matching kernel and modules in your cross root.