5,814,633 Members 53,312 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Build Your Own Android Kernel{Easiest and Fastest Way] [Using The NDK]

Tip us?
 
TheWizardOfROMs
Old
(Last edited by TheWizardOfROMs; 26th April 2013 at 12:29 PM.)
#1  
TheWizardOfROMs's Avatar
Senior Member - OP
Thanks Meter 230
Posts: 124
Join Date: Nov 2012
Location: Prilep

 
DONATE TO ME
Default [GUIDE] Build Your Own Android Kernel{Easiest and Fastest Way] [Using The NDK]

This is the quickest and easiest way to build your own Kernel using the Android NDK

Note:I will be reffering to the following
Quote:
yourusername=the username that you are logged in to
devicecode=The codename for the device you are building a kernel for(Google it on what is the code name
Note:I am only showing you how to make it to be flashed via CWM. If you wan't a tuttorial on how to make a boot.img comment and i will make it.

What you will need
Quote:
Ubuntu 12.04 or newer
A lot of patience
Step 1:Installing the required files

Open a terminal and type the following (copy-paste)
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2
This will install the packages you need

Download the kernel source code for your device (This is important. We are going to build the kernel from this)
Find your device and click Download

Download The NDK

Move the NDK and your device Kernel source code in your home folder
Extract both the NDK and your kernel source code
Rename the folder were you have the NDK installed to NDK. And rename the folder where you have the kernel installed to Kernel

Now we are ready to build.

Step 2:Tweaking the kernel

Navigate to the kernel folder
Code:
cd /home/yourusername/Kernel
Next we need to point the NDK tools to the kernel folder
Code:
export CROSS_COMPILE=/home/yourusername/NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
We've pointed the NDK tolls and now we can use the NDK to tweak the kernel

Next we need to clean the previous work just incase:
Code:
make clean && make mrproper
If everything goes well you are good to go. If you have an Error(s) then something is wrong.

Now we are ready.
Next we need to add the kernel features to the NDK so we can modife them
Firs open your kernel source code folder go to arch/arm/configs
Here you will all the configs.
We need only one. Find that. It is called:Yourdevicecode_somethingbalblabla.defconfig
Rename it to maker.defconfig
Now type this in your terminal
Code:
make maker.defconfig
Now we need to tweak those configs.
Code:
make menuconfig
A user interface will pop out showing you all the tweaks you can do. I am not going to show you whow to use it. Google it(Sorry don't have that enough space)
When you are ready close the UI and click SAVE

Step 3 Building
So we tweaked the Kernel and we are ready to build.
Quote:
make -j# ARCH=arm
Note:The # means the number of CPU cores +1. For example my device has a quad core CPU and I will type
Code:
make -j5 ARCH=arm
This will build the Kernel. It will take about 10 minutes.

Step 4: Finalizing
Now that kernel is ready you will need to find a kernel flashable zip for your device(Just google it)
Download the zip file and leave it in your home folder.

Now got to your kernel source and go to arch/arm/boot and copy zImage
Paste your Zimage to the zip file and replace it.

Now we need the WI-FI modules otherwise your WI-FI will not be working
Go to the Kernel source code folder and go to driver/net/wireless/bcm4329_204 and copy bcm4329.ko
Got the zip file go to the System folder and replace it's bcm4329.ko with your bcm4329.ko

You are ready all you need to do is flash it.
The Following 48 Users Say Thank You to TheWizardOfROMs For This Useful Post: [ Click to Expand ]
 
sert00
Old
#2  
sert00's Avatar
Senior Member
Thanks Meter 505
Posts: 1,082
Join Date: May 2011
Location: cesena,IT
mmm..interesting...i always build without the ndk,but simpy sdk.what's the advantages?
and i usually do the git clone to download all the sources,in my case nexus7 and maguro.
thanks for this!
My current mobile devices:
Samsung galaxy nexus maguro version 16Gb
Asus transformer WiFi-only 16Gb
Asus nexus 7 WiFi-only 16Gb
My current system embedded boards in use:
Arduino UNO (x2)
Arduino Mega 2560 (ADK support with USBHost Shield)
My current ARM boards:
Raspberry Pi rev.B
Hardkernel odroid-U2 with Exynos4412 PRIME x2 and all optional addons
Hardkernel odroid-XU-E with Exynos5410 x1 and all optional addons
The Following User Says Thank You to sert00 For This Useful Post: [ Click to Expand ]
zylor Old
#3  
Guest
Thanks Meter 0
Posts: n/a
Well i am just waiting for Samsung to release JB sources for N7000 to start learning on how to create my own kernel

This is a pretty good base! Thanks
The Following User Says Thank You to For This Useful Post: [ Click to Expand ]
 
HTCDreamOn
Old
#4  
HTCDreamOn's Avatar
Recognized Contributor
Thanks Meter 689
Posts: 820
Join Date: Jun 2012
Question RE: [GUIDE] Build Your Own Android Kernel{Easiest and Fastest Way] [Using The NDK]

Sorry if this is a stupid question but do we need 64 bit like we do for ROM compiling, or will this work fine for 32 bit (I'm running Ubuntu 12.10 32 bit). Also, roughly how much is there to download? Thanks
 
pwelyn
Old
(Last edited by pwelyn; 19th February 2013 at 08:44 AM.)
#5  
pwelyn's Avatar
Member
Thanks Meter 11
Posts: 73
Join Date: Oct 2009
Location: 上海
Thanks! I'm use Ubuntu 10.04 64 bit don't know if can?
The Following User Says Thank You to pwelyn For This Useful Post: [ Click to Expand ]
 
TheWizardOfROMs
Old
#6  
TheWizardOfROMs's Avatar
Senior Member - OP
Thanks Meter 230
Posts: 124
Join Date: Nov 2012
Location: Prilep

 
DONATE TO ME
Quote:
Originally Posted by HTCDreamOn View Post
Sorry if this is a stupid question but do we need 64 bit like we do for ROM compiling, or will this work fine for 32 bit (I'm running Ubuntu 12.10 32 bit). Also, roughly how much is there to download? Thanks
I am not sure. I think you can on 32 bit try it the download takes all together about 500 MB
The Following User Says Thank You to TheWizardOfROMs For This Useful Post: [ Click to Expand ]
 
HTCDreamOn
Old
#7  
HTCDreamOn's Avatar
Recognized Contributor
Thanks Meter 689
Posts: 820
Join Date: Jun 2012
Post RE: [GUIDE] Build Your Own Android Kernel{Easiest and Fastest Way] [Using The NDK]

Quote:
Originally Posted by TheWizardOfROMs View Post
I am not sure. I think you can on 32 bit try it the download takes all together about 500 MB
Thanks, do you know how large all the files are once installed on the system (you might have guessed I'm slightly short of space atm)
The Following User Says Thank You to HTCDreamOn For This Useful Post: [ Click to Expand ]
 
TheWizardOfROMs
Old
#8  
TheWizardOfROMs's Avatar
Senior Member - OP
Thanks Meter 230
Posts: 124
Join Date: Nov 2012
Location: Prilep

 
DONATE TO ME
Quote:
Originally Posted by HTCDreamOn View Post
Thanks, do you know how large all the files are once installed on the system (you might have guessed I'm slightly short of space atm)
About 700 MB
The Following 2 Users Say Thank You to TheWizardOfROMs For This Useful Post: [ Click to Expand ]
 
thewadegeek
Old
(Last edited by thewadegeek; 21st February 2013 at 06:23 PM.)
#9  
thewadegeek's Avatar
Senior Member
Thanks Meter 773
Posts: 694
Join Date: Mar 2011
Location: Cedar Rapids
Quote:
Originally Posted by sert00 View Post
mmm..interesting...i always build without the ndk,but simpy sdk.what's the advantages?
and i usually do the git clone to download all the sources,in my case nexus7 and maguro.
thanks for this!
What are you building? If a whole ROM like AOSP,AOKP,PA or CM then they typically bundle the toolchain/kernel with the source, making this totally unneeded.

---------- Post added at 12:18 PM ---------- Previous post was at 12:17 PM ----------

Quote:
Originally Posted by HTCDreamOn View Post
Sorry if this is a stupid question but do we need 64 bit like we do for ROM compiling, or will this work fine for 32 bit (I'm running Ubuntu 12.10 32 bit). Also, roughly how much is there to download? Thanks
No 32-bit is fine, just install the right libraries. I actually believe that you can compile a ROM on 32-bit as well.

Self-Plug http://forum.xda-developers.com/show....php?t=1748297
Search before asking for help.
Search again.
Once more.
And again.
Now post.
Oh and you ask for thanks? I say no.
The Following 2 Users Say Thank You to thewadegeek For This Useful Post: [ Click to Expand ]
 
thewadegeek
Old
#10  
thewadegeek's Avatar
Senior Member
Thanks Meter 773
Posts: 694
Join Date: Mar 2011
Location: Cedar Rapids
Default Re: [GUIDE] Build Your Own Android Kernel{Easiest and Fastest Way] [Using The NDK]

Also just to warn users, the above defconfig convention is just that, a convention. The author of a kernel can name the defconfig whatever they want, so it is something to keep in mind.

Sent from my SCH-R950 using Tapatalk 2
Search before asking for help.
Search again.
Once more.
And again.
Now post.
Oh and you ask for thanks? I say no.

The Following User Says Thank You to thewadegeek For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes