Graphical view of new Android kernel flashing

A picture speaks a thousand words.. Hence, summarizing my experience from the previous two days, below is the graphical overview of new Android kernel flashing steps:

Android kernel flashing steps

Android kernel flashing – graphical overview

Key to the above figure:

  • Items in RED : things to be downloaded from the internet.
  • Boxes in GREEN : Step#1 of the new kernel install – making flashable kernel zip.
  • Box(es) in WHITE : Step#2 of the new kernel install – installing modules.
  • Boxes in YELLOW : a step producing multiple things, and used individually.

Solving “WiFi not working” issue after new kernel install on an Android device

Yesterday I managed to successfully install a self-built kernel onto my test Android phone. The major visible issue that cropped up was that of WiFi not working. After going through several blogs, have finally solved the issue :), thanks mainly to a great point mentioned on a geeksphone blog (point no. 9). I’ll summarize the issue and the solution here:

The filesystem present on the Android device contains several kernel modules at the location /system/lib/modules.These may have been compiled using an unknown toolchain (android-ndk or Linaro or Sabermod, etc.). Personally, am using Sabermod-4.7-32bit toolchain, given that I have a 32-bit linux OS installed on my laptop.

This mismatch in toolchains results in the zImage created by our kernel-build, and the several .ko files already present in devices’ /system/lib/modules being incompatible, and thus issues like WiFi not working crop up!

To solve this, copy all the .ko’s generated during our kernel build to the devices /system/lib/modules. This can be achieved through the following steps:

# cd to kernel source directory
cd kernel-src-dir/

#copy all kernel modules from kernel source directory
find . -name '*ko' -exec cp '{}' custom-dir/ \;

#mount the device after plugging it into the USB
adb shell mount -o remount,rw /system
for filename in custom-dir/*
do
  adb push `basename $filename` /system/lib/modules/
done;

#reboot the device
adb reboot

Thats it! Next time you reboot, WiFi should be working as normal with your own new, shiny custom kernel.. Enjoy!!

Foray into Android Kernel hacking

A post after ages.. and we begin a new journey into the world of (Linux’s cousin) Android kernel hacking.

Presently, have taken baby steps in this field involving:

  • building the kernel from source using default defconfig of my device. Thanks to cheatman for the kernel source for my test device.
  • Thanks to excellent explanation provided at this xda link, kernel build was almost a cakewalk!
  • Kernel build produces a zImage, which is a compressed image of the kernel. Next step involves packaging the kernel into a form that a custom recovery installed in your Android devices can read it (FYI, I am currently using CWM Recovery).
  • Kernel packaging involves the following steps:
    1. Extract ramdisk (or, initramfs on older devices) from an existing boot.img. This can be obtained from freely downloadable flashable kernel zips corresponding to one’s device.
    2. Use this ramdisk along with the built zImage to create a new boot.img
    3. Create a zip out of this boot.img and META-INF folder that was obtained from flashable kernel zip in 1).
  • The linux tools for performing the above can be obtained from this link.
  • Once the zip is ready, copy it to your sdcard, boot to recovery and select option : install from zip and select your flashable kernel file.

Finally, a screenshot from my device πŸ™‚

Screenshot of new kernel install from device's settings view

Screenshot of new kernel install

A major problem am facing presently is that WiFi on this device is not working since the new kernel install. Will try to figure out the issue and post an update soon.