[Defy General] Kayant:
[Guide] Compiling your own nightly kernels Quark/Blechd0se & Essential Git commands

Well Hello again :cowboy: another day, another do it yourself guide for the people like me with ORD :cool:

Search it up to see what am on about ;)

Today there will be two guides they are very easy I promise :p - One on how to compile just the kernel image(zImage) and the other on how to use some common git commands.

Kernel Guide

1. Downloading the sources & packages needed :

Before we start we need to make sure you have the necessary packages required for you to compile the kernel.

If you already have an android build environment setup then we are good to go :D

If not then you can either use my guide and get an android build setup going just incase you want to compile your own nightly later on or you can just download the necessary packages required for compiling the kernel.

Packages needed - git-core, gnupg, flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev, build-essential, zip, curl, libncurses5-dev, zlib1g-dev, ia32-libs, lib32z1-dev, lib32ncurses5-dev, gcc-multilib, g++-multilib.

So for ubuntu based system it will be -

$ sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

For arch linux -

$ sudo yaourt git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

Most of the packages are found in the AUR repository so you need a frontend to AUR like yaourt.

Once you have the packages installed we are going to clone the kernel tree into our computer.

I feel it's best you make a new directory for which you will use to compile kernels.

Once you are in your directory of choice we can now download the kernel sources

For Quarx kernel - $ git clone https://github.com/Quarx2k/jordan-kernel

For Blechd0se kernel - $ git clone https://github.com/Blechd0se/jordan-kernel

One thing to note is after the git clone command you can name the folder in which the sources will be saved to.

For example git clone https://github.com/Blechd0se/jordan-kernel blechd0se. This will renamed the folder to Blechd0se which the kernel sources will be saved to instead of the default name of jordan-kernel.

2. Downloading the toolchain/s

If you have one of the rom sources (CM10, SB, CNA) synced up then you can just point the cross compile to that directory.

$ git clone https://github.com/Quarx2k/platform_prebuilt

Here you have a choice of two toolchains either the default google one (4.4.3) or the recently added linaro toolchain(4.5.4) by Quarx

3. Setting up configuration

Now cd into the kernel folder so for me -

$ cd ~/Kernel/Blech0se

Then run the follwing commands -

$ export ARCH=arm

$ export CROSS_COMPILE=~/<location of toolchain>

- For the linaro toolchain it will be export CROSS_COMPILE=~/Kernel/arm-eabi-4.5.4-linaro/bin/arm-eabi-

- For google's iw will be export CROSS_COMPILE=~/Kernel/arm-eabi-4.4.3/bin/arm-eabi-

make mapphone_defconfig

If you are compiling Blechd0se kernel then you can choose what process schedulers you want BFS or CFS the default is CFS.

To enable BFQ you need to do the following things

make menuconfig this will bring up a menu which you can use to customise the kernel if you know what you are doing this can also be used on Quarx's the difference is you don't have as much choice as in Blechd0se's.

Scroll down and select enable block layer then IO schedulers the scroll down to BFS and type "Y" a star will appear in the checkbox showing it will use BFS now.

Once that's done you can compile own kernel image using the make command

make -jx <maximum number of jobs>

Replace the x with the amount of jobs you want. I usually use -j8 but you can use higher but it can slow down you PC.

Read this post for more info on effectively using make -jx

You kernel will be finished into a couple of minutes to hours depending on the amount of jobs you used and how many cores you have in your processor.

Now we need to package the kernel into a zip to flash recovery.

I recommend you download one of Blechd0se's zips and modify it.

You need to delete the config folder if you don't want your overclock settings getting overwritten and also you can modify the updater script found in META-INF/com/google/android.

Then replace the zImage in the folder system/2ndboot/ with your new one.

You can find your zImage into the arch/arm/boot folder in your kernel source folder.

4. Updating and rebuilding -

To update your sources with the latest changes you can use the git pull origin command from the kernel source folder.

So for me it will be -

$ cd ~/Kernel/Blechd0se

$ git pull origin

Once it's being updated we need to first use

$ make clean

$ export ARCH=arm

$ export CROSS_COMPILE=~/<location of toolchain>

$ make mapphone_defconfig

$ make -j8

Credits & Thanks-

To XDA as always for being an awesome resource and playground ;)

To Google for all they awesomeness

To Blechd0se for being an awesome kernel dev

To Quarx for his amazing work on the kernel so far

To thewadegeek for his guide which I have adapted this from Thank him here
​