Kernel Packaging and Boot.img creation

Search This thread

aeppacher

Senior Member
Apr 14, 2012
795
777
Okay, so I have created and modified my own kernel name BionicSheep and have done couple releases (check my signature for link). My main question is how do I create a flashable zip with a boot.img I have asked a few people and they told me to use the kernel kitchen or google, but this is the only problem I haven't been able to solve after googling daily for the past 4 days. I figured I would ask here.

The reason I would like a boot.img is because I know in order to modify the kernelsplash with my own logo, I need to be able to unpack the bootimage to get the ramdisk and modify an rle file. The problem is I have no idea how to first make this bootimage. I understand to make the bootimage you need a the zImage (kernel binary) and the ramdisk. I have the zImage but I don't know how to make/get a ramdisk.

Currently I have been using this described method of packing my kernel into a flashable zip. I am pretty sure it just packs my modules and zImage into koush's AnyKernel. Thanks for any help, I need it.

Also try my kernel out and leave feedback if you are so inclined! It really is appreciated
 

aeppacher

Senior Member
Apr 14, 2012
795
777

zamcum

Senior Member
Oct 22, 2008
265
449
This is helpful for unpacking modifying and repacking, but I dont have a boot.img to unpack. Like I said, all I have is a zImage, i have no clue how to get a ramdisk. Can I just use one from another kernel or will that cause conflicts? Thanks for the help

You can have it, in a stock rom:
Download a stock rom for your phone, open .tar.md5 file with winrar, extract boot.img and unpack it.

Inside you have, ramdisdk and zimage, with another name (boot.img-kernel)

rename your zimage, to boot.img-kernel, edit ramdisk if you want
repalce original boot.img-kernel with yours
and repack
Rename boot-new.img to boot.img

Enjoy


EDIT: To make a flashable Odin file, in Linux:

tar -H ustar -c boot.img > YOURKERNEL.tar
md5sum -t YOURKERNEL.tar >> YOURKERNEL.tar
mv YOURKERNEL.tar YOURKERNEL.tar.md5
 
Last edited:

CNexus

Senior Member
May 17, 2012
9,010
14,000
~/android
Google Pixel 7
That's not necessary. You can make it so that your zImage replaces the zImage inside the boot.img and the initlogo.rle at the same time.
 
Last edited:

aeppacher

Senior Member
Apr 14, 2012
795
777
You can have it, in a stock rom:
Download a stock rom for your phone, open .tar.md5 file with winrar, extract boot.img and unpack it.

Inside you have, ramdisdk and zimage, with another name (boot.img-kernel)

rename your zimage, to boot.img-kernel, edit ramdisk if you want
repalce original boot.img-kernel with yours
and repack
Rename boot-new.img to boot.img

Enjoy


EDIT: To make a flashable Odin file, in Linux:

tar -H ustar -c boot.img > YOURKERNEL.tar
md5sum -t YOURKERNEL.tar >> YOURKERNEL.tar
mv YOURKERNEL.tar YOURKERNEL.tar.md5

hahaha so I think that worked, I have a bootimage with my kernel!! hurrah, now how do I turn it into a flashable zip? Last question I promise
 

zamcum

Senior Member
Oct 22, 2008
265
449
hahaha so I think that worked, I have a bootimage with my kernel!! hurrah, now how do I turn it into a flashable zip? Last question I promise

the easiest way, is to download a custom kernel for your phone, open the zip with winrar and replace the bott.img by your boot.img

It is important that the exact custom kernel of your phone, so that, there are no incompatibilities in the installation script
 
  • Like
Reactions: Nosanahtir

aeppacher

Senior Member
Apr 14, 2012
795
777
the easiest way, is to download a custom kernel for your phone, open the zip with winrar and replace the bott.img by your boot.img

It is important that the exact custom kernel of your phone, so that, there are no incompatibilities in the installation script

Hmmm, I tried this and it didn't boot. :/ then I booted to recovery restarted, and then it booted with my boot splash (yay) went to apps updating and then just got stuck at starting apps. I couldn't get it to fully boot :/

Any ideas whats up

EDIT: I can't thank you since I only get 8 per day, sorry :( I do appreciate it though
 

zamcum

Senior Member
Oct 22, 2008
265
449
Hmmm, I tried this and it didn't boot. :/ then I booted to recovery restarted, and then it booted with my boot splash (yay) went to apps updating and then just got stuck at starting apps. I couldn't get it to fully boot :/

Any ideas whats up

EDIT: I can't thank you since I only get 8 per day, sorry :( I do appreciate it though

If your kernel does not boot, is because it has a problem. It is normal to happen in the first kernel.

The process I use, is what is above. Sorry, II can not help more.

Do not worry about the gratefulness. The important thing is to help
 

flatherskevin

Senior Member
Mar 26, 2013
144
43
Boston
I have a question along the same lines as this thread and I've read all over the place and can't find anything. How do you open a boot.img file to be able to replace the zimage

---------- Post added at 09:21 AM ---------- Previous post was at 08:45 AM ----------

I have a question along the same lines as this thread and I've read all over the place and can't find anything. How do you open a boot.img file to be able to replace the zimage

EDIT: i fixed this
 
Last edited:

aeppacher

Senior Member
Apr 14, 2012
795
777
Problem solved, figured I would post a solution:

here are the tools: https://dl.dropboxusercontent.com/u/106865720/bootimg_tools.zip

extract them into any old folder. You also need to have perl installed (just google it)

1. You need to take your built boot.img (from a rom running your kernel successfully) and drag it into the folder.
2. Open up terminal and navigate to the directory with the tools and boot.img
3. First you need to split the boot image into its 2 parts (the ramdisk and the kernel zImage)
Code:
perl split_bootimg.pl boot.img
The "boot.img" part is just the name of your boot.img (I am assuming yours is called boot.img but you can change it as needed)
4. Okay what should have happened is the boot.img should have split into a 'boot.img-ramdisk.gz' and a 'boot.img-kernel' file. The first is a specially compressed ramdisk and the second is the zImage for the kernel
5. Now you need to unpack the ramdisk so that you can modify it. BE CAREFUL AND MODIFY ONLY IF NEEDED Use this code:
Code:
perl unpack_ramdisk boot.img-ramdisk.gz ramdisk
the "boot-img-ramdisk.gz" is the name of the ramdisk, you can change this as needed but it should be named that by default
6.Okay so what should have happened is a folder ramdisk was created (this is the unpacked ramdisk which you need).
7.Okay go back to your directory and delete your boot.img, boot.img-kernel and boot.img-ramdisk.gz files (you no longer need them)
8. Now you need to repack the ramdisk folder you modified so you can rebuild the boot.img use the following:
Code:
perl repack_ramdisk ramdisk boot.img-ramdisk.cpio.gz
9. This will take the 'ramdisk' folder and pack it and name it 'boot.img-ramdisk.cpio.gz'
11. Find your built zImage for your compiled kernel and copy it into this folder with the tools. Rename it as "boot.img-kernel"
10. Sweet now you need to pack the new ramdisk file and your kernel you just stuck in into a new boot.img (this part took me forever to figure out)
11. Here is the code to rebuild
Code:
mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 -o boot.img
12. This should create a file named boot.img in the directory that will have your kernel and modified ramdisk (whoo)

Any further help can be directed to this thread or PMing me!
 

mukulsoni

Senior Member
Aug 16, 2013
721
4,790
Bangkok
11. Here is the code to rebuild
Code:
mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 -o boot.img

Any further help can be directed to this thread or PMing me!
While executing above code I am getting : -bash: mkbootimg: command not found. Whether the mkbootimg file is exist there,
could you please help
 

mukulsoni

Senior Member
Aug 16, 2013
721
4,790
Bangkok
Hmmm perhaps a bad download?
but unpacking is fine, My downloaded zip file is in 66.4 Kb size. any way could you please try to compile the attached HP.zip into boot.img in your system. TIA

Edit: sorry downloaded file size is 290kb. please send me the final compiled boot.img file. Thanks so much
 

Attachments

  • HP.zip
    3.5 MB · Views: 131
Last edited:

aeppacher

Senior Member
Apr 14, 2012
795
777
but unpacking is fine, My downloaded zip file is in 66.4 Kb size. any way could you please try to compile the attached HP.zip into boot.img in your system. TIA

Edit: sorry downloaded file size is 290kb. please send me the final compiled boot.img file. Thanks so much

What version of linux are you running? Ubuntu? what version number, and is it 32-bit or 64-bit

EDIT: try install 32bit packages "sudo apt-get install ia32-libs"
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Problem solved, figured I would post a solution:

    here are the tools: https://dl.dropboxusercontent.com/u/106865720/bootimg_tools.zip

    extract them into any old folder. You also need to have perl installed (just google it)

    1. You need to take your built boot.img (from a rom running your kernel successfully) and drag it into the folder.
    2. Open up terminal and navigate to the directory with the tools and boot.img
    3. First you need to split the boot image into its 2 parts (the ramdisk and the kernel zImage)
    Code:
    perl split_bootimg.pl boot.img
    The "boot.img" part is just the name of your boot.img (I am assuming yours is called boot.img but you can change it as needed)
    4. Okay what should have happened is the boot.img should have split into a 'boot.img-ramdisk.gz' and a 'boot.img-kernel' file. The first is a specially compressed ramdisk and the second is the zImage for the kernel
    5. Now you need to unpack the ramdisk so that you can modify it. BE CAREFUL AND MODIFY ONLY IF NEEDED Use this code:
    Code:
    perl unpack_ramdisk boot.img-ramdisk.gz ramdisk
    the "boot-img-ramdisk.gz" is the name of the ramdisk, you can change this as needed but it should be named that by default
    6.Okay so what should have happened is a folder ramdisk was created (this is the unpacked ramdisk which you need).
    7.Okay go back to your directory and delete your boot.img, boot.img-kernel and boot.img-ramdisk.gz files (you no longer need them)
    8. Now you need to repack the ramdisk folder you modified so you can rebuild the boot.img use the following:
    Code:
    perl repack_ramdisk ramdisk boot.img-ramdisk.cpio.gz
    9. This will take the 'ramdisk' folder and pack it and name it 'boot.img-ramdisk.cpio.gz'
    11. Find your built zImage for your compiled kernel and copy it into this folder with the tools. Rename it as "boot.img-kernel"
    10. Sweet now you need to pack the new ramdisk file and your kernel you just stuck in into a new boot.img (this part took me forever to figure out)
    11. Here is the code to rebuild
    Code:
    mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 -o boot.img
    12. This should create a file named boot.img in the directory that will have your kernel and modified ramdisk (whoo)

    Any further help can be directed to this thread or PMing me!
    4
    This is helpful for unpacking modifying and repacking, but I dont have a boot.img to unpack. Like I said, all I have is a zImage, i have no clue how to get a ramdisk. Can I just use one from another kernel or will that cause conflicts? Thanks for the help

    You can have it, in a stock rom:
    Download a stock rom for your phone, open .tar.md5 file with winrar, extract boot.img and unpack it.

    Inside you have, ramdisdk and zimage, with another name (boot.img-kernel)

    rename your zimage, to boot.img-kernel, edit ramdisk if you want
    repalce original boot.img-kernel with yours
    and repack
    Rename boot-new.img to boot.img

    Enjoy


    EDIT: To make a flashable Odin file, in Linux:

    tar -H ustar -c boot.img > YOURKERNEL.tar
    md5sum -t YOURKERNEL.tar >> YOURKERNEL.tar
    mv YOURKERNEL.tar YOURKERNEL.tar.md5
    3
    Okay, so I have created and modified my own kernel name BionicSheep and have done couple releases (check my signature for link). My main question is how do I create a flashable zip with a boot.img I have asked a few people and they told me to use the kernel kitchen or google, but this is the only problem I haven't been able to solve after googling daily for the past 4 days. I figured I would ask here.

    The reason I would like a boot.img is because I know in order to modify the kernelsplash with my own logo, I need to be able to unpack the bootimage to get the ramdisk and modify an rle file. The problem is I have no idea how to first make this bootimage. I understand to make the bootimage you need a the zImage (kernel binary) and the ramdisk. I have the zImage but I don't know how to make/get a ramdisk.

    Currently I have been using this described method of packing my kernel into a flashable zip. I am pretty sure it just packs my modules and zImage into koush's AnyKernel. Thanks for any help, I need it.

    Also try my kernel out and leave feedback if you are so inclined! It really is appreciated
    1
    hahaha so I think that worked, I have a bootimage with my kernel!! hurrah, now how do I turn it into a flashable zip? Last question I promise

    the easiest way, is to download a custom kernel for your phone, open the zip with winrar and replace the bott.img by your boot.img

    It is important that the exact custom kernel of your phone, so that, there are no incompatibilities in the installation script