[TUT] How to Compile your own kernel from source

jdkoreclipse

Banned
Nov 1, 2010
246
24
0
Ok ,so i got a few requests on how to compile a kernel. Its fairly easy, but you MUST know what you are doing, or else you can make a bad kernel, that wont boot or will run like bad.

The first thing we want is to make sure java is installed. Just enter this into your terminal:
Code:
 sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

FOr 64 bit sustems, you also have to enter this in your terminal after the previous command finished running:
Code:
sudo apt-get install ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

Ok, now we want to set up the proper build environment for our kernel. For the sake of time, we will use the easy method for now. Download the toochain here: github.com/jdkoreclipse/toolcain and renaame the first folder (the one that says jdkoreclipse_toolchain with all the numbers) to system and extract it into a directory on your home folder called android. You have now completed step one of the build environment setup.

Now to grab the source. Grab whosever source you want. CM kernel source, HTC kernel source, or even someone else's source. Once you grab your desired source, unpack it at a directory called kernel (name it whatever you want, but for the sake of this tutorial, we will keeep the default directory kernel).

Ok, now that we have our source set up, now to do the compiling. First, we need to complete our build environment. Just run this command to do that:
Code:
 export CCOMPILER=${HOME}/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

Now that we setup the toolchain, now to do the real stuff. First, we want to modify any code within the source. Next, we want to
make the kernel configuration. To do that just run
Code:
 make incrediblec_defconfig
(on my kernel its jdkoreclipse_defconfig and on cyanogen's its cyanogen_incrediblec_defconfig). Now to set out preferences for some kernel specific features. RUn:
Code:
make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig
and once your done editing that, save your configuration and run:
Code:
 make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
to make your kernel. Your zimage will be at arch/arm/boot. And your modules will be in a few directories (there will be a list in the top of your kernel tree). If i was you, i would zip up the kernel and the modules into an anykernel, but thats my preference.
 
Last edited:
  • Like
Reactions: ProTekk and trock70
I get a mount error using the anykernel updater. Do you have any idea

Using this anykernel template I get mount error complaining about 3 args when it needs 4. Do you have any idea,
 
Since this thread is from Jan of this year, it does not surprise me if it's out of date. I'm not a kernel guru by any means. I would suggest checking the CM site as a good starting point for Kernels.

Good luck.
 

Forum statistics

Threads
954,086
Messages
6,960,547
Members
3,162,919
Latest member
mespeedie3