How to build AOSP Kernel for Galaxy Nexus

Building an AOSP Kernel Galaxy Nexus GT-I9520 Version 4.2.2

Generate Folder:

generate a folder of you choice on your file system. In This case it is KERNEL_AOSP


Download Sources:

switch into the KERNEL_AOSP folder

git clone https://android.googlesource.com/kernel/omap.git

This will give you a git repository with all actual branches of the omap Kernels.

omap is the corresponding Kernel Source for Maguro Devices (Galaxy Nexus)

After the download you have a omap folder. 


Show the branches:

in your KERNEL_AOSP/omap Folder type 

git branch -a (shows you all branches)

This will list you a list of all branches available

 

Hint: after checkout you can look up you actual branch with git branch


Checkout branch:

For the actual JB Version checkout the following branch: 

git checkout android-omap-tuna-3.0-jb-mr1.1

After the checkout you have all files available 


Preparing the prebuilt GCC:

For Kernel built prebuilt GCC is necessary. If you have already a AOSP Rom Source on your Filesystem you need not to Download it.

Just set the Path:

 export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin: 

(pwd)...Path of you AOSP Rom Source

 

If you don't have an Android source tree, you can download the prebuilt toolchain from:

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/ar...

 

Don't forget to set the Path of where you have downloaded the prebuilt to.


 Set some Variables: 

export ARCH=arm

export SUBARCH=arm

export CROSS_COMPILE=arm-eabi-


Cleaning the Source

To ensure that you generate a really new Kernel type:

make clean

make mrproper

 

!!!Do this everytime before starting a new make process!!! 


 Config

make tuna_defconfig

This prepares the make configuration 

make menuconfig

Opens the visaulisation for the def config

 

Goto General setup ---> Local version-append to kernel release

type in whatever you want to name your Kernel 

This text is shown in the about diaglog of the Phone and helps you to find out if the Kernel Source is your custom source.

 

After this we start the make process: 

make -j16 (-jx) the higher the number the more core power is used and will speed up the make

When make is finished you should have the message "Creating zImage successfully" 


Flash your Kernel to device:

Go into the folder arm/arch/boot. There you should find the zImage.img file.

Check if the date of the file is correct with the time of building and also if the size is about 4,2MB.

If all thing are OK, we can flash the zImage to the device. Make sure that the device is available

adb devices (if the device is not shown do adb kill-server and adb start-server)

Go into fastboot mode

adb reboot bootloader


Flash it:

fastboot flash zimage zImage (Match Case!!)


Reboot the device:

either you press the START button on your device or you type fastboot reboot

 

After rebooting the device you should find your Kernel name in the About Phone page!

CONGRATS YOU ARE DONE!