how to build kernel

1,770 views
Skip to first unread message

talon1975

unread,
Nov 21, 2011, 12:32:02 AM11/21/11
to Android Linux Kernel Development
Hi all,

l download the kernel source from Samsung site and the arm-eabi
toolchine (4.4.0 and 4.4.3) from github.
When i build my kernel (2.6.35.7) on Linux machine the size of zImage
is 3.5M and it doesn't work, i found some kernels zImage files and the
size is 6.7M and bigger. I use the same defconfig file so I wonder
where is my problem?

Thanx
talon

s.rawat

unread,
Nov 21, 2011, 12:48:59 PM11/21/11
to android...@googlegroups.com
For whcih Device you are using it?
"..pain is temporary.....quitting lasts forever......"




Bridgette

unread,
Nov 21, 2011, 1:17:35 PM11/21/11
to android...@googlegroups.com
Hello Talon....

Samsung provides a txt file that details how to build the kernel...once your environment is set up correctly you should only need to run a script file that they provide, for example mine is called make_kernel_tass_vtr.sh.

If you take a look at the file it points to a specific config file to use I would use that one initially if your defconfig file is not the same....they also recommend the Codesourcery cross compiler (which that may or may not be the one that you mentioned)....



From: talon1975 <tal.al...@gmail.com>
To: Android Linux Kernel Development <android...@googlegroups.com>
Sent: Sunday, November 20, 2011 9:32 PM
Subject: [android-kernel] how to build kernel

Tal Alon

unread,
Nov 22, 2011, 2:31:28 AM11/22/11
to android...@googlegroups.com
Hi Bridgette,

I am trying to build kernel for galaxy S2 and for these device i didn't find any script to run. The txt file details 2 steps
first make config (mine is c1_rev02_defconfig) and second make.
My environment includes toolchines that provides with the NDK with no installation but i define the ARCH and CROSS_COMPILE macros before compilation.


Tal Alon

unread,
Dec 12, 2011, 9:06:30 AM12/12/11
to android...@googlegroups.com
Hi all
I am trying to build kernel for galaxy S2 with no success and i need some help for it.
I execute 2 steps first make config (c1_rev02_defconfig) and second make.
My environment includes toolchines that provides with the source tree and i define the ARCH and CROSS_COMPILE macros before compilation.
The compilation success and I receive zImage file (3.5MB to 4.6MB) depends on kernel version. 
What is the next step? How do i burn the new kernel to device? I tried to do it with odin but the device stuck.
What about the new modules of the new kernel compilation? what about file system?

Thanks a lot
Tal 

s.rawat

unread,
Dec 13, 2011, 9:22:32 AM12/13/11
to android...@googlegroups.com
I too got the same problem , 
I did it for samsung galaxy tab 7 inches, my kernel image is 3.5 mb where the actual is around 7 mb.When I flashed it using the heimdall or odin the tab remains atteh bootscreen and didnt go any further.I got frustrated at one time and unplugged the cable and it resulted in the soft brick of my tablet,But thanks to some video on yotube I got it back.Now I am looking out for the correct building of the kernel .
I came to know frmo one of my frnd @samsung that i need to extract and repack the rootfs into the zimage.
Plz post your comments.
xda forum is the sight to look out for 
Rgds,
Saurabh

"..pain is temporary.....quitting lasts forever......"



Jeremy Morales

unread,
Dec 13, 2011, 9:30:04 AM12/13/11
to android...@googlegroups.com
Sounds like your def_config isn't correct.

s.rawat

unread,
Dec 13, 2011, 9:39:08 AM12/13/11
to android...@googlegroups.com
I downloaded 
GT-P1000_OpenSource.zip frmo the open source 
It has --> Android  build.sh  GT-P1000_Kernel.tar.bz2   GT-P1000_Platform.tar.bz2  kernel  README.txt

I followed teh README


1. How to Build
        - get Toolchain
                From Code Sourcery site ( www.codesourcery.com )

                recommand : later than 2009q3 version.
                                        Feature : ARM
                                        Target OS : "EABI"
                                        package : "IA32 GNU/Linux TAR"

        - edit build_kernel.sh
                edit "TOOLCHAIN" and "TOOLCHAIN_PREFIX" to right toolchain path(You downloaded).
                Ex)  30 TOOLCHAIN=/usr/local/toolchain/arm-2009q3/bin/          // check the location of toolchain
                     31 TOOLCHAIN_PREFIX=arm-none-gnueabi-                      // You have to check.

        - run build_kernel.sh
                $ ./build_kernel.sh

2. Output files
        - Kernel : Kernel/arch/arm/boot/zImage
        - module : Kernel/drivers/*/*.ko

3. How to Clean
        - run build_kernel.sh Clean
                $ ./build_kernel.sh Clean

4. How to make .tar binary for downloading into target.

        - change current directory to Kernel/arch/arm/boot
        - type following command
                $ tar cvf gt-p1000-kernel.tar zImage


and the  result is no further boot screen.

where do you want to point out.???You want to assist in this..would be grateful .!
Rgds,
Saurabh


"..pain is temporary.....quitting lasts forever......"



Vincenzo Ciaglia

unread,
Dec 13, 2011, 12:16:02 PM12/13/11
to android...@googlegroups.com
Hi, we have the same problems here.

We successfully re-compile the Samsung Android kernel sources but we
get a zImage of just 3.1MB that doesn't boot the TAB.

It seems there's a lack of something (lack of informations too!)
compared to the official Samsung P1000 zImage (~7MB).

Someone could help?

Thanks in advance.

Have a nice day,

2011/12/13 s.rawat <imsaura...@gmail.com>:

--
Vincenzo Ciaglia

Mobile: +39 392.4428505
E-mail: vcia...@0inf.com
-----------------------------------

Kiran Kumar Raparthy

unread,
Dec 13, 2011, 6:56:56 AM12/13/11
to android...@googlegroups.com
Hi Tal,
Usually your Bootloader will launch the kernel image in any kind of linux systems.
So you have to create the kernel image to be compatible with bootloader(Which adds the Header,size and CRC),so that when launching the kernel, bootloader verifies the header,gets the kernel image based on the size and calculates the CRC and verifies,when successful,gives control to kernel.
If your compiling the kernel in android source,it creates the filesystem image too.If not,probably you have to compile the filesystem and create the File system image based on your requirement and burn the same.

Also the address where you are burning the images in the flash is also important,as bootloader reads the kernel header from a fixed location so you have to load the kernel at that fixed address only.

Regards,
Kiran

s.rawat

unread,
Dec 13, 2011, 2:32:03 PM12/13/11
to android...@googlegroups.com
HI Kiran, 
Do you have the set of instructions for the same.Plz send or direct us to any such link.That will life saver for all of us.
Rgds,
Saurabh
"..pain is temporary.....quitting lasts forever......"



Tal Alon

unread,
Dec 13, 2011, 2:43:49 PM12/13/11
to android...@googlegroups.com
Hi
I download the source directory of android brunch 2.3.5 and compiled it to receive the filesystem. I got an empty filesystem (~150KB)  and added under /lib/modules/ the new 7 modules from the kernel compilation.
The next step was to mkbootfs to recreate the new file system and then mkbootimg from the new kernel and filesystem. The image that i received is ~5.3MB and it does not boot on the device.
The mkbootfs and mkbootimg i compiled from the android source direcory from 2.3.5 brunch.
When i download kernel from XDA i get zImage ~6.4MB and i failed to extract the filesystem from it (with some tools which i found at making kernel guides), But the downloading to the device success and the device boots well.
I tried these process with kernel from samsung open source update 1,2,3 with no success, I used default def_config as mentioned at kernel compilation instructions. 
I still don't understand what i do wrong, 
H E L P

Tal

petter

unread,
Dec 14, 2011, 1:13:54 AM12/14/11
to Android Linux Kernel Development
I think that your problem is, that samsung uses initramfs in kernel
image, so theirs modules(and other files) are packed in zImage, so if
are some of these modules(files) not open, you must extract them from
orig. kernel, put them into your kernel and pack your kernel with all
these modules(files). you must make same root structure like orig.
kernel do, if you want to boot samsung's rom.

> > On Mon, Dec 12, 2011 at 7:36 PM, Tal Alon <tal.alon1...@gmail.com> wrote:
>
> >> Hi all
> >> I am trying to build kernel for galaxy S2 with no success and i need some
> >> help for it.
> >> I execute 2 steps first make config (c1_rev02_defconfig) and second make.
> >> My environment includes toolchines that provides with the source tree and
> >> i define the ARCH and CROSS_COMPILE macros before compilation.
> >> The compilation success and I receive zImage file (3.5MB to 4.6MB)
> >> depends on kernel version.
> >> What is the next step? How do i burn the new kernel to device? I tried to
> >> do it with odin but the device stuck.
> >> What about the new modules of the new kernel compilation? what about file
> >> system?
>
> >> Thanks a lot
> >> Tal
>

> >> On Tue, Nov 22, 2011 at 9:31 AM, Tal Alon <tal.alon1...@gmail.com> wrote:
>
> >>> Hi Bridgette,
>
> >>> I am trying to build kernel for galaxy S2 and for these device i didn't
> >>> find any script to run. The txt file details 2 steps
> >>> first make config (mine is c1_rev02_defconfig) and second make.
> >>> My environment includes toolchines that provides with the NDK with no
> >>> installation but i define the ARCH and CROSS_COMPILE macros before
> >>> compilation.
>

> >>> On Mon, Nov 21, 2011 at 8:17 PM, Bridgette <tbridge...@yahoo.com> wrote:
>
> >>>>  Hello Talon....
>
> >>>> Samsung provides a txt file that details how to build the kernel...once
> >>>> your environment is set up correctly you should only need to run a script
> >>>> file that they provide, for example mine is called make_kernel_tass_vtr.sh.
>
> >>>> If you take a look at the file it points to a specific config file to
> >>>> use I would use that one initially if your defconfig file is not the
> >>>> same....they also recommend the Codesourcery cross compiler (which that may
> >>>> or may not be the one that you mentioned)....
>

> >>>>   ------------------------------
> >>>> *From:* talon1975 <tal.alon1...@gmail.com>
> >>>> *To:* Android Linux Kernel Development <android...@googlegroups.com>
>
> >>>> *Sent:* Sunday, November 20, 2011 9:32 PM
> >>>> *Subject:* [android-kernel] how to build kernel


>
> >>>> Hi all,
>
> >>>> l download the kernel source from Samsung site and the arm-eabi
> >>>> toolchine (4.4.0 and 4.4.3) from github.
> >>>> When i build my kernel (2.6.35.7) on Linux machine the size of zImage
> >>>> is 3.5M and it doesn't work, i found some kernels zImage files and the
> >>>> size is 6.7M and bigger. I use the same defconfig file so I wonder
> >>>> where is my problem?
>
> >>>> Thanx
> >>>> talon
>
> >>>> --

s.rawat

unread,
Dec 14, 2011, 2:43:55 AM12/14/11
to android...@googlegroups.com
Petter You are correct.I followed the same.But I doubt there will be some MD5 checksum ssociated with it which I dont  have any clue.
"same root structure like orig"..hmmm..i could try this as well.
plz if some one who has success in this , do report(in either SGT or SGS )

Rgds,
Saurabh

"..pain is temporary.....quitting lasts forever......"



abr

unread,
Dec 14, 2011, 2:20:20 PM12/14/11
to android...@googlegroups.com
Short Question: If I Download the complete Android source via repo is the kernel and build of part of it?
I've followed instructions from http://source.android.com on a Ubuntu 11.10 64 Bit Virtual Maschine but couldn't complete the build without errors yet.
I'm especially interested in the kernel also is there a bether approach then source.android.com?
BTW In the Android src docs I found files of some .md format my ubuntu not yet know and I can't find infos googling for...

petter

unread,
Dec 15, 2011, 3:15:30 AM12/15/11
to Android Linux Kernel Development
I am working on SGS porting, and when I had phone new, I'd started
with compiling original kernel and samsung rom booted with my kernel(I
extracted initramfs from orig. zImage and used him for my kernel). I
remember that for samsung kernel you need www.codesourcery.com
toolchain, when I tryed toolchain from android prebuild dir, kernel
crashed. Maybe you can compile whole android for your device +
kernel(initramfs you should point to out/target/product/$name/rootdir)
and you will see. you can boot your OS from sdcard(ext4 partition), so
your orig. samsung rom can be still in your device internal memory, so
when device will be stuck, you can still boot into orig. rom by
flashing orig. kernel back

On 14 pro, 08:43, "s.rawat" <imsaurabhra...@gmail.com> wrote:
> Petter You are correct.I followed the same.But I doubt there will be some

> MD5 *checksum *ssociated with it which I dont  have any clue.

Tal Alon

unread,
Dec 15, 2011, 7:14:47 AM12/15/11
to android...@googlegroups.com
Hi all,

Does someone success in building new kernel (with modules) and burn it to device successfully and can share with us the main stages of doing IT (with detailed explanation please).

10x
Tal

manoj gupta

unread,
Dec 15, 2011, 10:53:40 PM12/15/11
to android...@googlegroups.com
hi ,
Please find the method to build android source code.
Get Android source code
./build/envsetup.sh
lunch 1
make -j4
Regards
Manoj Kumar Gupta

On Mon, Nov 21, 2011 at 11:02 AM, talon1975 <tal.al...@gmail.com> wrote:

s.rawat

unread,
Dec 15, 2011, 11:32:26 PM12/15/11
to android...@googlegroups.com
HI Manoj,
whats the zImage size you got and were you able to successfully flash it on any of the device.
RGds,

Saurabh
"..pain is temporary.....quitting lasts forever......"



manoj gupta

unread,
Dec 15, 2011, 11:38:45 PM12/15/11
to android...@googlegroups.com
Hi,
I dont have any idea about this but you follow this method to unlock and flashing all application in any device iand in between you need to chose your device
Get Android source code
./build/envsetup.sh
lunch 1
make -j4
adb reboot bootloader
fastboot oem unlock
fastboot flashall -w
Regards
manoj

Tal Alon

unread,
Dec 19, 2011, 8:02:10 AM12/19/11
to android...@googlegroups.com
Hi,

I am asking for kernel compilation and downloading process and for android application.
Thanks anyway.

Does someone succeed?

Tal 

Tal Alon

unread,
Dec 19, 2011, 9:37:17 AM12/19/11
to android...@googlegroups.com
Hi,

I am asking for kernel compilation and downloading process and not for android application.
Thanks anyway.

Does someone succeed?

Tal 

cd

unread,
Dec 15, 2011, 8:12:17 AM12/15/11
to Android Linux Kernel Development
This gonna be a long post!
Samsung kernels have a initramfs
so
get the stock zImage, and then unpack it(a chinese guy posted an
unpacker on xda (sgs2 dev sub-forum), it works fine for me with sgs/
tab/s2 kernels

Once you have extracted the initramfs, open up your deconfig, and set
the path to it
Then compile, and it should boot fine.

P.S. The first line was meant to be correct, but i dont wanna do
that :D , but if you need any help, feel free to ask :)

s.rawat

unread,
Dec 19, 2011, 2:18:47 PM12/19/11
to android...@googlegroups.com
I tried even this too, I may have misconifgured the step but what I know is that after 
combining it along with the initramfs(aka rootfs) either by giving the path in deconfig or manually tarring it using xvf .The kernel zimage does comes out to be bigger than previous one(~6.5 mb) but on flashing it via odin or heimdall the boot screen couldn't go any further.
Can you plz post your experience if you have actually done hands on it.
Rgds,
saurabh

"..pain is temporary.....quitting lasts forever......"



cd

unread,
Dec 23, 2011, 2:17:11 AM12/23/11
to Android Linux Kernel Development
i just give the path in deconfig, n then compile

Use this as a reference : https://github.com/sgt7/p1000-kernel-cm9

Tal Alon

unread,
Dec 29, 2011, 10:13:48 AM12/29/11
to android...@googlegroups.com
Hi all,

Finally I success to build my own kernel it works fine and i add some drivers for my kernel too.
Building SGS2 kernel in x steps:
  1. Download from samsung open source site the kernel tree (i used samsung_kernel_update2)
  2. Download android ndk (for CROSS_COMPILE, i used /android-ndk-r5b)
  3. you need basic ramdisk (you can compile samsung platform or download from http://forum.xda-developers.com/showthread.php?t=1294436 (thanks to Chenglu)
  4. if you want to edit your kernel config file make ARCH=arm menuconfig or default make ARCH=arm c1_rev02_defconfig
  5. compile the kernel with: make ARCH=arm CROSS_COMPILE=/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-        
  6. copy all kernel modules to new directory ramdisk/lib/modules (the default is 7 modules)
  7. open your .config file and add the path to your ramdisk (CONFIG_INITRAMFS_SOURCE="/ramdisk")
  8. compile the kernel make ARCH=arm CROSS_COMPILE=/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-
  9. under /arch/arm/boot you receive the zImage 
  10. tar -cvf new_I9100.tar zImage
  11. use odin to burn your new kernel (PDA)
good luck

s.rawat

unread,
Dec 29, 2011, 10:31:47 AM12/29/11
to android...@googlegroups.com
Awwsssomessssssssss work Tal..I will try this soon and post the result !!!
Rgds,
Saurabh

"..pain is temporary.....quitting lasts forever......"



Reply all
Reply to author
Forward
0 new messages