[KERNEL]How to build a custom Android Kernel for your device

Search This thread

irfanbagus

Senior Member
Mar 12, 2012
307
498
it's not working. sgy stock kernel do not have /proc/config.gz and gcc version in arm-2011.03 not compatible with other precompiled module.

this is work for me

requirement :
1. linux box 32 bit with working gcc. you can use real linux machine or virtual machine
2. Sourcery G++ Lite 2009q3-68 toolchain for ARM EABI from http://www.codesourcery.com/ (Linux version without installer arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2)
3. mkbootimg with md5support. got it from http://xdaforums.com/showpost.php?p=22224170&postcount=241 . credit to harish2704
4. split_bootimg.pl (google it)
5. kernel source from http://opensource.samsung.com . i use GT-S5360_GB_Opensource_Update2.zip
6. stock boot.img (or from your custom kernel).

step :
1. make folder "sgy" in your home. the result is folder "/home/<yourname>/sgy". <yourname> is your linux user name, and from now replace <yourname> with your user name. put all file you already download there
2. extract "GT-S5360_Kernel.tar.gz" from "GT-S5360_GB_Opensource_Update2.zip". put also in "sgy" folder
3. open terminal emulator and go to your working path with command

Code:
cd ~/sgy

4. extract your compiler with

Code:
tar -xvf arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2

5. create folder "kernel" and extract kernel source there

Code:
mkdir kernel
cd kernel
tar -xvf ../GT-S5360_Kernel.tar.gz

you got 2 folder, "common" and "modules"

6. open folder "common", there is file "Makefile". open with text editor and find line with content "/opt/toolchains/arm-eabi-4.4.3/bin/arm-eabi-". replace with "/home/<yourname>/sgy/arm-2009q3/bin/arm-none-eabi-", don't forget replace <yourname>.

7. in terminal goto folder "common" and load default config for sgy

Code:
cd ~/sgy/kernel/common
make bcm21553_totoro_05_defconfig

8. if you want change you config run

Code:
make menuconfig

9. if you ready to build then run

Code:
make

or if you have dual core cpu and want to make it faster

Code:
make -j3

10. when complete and no error appear, copy your kernel to "sgy" folder

Code:
cp arch/arm/boot/zImage ~/sgy

11. extract ramdisk from your boot.img

Code:
cd ~/sgy/
perl split_bootimg.pl boot.img

you got "boot.img-kernel" and "boot.img-ramdisk.gz". move "boot.img" and "boot.img-kernel" to other place.

12. repack your new kernel and ramdisk. but first get md5sum of your new kernel

Code:
md5sum zImage

you got something like

Code:
1fd319aa60abc2abae2e5932bcb9fc77  zImage

you need that "1fd319aa60abc2abae2e5932bcb9fc77" write it or copy to text editor. you need run it every time compile new kernel

13. repack

Code:
chmod +x mkbootimg
./mkbootimg --kernel zImage --ramdisk boot.img-ramdisk.gz --base 0x81600000 --kernelMD5 <your md5sum result> -o boot.img

14. make odin flash-able

Code:
tar -cf boot-sgy.tar boot.img
 
Last edited:

kurotsugi

Senior Member
Feb 12, 2012
2,507
1,796
yogyakarta
offtopic:
btw, do you know who's working on cm7 from source with motafoca?his thread is missing and I just get curious on their progress.
 

PREMOLIKES

Senior Member
Mar 23, 2009
1,202
105
Imphal
offtopic:
btw, do you know who's working on cm7 from source with motafoca?his thread is missing and I just get curious on their progress.

His thread was closed by moderator.You can request MOD to reopen his thread.Motafoca wanted a galacy y to be lended for his experiments

---------- Post added at 03:37 PM ---------- Previous post was at 03:33 PM ----------

Can someone download the sources around 15Gigs and stripe down the file and share it to Maroc ?
 

irfanbagus

Senior Member
Mar 12, 2012
307
498
I thought you have to put your post into a new thread irfan...this one is a fake guide.
i don't call it fake. it's just too general and missing some detail (but critical) for our device. and in the 'spirit of operation iron fist', i think it's better to put here :D

Irfan must create a guide.yes yes..I also think Irfan sahab must compile a CM7.2 from sources.
with my internet connection, it will take weeks just to download the source. and i think cm, like android source, use repo. so you can't just download it. you clone it from their source repository, that mean no download accelerator.

btw beside kernel source, samsung also release their mod to android source. but to build it, you still need to get android source (about 10GB according their website).
 
  • Like
Reactions: TheDeadEnd

kurotsugi

Senior Member
Feb 12, 2012
2,507
1,796
yogyakarta
well...thats your choice, irfan.

@sgy.creed: sorry, I don't mean to offend you. IMHO it will be nice if before someone post any guide they already have tested it by them. in this way, they'll able to give more accurate direction to anyone who need their guide. as we already know, kernel is crucial part in our device. any mistake in compiling it will lead to brick our device. we have to cautious on it. peace ^,^v
 

irfanbagus

Senior Member
Mar 12, 2012
307
498
well...thats your choice, irfan.

@sgy.creed: sorry, I don't mean to offend you. IMHO it will be nice if before someone post any guide they already have tested it by them. in this way, they'll able to give more accurate direction to anyone who need their guide. as we already know, kernel is crucial part in our device. any mistake in compiling it will lead to brick our device. we have to cautious on it. peace ^,^v

if you (or others) think it's better to put in other thread, or maybe op wanna edit his post, fell free to copy my post (or just link, it's up to you). i don't take any credit to that post, because it just recompilation from other thread.
 

Rui Oliveira 21

Senior Member
Apr 8, 2012
234
17
Braga
GT-B5510

Is there by chance anyway to find a stock Kernel for my device for my GT-B5510???

I recently flashed a custom Kernel for GT-S5360 and the result was a Brick.


is there someone willing to help me??
 

Harsh06

Senior Member
Mar 1, 2012
177
49
Shah Alam
Is there by chance anyway to find a stock Kernel for my device for my GT-B5510???

I recently flashed a custom Kernel for GT-S5360 and the result was a Brick.


is there someone willing to help me??

Have u tried through kies?if the answer u failed then only odin is the way.
u need pda files from the update.Search google,i found one FW but it is from Italy :
B5510CEKK1.
 
  • Like
Reactions: Rui Oliveira 21

whitexp

Senior Member
Jan 3, 2012
1,071
3,205
Rio De Janeiro
madteam.co
Amazfit
Hi guys,
This guide teaches how to make a new kernel for your device, it works in most of the cases but doesnt mean it will work for everyone
You need a minimal linux experice to know WTF you are doing
If you have any questions, post Belloowww
Download the required files
You will need a linux machine with the basic development tools or a virtualbox machine running a linux distribution (ubuntu 64bits will do fine)
I use the codesourcery package
Download the IA32 GNU/Linux TAR
The tar package is the easier to install
You will also need your kernel source from your manufacturer, for samsung the sources are available here

Install the cross compiler
Enter the folder were you downloaded the package and extract it, you will get something like arm-2011.03
Move that folder to some location, i use opt
ex: mv arm-2011.03 /opt/
or
sudo mv arm-2011.03 /opt
Done!

Extract and prepare the kernel sources
I will use the samsung sources as example, but anything can be used
For the samsung sources, after you extract the zip, you will get something like DEVICE_Platform.tar and DEVICE_Kernel.tar.gz
Extract the kernel:
tar zxvf DEVICE_Kernel.tar.gz
Enter the kernel folder and list the folder contents
ls
The structure is something like this:
kernel-sources.png

Most devices contain the config file inside the device
You can extract it like this:
adb shell
su
cp /proc/config.gz /sdcard/
exit
exit
adb pull /sdcard/config.gz
Good, now we have the sources, compiler and configuration

Compiling the kernel
To compile ther kernel, i usually clean the sources first, with this i know for sure nothing will go wrong (usually )
make ARCH=arm CROSS_COMPILE=/opt/arm-2011.03/bin/arm-none-eabi- distclean (Remember to replace acordingly the compiler folder)
Sources cleaned, time to load the config file
gunzip config.gz
cp config ./.config
Good, now lets check the menuconfig (menuconfig is a menu to choose the kernel options, created to make it easy to select)
make ARCH=arm CROSS_COMPILE=/opt/arm-2011.03/bin/arm-none-eabi- menuconfig
Change whatever you want and exit and save
good, now its time to build
make ARCH=arm CROSS_COMPILE=/opt/arm-2011.03/bin/arm-none-eabi- -j2
Now wait for it to finish!
Your compiled kernel will be located inside arch/arm/boot/zImage

Extracting a boot.img
Good, now we have the zImage, but WTF to do with it?
Well, android usually (some samsung devices use a different boot.img method, ex: I9000) has the boot.img, inside of it we contain:
- ramdisk (required files to load the /system partition and continue the boot sequence)
- zImage (our kernel)
- pagesize
- base
- cmdline (some kernel paremetes used on boot)

To create your own boot.img, you need one from a nandroid backup that was made from CWM or AmonRA custom recoveries (there are other methods, but for those use the madteam forum )
The boot.img is located inside your /sdcard/clockworkmod/backup/somedate/boot.img
You will also need the unpackbootimg and mkbootimg binaries, i this link there is the 64 bit version (wont work on 32 bit linux)
create an empty folder, copy the downloaded file inside, enter it and do:
tar zxvf bootimgtools.tar.gz
chmod 755 *
now copy the boot.img you got from the backup
and extract the boot.img with:
./unpackbootimg -i boot.img
this will create the files as explained above

Creating the boot.img
Before making the boot.img, we need some information from the files extracted
cat boot.img-base ( save the output #1)
cat boot.img-pagesize (save the output , place the value inside the Hex Value of this site, and copy the decimal value and save it #2)
cat boot.img-cmdline (save the output #3)

Good, now copy the compiled kernel (zImage) inside the current folder and do:
mkbootimg –kernel zImage –ramdisk boot.img-ramdisk.gz –cmdline “(replace with output#3)” –base (replace withoutput #1) –pagesize (replace with output#2) -o /tmp/boot.img
Good, the boot.img is created!
Now test on your device!

If you dont know how to flash the boot.img, enter the madteam forum and request help (its too difficult to explain the flashing of boot.img if you dont know how to do it )

Take care!

<External link removed>

please credits motafoca madteam
 

Rui Oliveira 21

Senior Member
Apr 8, 2012
234
17
Braga
GT-B5510

Have u tried through kies?if the answer u failed then only odin is the way.
u need pda files from the update.Search google,i found one FW but it is from Italy :
B5510CEKK1.

Kies said that I had the most recent firmware, tough I found some new versions.

right now trough kies I tried to do an emergency firmware restore, i guess thats the name, but it asked for a code, a 4 number code i guess and i dont know what's the code.

Via odin I tried to install stock firmware from sammobile but it failled as well, if you want I'll post the dialog from odin.

I can boot in recovery mode, Odin(download) mode and CWM mode.

could you point me in the right direction???


thanks for your time ;)
 

Harsh06

Senior Member
Mar 1, 2012
177
49
Shah Alam
Kies said that I had the most recent firmware, tough I found some new versions.

right now trough kies I tried to do an emergency firmware restore, i guess thats the name, but it asked for a code, a 4 number code i guess and i dont know what's the code.

Via odin I tried to install stock firmware from sammobile but it failled as well, if you want I'll post the dialog from odin.

I can boot in recovery mode, Odin(download) mode and CWM mode.

could you point me in the right direction???


thanks for your time ;)
I believe Doky already reply your post n willing to help u in others thread.Give doky some info about your current FW.U need 3 complete files n flash through Odin.Key in *#1234# with your dialer(u will see current info version) and PM doky about the info.He surely gonna help u.
Sorry OP off topic.
 

Rui Oliveira 21

Senior Member
Apr 8, 2012
234
17
Braga
GT-B5510

He did help, thanks ;)

question now is...while trying to revive the phone I installed Creed's Rom for Gt-s5360, I got quiet, and obviously it doesnt work that well in my GT-B5510, so I need a custom Rom for my device or a Stock Rom, but I cant find neither :S

any lights??
 

savie

Senior Member
Feb 8, 2012
848
626
Kernel

How to change Kernel Version when build kernel ??
usually display 2.6.35.7 root@dpi #1
i wanna change root@dpi #1 :confused: so how the setting on linux or maybe what file??
Thanks b4 :)
 

Dreamboxuser

Senior Member
Jan 24, 2012
380
83
He did help, thanks ;)

question now is...while trying to revive the phone I installed Creed's Rom for Gt-s5360, I got quiet, and obviously it doesnt work that well in my GT-B5510, so I need a custom Rom for my device or a Stock Rom, but I cant find neither :S

any lights??

I was just wondering if you went to the oldest possible firmware you could find and then proceeded to update from that. Sometimes the updates only contain necessary info and kind of rely on the previous installs.

Sent from my TF101 using Crashntalk 2
 

Top Liked Posts

  • There are no posts matching your filters.
  • 71
    it's not working. sgy stock kernel do not have /proc/config.gz and gcc version in arm-2011.03 not compatible with other precompiled module.

    this is work for me

    requirement :
    1. linux box 32 bit with working gcc. you can use real linux machine or virtual machine
    2. Sourcery G++ Lite 2009q3-68 toolchain for ARM EABI from http://www.codesourcery.com/ (Linux version without installer arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2)
    3. mkbootimg with md5support. got it from http://xdaforums.com/showpost.php?p=22224170&postcount=241 . credit to harish2704
    4. split_bootimg.pl (google it)
    5. kernel source from http://opensource.samsung.com . i use GT-S5360_GB_Opensource_Update2.zip
    6. stock boot.img (or from your custom kernel).

    step :
    1. make folder "sgy" in your home. the result is folder "/home/<yourname>/sgy". <yourname> is your linux user name, and from now replace <yourname> with your user name. put all file you already download there
    2. extract "GT-S5360_Kernel.tar.gz" from "GT-S5360_GB_Opensource_Update2.zip". put also in "sgy" folder
    3. open terminal emulator and go to your working path with command

    Code:
    cd ~/sgy

    4. extract your compiler with

    Code:
    tar -xvf arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2

    5. create folder "kernel" and extract kernel source there

    Code:
    mkdir kernel
    cd kernel
    tar -xvf ../GT-S5360_Kernel.tar.gz

    you got 2 folder, "common" and "modules"

    6. open folder "common", there is file "Makefile". open with text editor and find line with content "/opt/toolchains/arm-eabi-4.4.3/bin/arm-eabi-". replace with "/home/<yourname>/sgy/arm-2009q3/bin/arm-none-eabi-", don't forget replace <yourname>.

    7. in terminal goto folder "common" and load default config for sgy

    Code:
    cd ~/sgy/kernel/common
    make bcm21553_totoro_05_defconfig

    8. if you want change you config run

    Code:
    make menuconfig

    9. if you ready to build then run

    Code:
    make

    or if you have dual core cpu and want to make it faster

    Code:
    make -j3

    10. when complete and no error appear, copy your kernel to "sgy" folder

    Code:
    cp arch/arm/boot/zImage ~/sgy

    11. extract ramdisk from your boot.img

    Code:
    cd ~/sgy/
    perl split_bootimg.pl boot.img

    you got "boot.img-kernel" and "boot.img-ramdisk.gz". move "boot.img" and "boot.img-kernel" to other place.

    12. repack your new kernel and ramdisk. but first get md5sum of your new kernel

    Code:
    md5sum zImage

    you got something like

    Code:
    1fd319aa60abc2abae2e5932bcb9fc77  zImage

    you need that "1fd319aa60abc2abae2e5932bcb9fc77" write it or copy to text editor. you need run it every time compile new kernel

    13. repack

    Code:
    chmod +x mkbootimg
    ./mkbootimg --kernel zImage --ramdisk boot.img-ramdisk.gz --base 0x81600000 --kernelMD5 <your md5sum result> -o boot.img

    14. make odin flash-able

    Code:
    tar -cf boot-sgy.tar boot.img
    21
    here is the guide

    http://xdaforums.com/showpost.php?p=24747881&postcount=4


    thakz irfanbagus for the guide :)
    2
    I used google.
    The most powerful tool. :p

    Sent from my GT-S5360 using xda app-developers app

    lol, how can you find it in google if nobody ever wrote it. can you find guide to build kernel for galaxy y which not related to harish2704 post and write before 6 february ?
    2
    To both.

    zImage compiled using a good source and correct method as stated by samsung is always good to go.

    The only thing you need is a working ramdisk to combine that image with.

    make xx_xx_xx_defconfig
    make -j4

    This is the easiest way to compile (only make commands are given above)

    you still don't understand. i know how to compile kernel. i already have more than dozen kernel in my pc. in fact i write this step/tutorial more than a month after i did my first bootable kernel.

    the real problem with samsung guide is it does not tell you how to install compiled kernel. back before february, few people already try to make custom kernel. none working. not before harish2704 find that we need mkbootimg which support md5 checksum. he post it here, in 6 feb, a month before meruk release his kernel for the first time.

    the funny thing is all people waiting for custom kernel at that time, but nobody seem to care about his post.
    1
    I thought you have to put your post into a new thread irfan...this one is a fake guide.
    i don't call it fake. it's just too general and missing some detail (but critical) for our device. and in the 'spirit of operation iron fist', i think it's better to put here :D

    Irfan must create a guide.yes yes..I also think Irfan sahab must compile a CM7.2 from sources.
    with my internet connection, it will take weeks just to download the source. and i think cm, like android source, use repo. so you can't just download it. you clone it from their source repository, that mean no download accelerator.

    btw beside kernel source, samsung also release their mod to android source. but to build it, you still need to get android source (about 10GB according their website).