[Galaxy S II I9100G Android Development] superatmos:
Building Kernel

Okay. Let's learn how to build kernel for our I9100G. There are many ways to build. I am just presenting here the way I build and make kernel.

NOTE 1: Follow the instructions exactly.

NOTE 2: Kernel is opensource. If you make any changes to it, you're expected to share your source. (Usually people share it over github :))

NOTE 3: FLASHING KERNEL IS RISKY AND DANGEROUS. BE CAREFUL. BUILD AND FLASH ON YOUR OWN RISK.

What you need to have:

Ubuntu 10.04 and above (I use 10.04 :))

ARM tool chain (Download HERE. Click on IA32 GNU/Linux TAR under Advanced Packages)

Samsung's opensource kernel for I9100G (Download HERE. Go to Mobile->Mobile Phone-> Select I9100G and download the zip)

Setting up toolchain:

Extract the tar you downloaded(Suggestion: Extract to one folder where you can have everything. In my case /home/superatmos/build_kernel).

After extracting, you'll see a folder named arm-2010q1. Inside there will be many folders (ex. bin, lib and so on.)

Folder structure will be: /home/<your_name>/build_kernel/arm-2010q1

Setting up kernel:

Extract the zip you've downloaded from samsung's opensource.

You'll find two zips.

Extract GT-I9100G_Kernel.tar.gz to /home/<your_name>/build_kernel/

Folder structure: /home/<your_name>/build_kernel/GT-I9100G_Kernel

Setting up initramfs:

Samsung's zImage is divided into two parts: Opensource kernel (which you downloaded from samsung's website) and initramfs (which is root file system to boot up the device).

I am providing my initramfs HERE. (You can use it as it is or modify it. But give credits to me. :))

Extract the downloaded zip and copy it to /home/<your_name>/build_kernel/

Folder structure: /home/<your_name>/build_kernel/initramfs

Now the entire setup is ready. Let's start modifying kernel configuration. :)

Setting up kernel config:

Go to /home/<your_name>/build_kernel/GT-I9100G_Kernel/arch/arm/configs folder.

Copy

t1_defconfig

file and paste it in kernel root folder (/home/<your_name>/build_kernel/GT-I9100G_Kernel/).

Rename t1_defconfig to .config in kernel root folder.

Now open Makefile which is in your kernel root folder(/home/<your_name>/build_kernel/GT-I9100G_Kernel/).

Modify the below lines (I guess line 195 and 196).

ARCH ?= arm
CROSS_COMPILE ?= /home/<your_name>/build_kernel/arm-2010q1/bin/arm-none-linux-gnueabi-

Save and close.

Modifying kernel configuration:

Now open .config file(which you renamed). If its not seen, it might be hidden. ;) Go to View->Show hidden files and there you go. :)

Do the below things:

Adding local version:

Change CONFIG_LOCALVERSION=" " to anything you like. I add this way:

CONFIG_LOCALVERSION="-I9100G-superatmos" :cool:

Adding initramfs path:

You need to let kernel know the path from which it needs to take initramfs.

Change CONFIG_INITRAMFS_SOURCE=" " to ../initramfs (In this tutorial it's the path. If you had copied anywhere else, give the path properly).

Enough for now. Once you get experience, you can modify many configurations as per your liking and save. This configuration can be changed by GUI too with the command make menuconfig.

The Important part: Building the kernel: :)

Open terminal.

Go to path /home/<your_name>/build_kernel/GT-I9100G_Kernel/

Type make.

THAT'S ALL. YOUR zImage is ready and is available in /home/<your_name>/build_kernel/GT-I9100G_Kernel/arch/arm/boot/zImage. :)

Install the zImage on the device:

Go to the path where zImage is present and type the below line in command line.

tar cvf I9100G_kernel.tar zImage

Flash the tar using odin.

DONE. CONGRATULATIONS. NOW YOU'VE YOUR OWN KERNEL. :)

Other references:

Building Kernel by bedalus

How to compile your first Nexus Kernel by djjonastybe

Give me your feedback so that I can improve this tutorial. And post here about how your build went. All the best. :)