Powered By Blogger

Saturday, February 1, 2014

Tutorials for compiling new kernel for XT530

Tutorial 1 :

Compiling your OWN kernel from source.

 

In this tutorial I would explain how can you compile an android kernel for XT530 or XT316 from source.

First of all you would need UBUNTU 12.04+ 64-bit(32-bit must also work) . You can grab it from their official website.

After you've installed UBUNTU in your PC you would need to set up the kernel building environment. Just follow the steps mentioned below :
1. Open Terminal emulator.
2. Type :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ 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
------------------------------------------------------------------------------------------------------------------------------------------------------
This all would take a little time.
3. Cloning sources :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ git clone git://github.com/aweosomeabhijeet/android_device_domino_kernel.git kernel
------------------------------------------------------------------------------------------------------------------------------------------------------
This would fetch kernel sources from the Github repo.
4. Cloning toolchains :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains
------------------------------------------------------------------------------------------------------------------------------------------------------
These are handy prebuilt toolchains that would be used for compiling kernel. Thanks to DooMLoRD(xda) for extracting them and keeping them handy.

We are all done with fetching(downloading) part.

Now we would start actual compiling.

You can make changes to kernel like overclocking, undervolting, etc.

Now type in Terminal :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ cd kernel
$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=~/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-
------------------------------------------------------------------------------------------------------------------------------------------------------
Now we've set up the toolchain and we are ready to compile.
Now execute

If you are compiling for XT530, use :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ make domino_defconfig
------------------------------------------------------------------------------------------------------------------------------------------------------

Or if you are compilinf for XT316, use :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ make spice_defconfig
------------------------------------------------------------------------------------------------------------------------------------------------------

Then run
------------------------------------------------------------------------------------------------------------------------------------------------------
$ make -j#
------------------------------------------------------------------------------------------------------------------------------------------------------
( # - Twice the number of cores in your CPU)

Now the compiling process should start.
After it finishes compiling it would display zImage at arch/arm/boot ready.

Making boot.img

Part I

Extract boot.img from device from nandroid backup and copy it from sdcard to PC in a new folder "boot".

PART II

Download compiled mkbootimg and unpackbootimg(google them) and push them to /usr/bin and give executable permissions.
------------------------------------------------------------------------------------------------------------------------------------------------------
$ cd ~/boot
$ unpackbootimg -i boot.img
After this command the boot.img would get extracted into various files
$ cp ~/kernel/arch/arm/boot/zImage ~/boot/
This would copy zImage to the boot folder where we just extracted the boot.img
------------------------------------------------------------------------------------------------------------------------------------------------------

PART III

If you're compiling for XT530, use :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ mkbootimg --cmdline "mem=466M console=ttyHSL0,115200n8 androidboot.hardware=qcom androidboot.bootloader=3710" --kernel zImage --ramdisk ramdisk.img.gz -o new-boot.img
------------------------------------------------------------------------------------------------------------------------------------------------------

Or if you are compiling for XT316, use :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ mkbootimg --cmdline "mem=210M console=ttyHSL0,115200n8 androidboot.hardware=qcom androidboot.bootloader=3710" --kernel zImage --ramdisk ramdisk.img.gz -o new-boot.img
------------------------------------------------------------------------------------------------------------------------------------------------------

Now we just need to boot our freshly compiled kernel :

For that we need to install adb and fastboot to our system.

I prefer this tool as the best method(Many thanks to the developer.

Once you have adb and fastboot installed, open terminal and run :
------------------------------------------------------------------------------------------------------------------------------------------------------
$ adb devices
$ adb reboot-bootloader
$ fastboot boot ~/boot/new-boot.img
------------------------------------------------------------------------------------------------------------------------------------------------------

Now disconnect your device.
This time you would boot into your new freshly compiled kernel.

NOTE : Remember, never to flash the boot.img. We've a Locked Bootloader, which can't handle self made boot.img(s)

Do comment if you get any issues while compiling.