Compile Android kernel for ZTE Blade
April 25, 2012
The three things that I most like about the ZTE Blade is that it is a low cost Android handset, it has a very good screen (480*800 px) and, most important, it has a great community behind it. When I first bought mine almost 17 months ago, it came with Android 2.1. Now, Android 2.3 (Gingerbread) runs pretty fast and is really stable, and Android 4.0.3 is almost usable on a daily basis.
One thing that I always wanted, was to understand more about the Android OS. Unfortunatelly, although I have a degree in Computer Science, more specifically in the Artificial Intelligence area, I have never payed much attention to Operating system internals, like kernels and the rest. I want to believe that it is because that I have always been a Windows user until 3 years ago, when I started to use Ubuntu Linux on a daily basis, but maybe there is no excuse at all!
So, I'm here to redeem myself, and this posts serves to document my incursion through the learning of the compilation of the Linux kernel 2.6.35 for the ZTE Blade Android handset. Until I can produce a workable kernel, consider this an on-going work.
As I'm using Xubuntu 11.10, there are some tools that come by default, and others that must be installed. Generic tools, like "git" can be installed using Synaptic Manager. Others must be installed in other ways. Google them to learn how.
Download the kernel source code
There are two or three 2.6.35 kernels on github’s accounts. These kernels are updated versions of the original 2.6.35 kernel which was published by ZTE corporation. As I don’t know the differences between the several different kernel implementations, I have chosen to use Tom Giordano’s implementation at https://github.com/TomGiordano/kernel_zte_blade.
So, before we start the downloading, we should create a new folder (e.g. mkdir ~/android/kernel), and issue inside the new folder the following command:
git clone https://github.com/TomGiordano/kernel_zte_blade.git -b 2.6.35
This will download a copy of Tom Giordano’s kernel github repository, more specifically, the branch 2.6.35. It may take a while to download the 530MB.
If you don’t have the git command, you can install it using the Synaptic Package Manager. If you don’t want to use git, you can also download the kernel in zip format. Just open https://github.com/TomGiordano/kernel_zte_blade, make sure you are in the 2.6.35 branch and download the zip file (both options are in the beginning of the page). The problem is that with zip, any change made to the upstream source code implies a new download. With git you only need to do git pull to synchronize with the remote server.
After the git clone (or zip download), there will be a newly created folder (~/android/kernel/kernel_zte_blade) with the kernel source code inside. The code is structured in folders, like “arch” which implements architecture specific code, “drivers” which implements device drivers (for keyboard, wifi, bluetooth, etc.), “fs” for filesystem specific code (ntfs, fat, ext4, etc.), “init/main.c” which is the Linux kernel entry point, and many more.
To those interested, I suggest to go around the source code to try to understand more about the linux kernel. I also recommend the reading of:
- http://en.wikipedia.org/wiki/Linux_kernel: Learn generically about Linux kernel.
- http://tldp.org/LDP/tlk/sources/sources.html: How the Kernel source is structured.
- http://www.treblig.org/Linux_kernel_source_finder.html: Different kernel architectures (corresponds to contents of the kernel_zte_blade/arch folder).