[XPERIA X10 General] championswimmer:
Compiling kernel

So letme tell you how a kernel for x10 can be compiled

1. install ubuntu (through wubi or in vmware will also do) but i prefer on a separate partition.

2. Install the following packages

git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

here's how you go about doing it

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

sun-java6-sdk is no more officially available through ubuntu repositories

so you will need a workaround.... so here are some helpful articles

http://www.gaggl.com/2011/10/installing-java6-jdk-on-ubuntu-11-10/

http://superuser.com/questions/353983/how-do-i-install-the-sun-java-sdk-in-ubuntu-11-10-oneric

http://softwareinabottle.wordpress.com/2011/11/17/install-sun-jdk-6-on-ubuntu-11-10/

In case you are on a 64-bit version of ubuntu, (btw i strongly recommend using a 32 bit version for android development as you'll face various problems with 64-bit at various stages) you'll need these packages too

ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib​

3. Next you'll need a cross-compiler.

a cross compiler is used to compile for a different architecture than from the one you are currently working on. in this case you are either on a i686 or amd64 pc while the kernel you are compiling is for an ARMv7 processor.

for ubuntu, getting the Linaro GCC cross compiler for arm is getting as easy as

sudo apt-get install gcc-arm-linux-gnueabi

4. Now you are pretty much set up to compile kernels. Next we need sources.

So let me link you up to the most common available ones

Sony Ericcsoon Official Kernel Sources for 3.0.1.G.0.75 (gingerbread firmware)

Sony Ericsson Official Kernel Sources for Eclair Firmware

FreeXperia Kernel For ICS

FreeXperia Kernel for GingerBread

DoomKernel (this is my forked repo)

*** i'll update this list later (there are dozens of kernels for x10, all have their sources, i guess for now, this is enough)

5. So the source you have downloaded will be either a tar or zip archive. Using archiver, extract it into a directory of your liking.

6. Open terminal and 'cd' into the kernel directory. The kernel directory is the one which contains the folders arch, block, crypto, firmware, drivers .....

for compiling kernel you need to be in the root of this direcrory.

7. So here are a few codes that will get your kernel compiled

To clean source directory : -

ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make clean
ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make distclean

To get default configuration

ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make semc_es209ra_defconfig

if you are compiling FXP kernel then instead of semc_es209ra_defconfig you need to write fxp_es209ra_defconfig , and likewise for DoomKernel you need to use doom_x10_defconfig

To configure the kernel

ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make menuconfig

inside general setup you can name your kernel

and inside power management setup you can setup which CPU governors will be present and which will be default

do not mess to much with the driver setups or with "kernel hacking" area....

do not touch things that you have no idea about

Finally... to compile the kernel

ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make

If all goes well, you'll get this message

Kernel: arch/arm/boot/Image is ready

Kernel: arch/arm/boot/zImage is ready

If you get stuck in between, nothing to fret about. Just post here what problem you faced, amd me or some other helpful soul will help you out :)

8. I know you are thinking "whew!! are we done??"... ha ha ha!! no buddy!! not yet... much more work to do. :p

Firstly from you kernel directory go to arch/arm/boot (using a file explorer, not a terminal) and inside you'll find a 2~3 MB sized file called zImage. Copy that file into a separate folder where you'll stach all your finished works.

9. Now we need to compile the wifi modules.

For compiling wifi, you'll need the "vendor" folder (which is there in official sony kernel sources but not present in Doom's or FXP's repo). So if you need just the vendor folder, you'll HAVE TO download the official kernel sources too.

in terminal 'cd' to vendor/atheros/wlan/host/ folder

edit the localmake.linux.inc file using a text editor

sudo gedit localmake.linux.inc

edit the line ATH_CROSS_COMPILE_TYPE := arm-eabi- to ATH_CROSS_COMPILE_TYPE := arm-linux-gnueabi-

also in the line

# ATH_LINUXPATH := < kernel source path >

remove the # (uncomment it) and insert the appropriate kernel source path (the folder that contains arch, crypto, firmware, drivers etc folders.

now to compile wifi modules, run this code

ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KERNEL_DIR=/path/to/kernel make

of course, in place of "/path/to/kernel" type the actual path to kernel on your pc :p

this will get your wifi module compiled

go to the folder

vendor/atheros/wlan/host/.output/QUALCOMM_ARM_NATIVEMMC_BSP_REV=3240-SDIO/image/

and you'll find a file ar6000.ko

transfer that file to the place where you kept your zImage safely earlier.

10. PHew!! done?? ha ha .. no dude.. still not...more work left

now to pack things up, you'll need a ramdisk.

so lets steal a ramdisk from a already working kernel (for stock kernel take stock ramdisk, for cm7/cm9 take respective ramdisk)

take any kernel and unpack it using instructions given here

the file ending with xyz.cpio.gz is the ramdisk. rename the file into "ramdisk" (without any extension) and put this file into the folder where you kept your zImage and wifi module.

Now transfer all these three files into a folder which is accessible from your Windows partition (oops... yeah... without windows you cannot finish this job)

Rest of the steps that follow are to be done on Windows (i have not tried on WINE)

rename zImage to "image"

now using this tool (courtesy DoomLord) pack your ramdisk and image into a flashable .ftf file

also make a copy of the file ar6000.ko and name it wifi.ko

both these ar6000.ko and wifi.ko files are supposed to be in the folder /system/lib/module of your mobile (please create appropriate flashable zip for the same)

===============================================================================================================

If you found this Guide helpful, please remember to press the thanks button ;P

================================================================================================================