[T-Mobile, Samsung Galaxy SIII] Jamison904:
First off let me start with saying this, half assing a kernel or not following all the steps exactly will brick your device!. You have been warned. I personally was every hesitant to even try to make my own kernels because of the brick factor. After researching for weeks and reading like crazy I felt like I had enough knowledge to attempt to build my own kernel. After talking with my buddy TDJ he told me that when it comes to kernels you just have to get learn by hands on. Of course he was right. So be careful and if something doesn't seem right,do not flash it. Also the kernel_test.zip attached is for TMO/ATT S3. I haven't checked to see if the boot block is the same for all of the US S3's. I'll check and update this. Until then only use for TMO/ATT S3.

#include
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/

[COLOR="Red"]By using this how to you agree with the above terms![/COLOR]

Now with that out of the way lets have some fun! This how to is for the T999 TW kernel. This guide will work for all S3 devices with minimal changes. Also the basics here will work for all devices. Also at this point the guide is only build a stock kernel without changes. That will come in another update. I will need to show you git and how to use it before you can make changes. Also if you make and changes and you share the kernel with others you have to post your source!! So you will need to know how to use github or bithub. These too will come later.

​

First you will need to download the source for the kernel. You will need to go to http://opensource.samsung.com/ and find the source for your device. Search for t999 and grab the one named SGH-T999_JB_TMB_Opensource.zip. Or you can grab it from my Goo account here. . . . .
​

Now you need to extract the zip. Then extract Kernel.tar.gz. Now make a folder in your home directory if you have not already called android. Then inside android make another director called kernel. Last make a folder for you kernel, you can name it whatever. For this how to lets just call it T999_TW_kernel. Now move everything from the extracted Kernel.tar.gz to this folder. This is your kernel working folder.
​

Next you will need to choose the toolchain you plan on using. There are many great ones out there. Just Google "kernel tool chain" to see the many different ones. The Android NDK comes with a bunch and most are 100% stable. Since I also suport AOKP for many devices, I just use the one they use. I have uploaded it to my github for you guys to download and use. Go to https://github.com/jamison904/arm-eabi-4.6 and click on zip to download it.

​

Now you will need to set your path and set the cross compile in your make file inside your kernel working folder.

​

We are going to setup your toolchain path now. Extract the downloaded toolchain from my github and make a folder inside the android folder called toolchain. Now move the extracted tool chain here. Open up the make file in the kernel folder and set your path like below. (of course change Jamison904 to whatever yours is named.) save and close.

ARCH	?= arm
CROSS_COMPILE = /home/jamison904/android/toolchain/arm-eabi-4.6/bin/arm-eabi-

​

​

Name your kernel! Open the make folder and make the change then save and close.

​

Now open terminal here inside the kernel build folder. You need set it up. You need to:

make clean && make mrproper

​

Ok time to pull the defconfig from your phone (This is for a TW Kernel so you need to be running a TW ROM. You also will need to be running a stock kernel for this to work right...) You will need to connect your phone to your computer with adb debugging turned on. Then open the terminal from your desktop and:

adb pull /proc/config.gz

then

gunzip config.gz

This will give you a file called config. You will want to rename this file to t999_defconfig. After that you will need to move this file to /home/jamison904 (your user name)/android/kernel/T999_TW_kernel/arch/arm/configs. Drop it here.

​

Now it is time to attempt to build. You will need to do:

make xconfig

This will bring up a nice user friendly UI to help you set up the build.

Now you need to click on the folder. Navigate to arch/arm/config and click on your T999_defconfig.

This shows you where to find the schedulers. You can change the default scheduler here. Also can turn them on and off, as well if you want to build them in or make them build as a module.

This shows you where to find the governors. You can change the default governor here. Also can turn them on and off, as well if you want to build them in or make them build as a module.

​

Now lets see if you set it up correctly.... lol. You will do:

make

​

Later after you know that it will build you can seed it up by doing make -j5. This will make with 5 jobs at once. This is way faster but very hard to trouble shoot and find your errors. If it stops without finishing you will need to make clean && make mrproper then do the xconfig again and save and close then "make" .... This will only make with one job at a time thus you have an error and it will stop and you will be able to read the error. Copy and paste to pastebin.com and post the link here and I will help you figure it out. :cool:

​

If you get this, congratulations you have made your first kernel... time to package it up and test.

​

​

​

Finding the zimage (kernel itself.) Navigate to arch/arm/boot and grab the zimage.

​

​

Now to find the modules. Do a ctrl f in the root of your kernel build folder and screach for .ko. Make sure to include the . before ko. Then copy and paste these into a folder to hold them for the zip.

​

​

Now you need to unpackage a boot.img and replace the zimage then repackage it up. The easiest way to do this is with the Android kitchen. Takes less then a minute. If you have been following my guides here you will already have it setup and have working knowledge of the kitchen. If not, stop here and go catch up, i'll wait....;) Ok moving on.

​

I made a folder called WORKING_Kernel to keep these away from real working folders just in case I forget. Don't need to update my S2 ROM with a S3 kernel. Anyways...

Place a stock boot.img into the folder

Now start up the kitchen and press 0. Then option 12 for boot.img.

Then press w. This will unpack the boot.img.

The end result will be a folder called "BOOT-EXTRACTED"

Open it and you will see the ram-disk and the Zimage (kernel). Delete the Zimage here!

Grab your new Zimage and copy and paste it in to the "boot-extracted"

Now to repackage it. Back over in the Kitchen press "b" to build

Your new kernel is in the boot.img

​

Now to flash the kernel. I have made you guys an empty flashable zip attached below. This way no one breaks their device trying to flash their kernel. If you do brick you didn't read the directions as this zip is dummy proof so to speak. ;)
​

Now double click on the kernel_test.zip and drag and drop your new boot.img into the archive.

Now navigate to system/lib/modules and press Ctrl A to select all of the modules then drag and drop these here.

​

Done. Copy and paste the zip to your SDcard and reboot into recovery and pry.... lol. You will be good if you followed the directions. Enjoy your own build stock TW kernel! Again remember not to public share your kernel unless you have uploaded "your exact source" and can provide a public link to it. You have been warned! Next updates will include how to work git, commits, and github as well as some more advanced kernel tweaks and code. Also how Cherry-pick :cool:

​

​

​

For more advanced kernel work you will need meld to work conflicts. Open terminal and:

sudo apt-get install meld

Now when you get a conflict from cherry picking you will do

git status

this will show you the conflicting files. Then to work them you will need to

git mergetool

For more info on how to use it go to http://meldmerge.org/ ... have fun!

​