Kernel Development

This is a general guide for building kernels and modifying them. Device-specific articles for getting the kernel source and setting up the build environment are provided in their respective sections.

Getting the kernel source
The source for your kernel must be made available by your device's manufacturer in order to comply with the GPL.

Motorola maintains a list of their devices' source code here.

HTC's device source code is available at developer.htc.com.

Your device's source code can be found on it's device page. See the Devices page to find your device. mm

Setting up the environment
Instructions for setting up the development environment should be included in your source code package. This should tell you the parts of the Android Open Source Project that must be in your working directory in order to allow the kernel to build. It will tell you what version as well. All of the Android Operating System source code is available at [android.git.kernel.org] and most projects are mirrored at [github.com/android]. Both are accessible via your internet browser as well as git.

Modifying the kernel
After the kernel source has been downloaded and your environment is set up, you can begin modifying the kernel. It is recommended (in most cases mandatory) that you run the standard "make xxx_defconfig" for your device before modifying the configuration.

Running make or make -jX [where X is the number of operations to perform at a time] at this point will make the stock kernel that your phone's official system has. To modify it, we can go two ways: 1) modify the file '.config' in a text editor, or 2) run make menuconfig for a graphical interface.

Modifying '.config' with menuconfig
Typing.. make menuconfig will bring up the aforementioned graphical interface for modifying your kernel. Striking the "y" key when an option is selected (with "< >" or "[ ]" before it) will include it in the kernel. Striking the "m" key will add those options with a "< >" as a Linux kernel module (*.ko).

Mofifying '.config' manually
The alternative to using menuconfig is editing '.config' in your preferred text editor. Options that are not to be included in the build are commented out with a "#". Options that are to be included inside the kernel image are uncommented and have the value of "y". Options with the value "m" are to be built into loadable kernel modules.

Adding ext3/ext4 support
touch yourself now.

Additional steps
You may find that you want to play around with '.config', but don't want to lose your configuration. You can rename your '.config' to whatever you want and give it the suffix "_defconfig" and put it in "arch/arm/configs/" for the next time you wish to use it.

For example: if you had a kernel that had tethering and ReiserFS support, and you wanted to try enabling VPN without breaking your current setup, you could rename your '.config' to 'my_rfs_tethering_defconfig' and move it to "arch/arm/configs/". The next time you wanted to make this kernel you could run make my_rfs_tethering_defconfig and have your kernel configuration just as you left it.

Note that this would overwrite your kernel configuration stored in '.config'