[AT&T, Rogers HTC One X, Telstra One XL] rohan32:
Hi guys!

Someone requested a tutorial on how to build the kernel source code, so I thought I might as well do it :) I'll give you a bit more information too.

Maybe this will kick start kernel development a little bit too. Who knows.

Anyway:

1. Set up your build environment as per this guide by AOSP here: http://source.android.com/source/initializing.html

This guide will be primarily aimed at Ubuntu, but it should be easy enough to do on other Linux PCs. Ubuntu is highly recommended. And don't ask about Windows.

2. Download the toolchains: http://code.google.com/p/rohan-kernel-evita/downloads/detail?name=toolchains.tar.gz&can=2

I've hosted both GCC 4.4 and GCC 4.6 (prebuilt) on my Google Code page. These are for Linux.

Download the toolchain package here: http://code.google.com/p/rohan-kernel-evita/downloads/detail?name=toolchains.tar.gz&can=2

Then un-tar the archive and extract it to your home folder so that the path to the toolchain directories are ~/toolchain/whatever-one-you-want

3. At this point you can decide which kernel source you want to download. There are really two sources.

The first choice is getting it from HTC Dev directly. This is good if you want to build your kernel for a Sense 4 ICS ROM. If you want to build for AOSP/JB, then scroll down below all the following HTC stuff.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

To use HTC's source:

Go to HTCdev.com and make an account. Then download the source code for our device (I'd recommend the "One X" source under carrier "AT&T" version "2.20". Let the zip file download and extract it to your home folder (so the path is /home/user/evita-ics..../

To build HTC's source, run these commands:

cd ~/evita-ics-whatever_the_directory_is_named
export ARCH=arm
make elite_defconfig

Second command is saying what type of architecture we want (we are compiling for ARM processors, so we want ARM)

Third command is saying to make the default config for our device (whose hardware is codenamed "elite")

Then to build the actual kernel:

make -j# ARCH=arm CROSS_COMPILE=~/toolchain/arm-eabi-4.4.3/bin/arm-eabi-

In the command above, there is "-j#". Replace the "#" with the number of CPUs you have.

Ask me about it if you need help. That should be it! Let the build go and in a few minutes you should have a zImage file located at ~/evita-ics-..../arch/arm/boot. That is the actual kernel.

To test out the zImage (kernel), connect your device via fastboot mode and type:

fastboot boot /path/to/zImage

Combined with the ramdisk, thats what makes the boot.img file. Eventually if you want to distribute your kernel, you should use an installer that injects the zImage into the boot.img or combine the zImage with a ramdisk to make a boot.img. I can do a tutorial on that later on as well.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

To get the "other" source:

This source is based off of HTC's source and includes other devices as well in it (the One S and Evo 4G LTE). Its good if you want to build JB AOSP kernels.

To download this kernel source do this:

mkdir ~/kernel
cd ~/kernel
git clone https://github.com/CyanogenMod/android_kernel_htc_msm8960.git -b android-msm-evita-3.0

This version also includes a number of optimizations and odd bug fixes present in the HTC version.

To build this second source, run these commands:

cd ~/kernel/android_kernel_htc_msm8960
export ARCH=arm
make elite_defconfig

Second command is saying what type of architecture we want (we are compiling for ARM processors, so we want ARM)

Third command is saying to make the default config for our device (whose hardware is codenamed "elite")

Then to build the actual kernel:

make -j# ARCH=arm CROSS_COMPILE=~/toolchain/arm-linux-androideabi-4.6/bin/arm-eabi-

In the command above, there is "-j#". Replace the "#" with the number of CPUs you have.

Ask me about it if you need help. That should be it! Let the build go and in a few minutes you should have a zImage file located at ~/evita-ics-..../arch/arm/boot. That is the actual kernel.

To test out the zImage (kernel), connect your device via fastboot mode and type:

fastboot boot /path/to/zImage

Combined with the ramdisk, thats what makes the boot.img file. Eventually if you want to distribute your kernel, you should use an installer that injects the zImage into the boot.img or combine the zImage with a ramdisk to make a boot.img. I can do a tutorial on that later on as well.

-----------------------------------------------------------------------------

The second option is also a bit better as it uses the 4.6 toolchain instead of GCC 4.4. HTC's source doesn't work with GCC 4.6 so it can't be used without changes that the second source has.

If you have any questions, feel free to post here, message me on twitter (@rohanXm), chat me on IRC (#HTC-One-XL) or PM me!

If this helped you, please consider hitting the donation link under my username on the left. Donations are never required but always appreciated.