[Samsung Galaxy W I8150] educk:
Hello guys!

Because the GT-i9001 (Galaxy S Plus) has a Kernel Building Tutorial, I decided to make one for the i8150 as these 2 devices are very similar.

This tutorial is based on this one by our Recognized Contributor, Xistance: /showthread.php?t=1966751. So all the credit goes to him!

First of all, you will need Ubuntu(it may work on other distros too, but Ubuntu is the most easy one to set up) these versions were tested:

14.04 - (this is were I build ROM's and Kernels)

13.10

12.10

12.04

10.04

Ok, so lets get started!

PART 1 - Installing Required Programs, Packages and Toolchains:

Android SDK

Download the SDK here: http://developer.android.com/sdk/index.html

Extract the SDK and place it in your home directory.

I rename the SDK to android-sdk to make it easier to navigate to.

Go to your home folder, press Ctrl+H to show hidden files, and open up your .bashrc file.

Add these lines at the bottom of the file(Change path according to your SDK dir):

# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin

Install required packages:

Open the Terminal and type:

sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 lib32ncurses5-dev x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Getting the Toolchain:

Open the terminal and type

mkdir android && cd android
mkdir kernel && cd kernel

Now clone this repo by DooMLoRD, these are precompiled toolchains, essential for compiling: (You can use any other linaro toolchains you want)

git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains

Make sure you have the toolchain folder in the Android folder as well as in the Kernel folder.

PART 2 - Getting the source, and making modifications:

Now we need to git clone the kernel source, this time I will use arco's github source:

cd android/kernel
git clone git://github.com/arco/samsung-kernel-msm7x30 -b ics-2.6

After -b you must specify the branch you want to clone, in this example, I used the ICS 2.6 branch.

After the repo is cloned you can modify/add features to kernel.

Examples in the second post.

PART 3 - Building the Kernel:

cd to your kernel directory:

cd android/kernel/samsung-kernel-msm7x30

Ok, now we need to set our target architecture and set the path to the toolchain we would like to use.

In this example, I will use the 4.6.2 toolchain downloaded above:

export ARCH=arm
export CROSS_COMPILE=~/android/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-

Now we need to load our configuration file, also, setting the board we would like to use, in this case, it is Ancora Board:

make ancora_defconfig

Than, we need to load menuconfing in order to apply the changes we made to the kernel (Governors, I/O schedulers, OC and so on)

make menuconfig

*Activating CPU Governors can be made under "CPU Power Management" Tab

*Activating I/O Schedulers can be made under "Enable block layer" tab

*OC can be activated under "System Type" tab

Now, the building will start after this command:

make -jx

x(max number of jobs per core)= number of CPU cores + 1 (for a QuadCore CPU there will be make -j5)

The building should take 5 to 10 minutes depending on your CPU.

PART 4 - Exporting the zImage and the modules

If the kernel compiled successfully you should see something like: zImage is ready.

Now, we need to export the zImage and the compiled modules into a folder:

A. Open a terminal
B. Change to your root kernel directory
C. Type "mkdir ../_output"
D. Type "cp arch/arm/boot/zImage ../_output/zImage"
E. Type "find . -name "*.ko" -exec cp {} ../_output \;"

Credits for this goes to Recognized Developer Hacre

PART 5 - Making the boot.img

Ok, this part is optional and it depends on your knowledge level.

The most easiest way to make the boot.img is using dsixda's Android Kitchen.

I recommend using this version from GT-i9001 forum as it is the same as for i8150: /showthread.php?t=1399468.

For this example, we built a zImage based on arco's sources for 2.6 kernel so we will need his ROM base.

Download the kitchen, and put the ROM (flashable ZIP) into the "original-update" folder.

Then, open up the kitchen (menu.sh) and press 1 (Set up working folder from ROM).

Choose your ROM and then press enter. After this we would like to go to 0 - Advanced Options and then 12 - Tools For Boot.img.

Here we need to press w to extract the content of the boot.img from the working directory.

Than, replace the zImage from BOOT-EXTRACTED with your zImage.

Also, you can put the compiled modules (.ko) inside /lib/modules in the RAMDISK folder

Now go back to the terminal and press b to build back your boot.img (which will be located in working folder)

PART 6 - Flashing the boot.img and Making Flashable ZIP

The compiled boot.img can be flashed to the device using adb like this: (If you don't know what adb is or how to use it, please search on Google/XDA for tutorials)

adb push boot.img /sdcard/boot.img
adb shell
su
dd if=/sdcard/boot.img of=/dev/block/mmcblk0p8
reboot

Commands explained:

adb push = it pushes the compiled boot.img to the internal sd card of the phone.

dd if = READ FROM FILE

dd of = WRITE TO FILE

mmcblk0p8 = the partition where the Kernel Image goes.

After that, we need to manually push the modules into /system/lib/modules on our phone. This can be done through adb like this:

adb push dhd.ko system/lib/modules/dhd.ko

This example is for dhd.ko module, which is required for WiFi.

For flashable ZIP, take one from another kernel and replace the boot.img.

Credits:

Xistance

broodplank

Hacre

DooMLoRD

Madridii (for helping to test the kernel on Galaxy W)

hotheabilly (for helping to test the kernel on Galaxy W)