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 |
2. 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 |
3. Build the kernel:
make ARCH=arm CROSS_COMPILE=~/cyanogenmod/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- |
4. 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 |
6. 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.kodrivers/input/evbug.koarch/arm/oprofile/oprofile.ko |
7. 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 |
6. Zip up the new boot.img and old META-INF and system directories:
zip -r rom.zip META-INF boot.img system |
7. Sign the zip:
java -jar signapk.jar testkey.x509.pem testkey.pk8 rom.zip rom-signed.zip |
8. 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:

Hi,
A good tutorial you got there, thanks! I was just wondering if the compiled zImage is the “kernel” file in device/zte/blade? If that file is the kernel file that goes into boot.img, wouldn’t it be easier to replace device/zte/blade/kernel with the fresh zImage, git add/commit it and have it built in the following times you compile CM? This would save you from the whole unpack/repack/resign process.
Yes I think you should be able to just replace the kernel file in git – assuming the modules are not needed – there should be no reason to do the repacking.
You don’t need to commit it to git (its readonly anyway).