FORUMS
Remove All Ads from XDA

[HOW-TO][TUTORIAL]Building Kernel from source

493 posts
Thanks Meter: 1,207
 
By superatmos, Retired Recognized Developer on 17th April 2012, 09:38 PM
Post Reply Email Thread
Hi all,

I am a developer in GT-I9100G sub-section. I made a tutorial over there for I9100G on building a kernel. Since the method is very similar, I thought of posting a tutotial here for N7000 too so that it will help many new and aspiring developers to build their own kernel for GT-N7000.

Okay. Let's learn how to build kernel for Galaxy Note N7000. 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 N7000 (Download HERE. Go to Mobile->Mobile Phone-> Select GT-N7000 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-N7000_Kernel.tar.gz to /home/<your_name>/build_kernel/

Folder structure: /home/<your_name>/build_kernel/GT-N7000_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).
  • Since I don't have the device, I don't have initramfs either. :( (If some kernel developer for GT-N7000 can provide a sample initramfs for reference, I can attach it here and give credits to him :))
  • The initramfs(let the folder name too be initramfs) folder need to be copied 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-N7000_Kernel/arch/arm/configs folder.
  • Copy c1_rev02_q1_defconfig file and paste it in kernel root folder (/home/<your_name>/build_kernel/GT-N7000_Kernel/).
  • Rename c1_rev02_q1_defconfig to .config in kernel root folder.
  • Now open Makefile which is in your kernel root folder(/home/<your_name>/build_kernel/GT-N7000_Kernel/).
  • Modify the below lines (I guess line 195 and 196).

Code:
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="-N7000-superatmos"

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-N7000_Kernel/
  • Type make.

THAT'S ALL. YOUR zImage is ready and is available in /home/<your_name>/build_kernel/GT-N7000_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.

Code:
tar cvf N7000_kernel.tar zImage
Flash the tar using odin.


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

Give me your feedback so that I can improve this tutorial and make modifications to the tutorial if necessary. And of course do post here about how your build went. All the best.
The Following 25 Users Say Thank You to superatmos For This Useful Post: [ View ] Gift superatmos Ad-Free
17th April 2012, 09:40 PM |#2  
OP Retired Recognized Developer
Flag Bangalore
Thanks Meter: 1,207
 
More
Reserved
The Following User Says Thank You to superatmos For This Useful Post: [ View ] Gift superatmos Ad-Free
17th April 2012, 09:41 PM |#3  
OP Retired Recognized Developer
Flag Bangalore
Thanks Meter: 1,207
 
More
Reserved
17th April 2012, 09:41 PM |#4  
OP Retired Recognized Developer
Flag Bangalore
Thanks Meter: 1,207
 
More
Last one
The Following User Says Thank You to superatmos For This Useful Post: [ View ] Gift superatmos Ad-Free
17th April 2012, 10:39 PM |#5  
muhamet's Avatar
Senior Member
Flag Skopje
Thanks Meter: 246
 
More
Superatmos good too see you in N7000 forum.Wil you launch Superatmos Rom for N7000

Sent from my LG-P500 using xda premium
18th April 2012, 12:31 AM |#6  
Senior Member
Thanks Meter: 528
 
More
Been using windows all the time. Seems its good time to learn linux and ubuntu
18th April 2012, 03:27 PM |#7  
OP Retired Recognized Developer
Flag Bangalore
Thanks Meter: 1,207
 
More
Quote:
Originally Posted by muhamet

Superatmos good too see you in N7000 forum.Wil you launch Superatmos Rom for N7000

Sent from my LG-P500 using xda premium

Not as of now. I don't have the device. But I have plans to extend this tutorial to deodexing, modifying initramfs, building custom rom and more.
The Following 4 Users Say Thank You to superatmos For This Useful Post: [ View ] Gift superatmos Ad-Free
18th April 2012, 08:08 PM |#8  
Junior Member
Thanks Meter: 1
 
More
looks interesting.
i just want to make sure.. if for some reason i used odin to flash the tarred zImage and it's a broken zImage. or corrupted file or false configuration that will break the booting process. will i see be able to go to download move or cwm mode ?
what are the risks here besides the regular odin risks ?
18th April 2012, 09:57 PM |#9  
chasmodo's Avatar
Senior Member
Flag Novi Sad
Thanks Meter: 41,311
 
More
Quote:
Originally Posted by ufk

i just want to make sure.. if for some reason i used odin to flash the tarred zImage and it's a broken zImage. or corrupted file or false configuration that will break the booting process. will i see be able to go to download move or cwm mode ?
what are the risks here besides the regular odin risks ?

The risks are considerable, to say the least. Read what happened with one b0rked kernel here:

http://forum.xda-developers.com/show....php?t=1526852

The end result: about 40-50 hard bricked devices.
19th April 2012, 07:56 PM |#10  
OP Retired Recognized Developer
Flag Bangalore
Thanks Meter: 1,207
 
More
Quote:
Originally Posted by ufk

i just want to make sure.. if for some reason i used odin to flash the tarred zImage and it's a broken zImage. or corrupted file or false configuration that will break the booting process. will i see be able to go to download move or cwm mode ?
what are the risks here besides the regular odin risks ?

Yes. Flashing kernels is always risky. But as per my experience, its very hard to brick the device unless you do something unusual.

so it depends on you. BUILD AND FLASH AT YOUR OWN RISK.
21st April 2012, 08:39 AM |#11  
Senior Member
Thanks Meter: 49
 
More
thanks and ok for this part ^^

but i have a question....
do you know the way for mod a stock kernel to add root / cwr when source code not avalable??

for exemple the lp6 kernel... do you know a way for extract the zimage for look on it and include root / crw on the Zimage directly...

if you have some idea please help comunauty for found a way for this ^^ (i have send pm to chainfire to take information for this mod but no response..)
The Following User Says Thank You to ReDroiD™ For This Useful Post: [ View ] Gift ReDroiD™ Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes