[G2 and Desire Z Android Development] jbdubbs:
Compiling Pershoot's Vision Kernel for CyanogenMod 7

Why would I do this?

1. You must enjoy punishment

2. You want to know how a kernel gets compiled for Android.

3. You want to modify your kernel somehow, such as adding the Interactive Scheduler to the default Pershoot config or switching between CFS and BFS.

4. You want to modify the overclocking frequencies or voltages.

I don't teach how to do anything but #1 and 2, the rest I might get into later, but this guide is the gateway to all that.

You will need a working Ubuntu system. 10.04, 10.10, or 11.04 should all be fine. I did it with 11.04, so bleeding edge is working 100%.

On Ubuntu 10.04 and 10.10, get the following packages:

sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

On Ubuntu 11.04 get:

sudo apt-get install git-core gnupg openjdk-6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

Let's create our compilation area:

cd ~
mkdir kernel-compilation
mkdir kernel-compilation/toolchain
mkdir kernel-compilation/finals
mkdir kernel-compilation/staging

Download the following files:

http://www.mediafire.com/file/5aqhkl69fq75253/arm-eabi-4.3.1.zip - Unzip to ~/kernel-compilation/toolchain

http://www.mediafire.com/file/7lo2ctg7r56urky/staging.zip - Unzip to ~/kernel-compilation/staging

And lastly, grab the source from Pershoot's GIT, which will end up in kernel-compilation/vision-2632:

cd ~/kernel-compilation/
git clone https://github.com/pershoot/vision-2632.git -b gingerbread

Next we'll set up the compiler to use the ARM toolchain through an environment variable to make it easier later:

export CCOMPILER=~/kernel-compilation/toolchain/arm-eabi-4.3.1/bin/arm-eabi-

Next we'll use Pershoot's default configuration file as a starting point:

cd ~/kernel-compilation/vision-2632
cp arch/arm/configs/pershoot_vision_defconfig .config

If you wish to modify his configuration:

make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig

Next we'll compile the newly configured kernel:

make ARCH=arm CROSS_COMPILE=$CCOMPILER -j4 (replace 4 with the number of physical processor cores on your system, or leave the -j option off altogether if you don't know)

And the modules:

make ARCH=arm CROSS_COMPILE=$CCOMPILER modules

Now we'll start installing the kernel into our staging area.

Copy the kernel image from the source area into staging:

cp arch/arm/boot/zImage ~/kernel-compilation/staging/kernel/zImage

and install the modules (and fix where it puts them):

make ARCH=arm INSTALL_MOD_PATH=~/kernel-compilation/staging/system modules_install
cp ~/kernel-compilation/staging/system/lib/modules/2.6.32.38-cyanogenmod/kernel/drivers/net/wireless/bcm4329/bcm4329.ko ~/kernel-compilation/staging/system/lib/modules/bcm4329.ko
rm -rf ~/kernel-compilation/staging/system/lib/modules/2.6.32.38-cyanogenmod

Now let's finish up by zipping it all into the finals area:

cd ~/kernel-compilation/staging
zip -r ~/kernel-compilation/finals/mykernel.zip *

Now go to your finals directory and get to flashing!

References:

http://wiki.cyanogenmod.com/index.php?title=Building_Kernel_from_source

http://xdaforums.com/showthread.php?t=916198#

Thanks to Pershoot, CyanogenMod Team, and everybody on #cyanogenmod on Freenode IRC.