[HOW TO] Compile and Deploy a Kernel

tasinofan

Senior Member
Jan 13, 2013
92
23
thanks mcl630 vampirefo to confirm and for all your expert help

fwiw my boot.img also contains a bootimg.cfg (I unpacked it with abootimg)

have a nice day and upcoming weekend
 

vampirefo.

Senior Member
Developer
Nov 8, 2011
3,836
1,394
thanks mcl630 vampirefo to confirm and for all your expert help

fwiw my boot.img also contains a bootimg.cfg (I unpacked it with abootimg)

have a nice day and upcoming weekend

abootimg isn't a good tool to work on boot.img but yes it creates a bootimg.cfg for any boot.img it separates.
A boot.img is a ramdisk and kernel, forget about abootimg, honesty it's not a good tool for boot.img.
 

tasinofan

Senior Member
Jan 13, 2013
92
23
Thanks vampirefo for telling about abootimg

This program is mentioned in this very thread in a step to flash own kernel ...

Which tool or program then do you recommend to unpack boot.img and/or how do you remake a boot.img to flash a custom built kernel?

have a nice day
 

vampirefo.

Senior Member
Developer
Nov 8, 2011
3,836
1,394
Thanks vampirefo for telling about abootimg

This program is mentioned in this very thread in a step to flash own kernel ...

Which tool or program then do you recommend to unpack boot.img and/or how do you remake a boot.img to flash a custom built kernel?

have a nice day

unpackbootimg is the best binary tool around for unpacking boot.img to repack use mkbootimg.

if you look at my build script you see the kernel once built is automatically repacked with ramdisk resulting into a boot.img, that is ready to flash.


Code:
make -j5

cd $makeboot
rm -rf ./zImagejb_4.2
rm -rf ./jb_4.2.img

#build boot.img
cp $zImage $makeboot/zImagejb_4.2
./repack-bootimg.pl ./zImagejb_4.2 $initramfs ./jb_4.2.img

what above code says and does.

make -j5 means to build kernel using 5 one number above my quad core.

cd $makeboot means once kernel is built go to directory where I want boot.img to be built.

rm -rf ./zImagejb_4.2 means remove any kernels named zImagejb_4.2

rm -rf ./jb_4.2.img means remove any boot.img named jb_4.2.img

cp $zImage $makeboot/zImagejb_4.2 means copy the kernel just built to directory I want boot.img to be built, rename zImage to zImagejb_4.2

./repack-bootimg.pl ./zImagejb_4.2 $initramfs ./jb_4.2.img means use prebuilt packing script (repack-bootimg.pl) and newly built kernel (zImagejb_4.2) and ramdisk (initramfs) to build boot.img (jb_4.2.img) that is ready to flash.
 
Last edited:

tasinofan

Senior Member
Jan 13, 2013
92
23
thanks vampirefo

I also found source code for all such programs so I could build and now I can run them on my dual cpu 6core 64bit gentoo (hence -j13) ;-)

have a nice day
 

FloRider

Senior Member
Dec 2, 2012
358
111
thanks vampirefo

I also found source code for all such programs so I could build and now I can run them on my dual cpu 6core 64bit gentoo (hence -j13) ;-)

have a nice day

OK guys, sorry I haven't been around for a while. I'll try to keep up with the board -- the members have really made this an awesome place.

Anyway, the figure of cores + 1 is a calculation I read somewhere that I reprinted without much experience. I've since found that a value somewhere around cores x 2 is quite a bit faster. I recommend that you experiment with higher values than I initially recommended to see what works best for your system. (I use 10 or even 12 jobs)

Sent from my IdeaTabA2109A using Tapatalk HD
 

tasinofan

Senior Member
Jan 13, 2013
92
23
Thanks Florider for your reaction

My dedicated build computer does also cross build 3 gentoo machines with -j13 so I think it really uses its CPUs and cores well (often all near 100%).

However, if all it has to do is build one kernel, then, as you suggest, next time I will try -j24

Have a nice day
 

AndreasWatch

Member
Dec 11, 2012
29
9
Hey Guys,
wich toolchain are you using for the jb kernel? I tried different toolchains and removed XMM_POWER2, BCMDHD_FXN_195_89 and VIDEO_S5K5CAG because of compiling errors but it is not booting.
With the ICS source, I haven't had this problems...
 

vampirefo.

Senior Member
Developer
Nov 8, 2011
3,836
1,394
Hey Guys,
wich toolchain are you using for the jb kernel? I tried different toolchains and removed XMM_POWER2, BCMDHD_FXN_195_89 and VIDEO_S5K5CAG because of compiling errors but it is not booting.
With the ICS source, I haven't had this problems...

Linaro toolchain is what I use.
 

AndreasWatch

Member
Dec 11, 2012
29
9
I tried several toolchains but can`t build a running kernel.
Could you please share whats special with yours? Or what I have to modify on the standard toolchain to get a running kernel?
Is there any other who can build the JB kernel?
For me it looks like that there is a error in the source, but I can not find the exact problem :/
 

vampirefo.

Senior Member
Developer
Nov 8, 2011
3,836
1,394
I am not sure what you are doing to your source, but if a kernel is built and added to ramdisk as a boot.img it will boot, run logcat and see what is happening.
 

AndreasWatch

Member
Dec 11, 2012
29
9
I'm sorry for the inconvenience and thank you, I can now build and boot the kernel.
I misunderstood you...I thought that the kernel can only build correctly with a customized tool chain, but the problem was really at the source and at the initramfs.
I have no idea what was wrong, but after I unpacked both new it worked.
If anyone is interested in it: I'm using the toolchain provided by CM.
 

vampirefo.

Senior Member
Developer
Nov 8, 2011
3,836
1,394
I'm sorry for the inconvenience and thank you, I can now build and boot the kernel.
I misunderstood you...I thought that the kernel can only build correctly with a customized tool chain, but the problem was really at the source and at the initramfs.
I have no idea what was wrong, but after I unpacked both new it worked.
If anyone is interested in it: I'm using the toolchain provided by CM.

Correct which, toolchain makes no difference, each toolchain adds their own options, but any toolchain should be able to build a bootable kernel.
 
Top