As I’ve been compiling Cyanogenmod for the ZTE Blade, I thought I’d have a look at compiling the kernel instead of applying binary patches. I found this tutorial which kind of helped, here’s my simplified summary:

  1. Pull kernel source from Github (currently weighs in at 1.7Gb):
git clone git://github.com/TomGiordano/kernel_zte_blade.git
  1. Get the .config file – most tutorials say to get this from your phone which is running the kernel that you want to compile, but actually its already stored in git:
cp ~/kernel_zte_blade/arch/arm/configs/cyanogen_blade_defconfig ~/kernel_zte_blade/.config
  1. Build the kernel:
make ARCH=arm CROSS_COMPILE=~/cyanogenmod/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
  1. Build CM7 as usual, and to make things easier we’re going to copy a few files all into the same directory, including the split_bootimg.pl we downloaded:
mkdir ~/custom_kernel
cd ~/custom_kernel/

cp ~/split_bootimg.pl .
cp ~/kernel_zte_blade/arch/arm/boot/zImage .
cp ~/cyanogenmod/out/host/linux-x86/bin/mkbootimg .
cp ~/cyanogenmod/out/target/product/blade/update-cm-7.1.0-RC1-Blade-KANG-signed.zip .
cp ~/cyanogenmod/out/host/linux-x86/framework/signapk.jar .
cp ~/cyanogenmod/build/target/product/security/testkey.* .

unzip update-cm-7.1.0-RC1-Blade-KANG-signed.zip
  1. Unzipping the KANG has given us the META-INF and system directories and boot.img file, which we must now unpack:
./split_bootimg.pl boot.img

6a. Optionally copy across the .ko files mentioned in modules.order to system/lib/modules/2.6.32.9-perf/ the highlighted ones are probably not neccessary:

grep -v test modules.order | sed 's|^kernel/||g'

arch/arm/mach-msm/reset_modem.ko
crypto/ansi_cprng.ko
drivers/scsi/scsi_wait_scan.ko
drivers/net/wireless/libra/librasdioif.ko
drivers/input/evbug.ko
arch/arm/oprofile/oprofile.ko
  1. Recreate the boot.img with the new kernel:
./mkbootimg --cmdline 'androidboot.hardware=blade console=ttyMSM2,115200 g_android.product_id=0x1354 g_android.serial_number=Blade-CM7' --base 0x2600000 --kernel zImage --ramdisk boot.img-ramdisk.gz -o boot.img
  1. Zip up the new boot.img and old META-INF and system directories:
zip -r rom.zip META-INF boot.img system
  1. Sign the zip:
java -jar signapk.jar testkey.x509.pem testkey.pk8 rom.zip rom-signed.zip
  1. Generate an md5sum of the signed zip so users can check it downloaded properly:
md5sum rom-signed.zip > rom-signed.zip.md5sum

And here’s the screenshot of the running ROM with my kernel:

img