[UTIL] unmkbootimg

Search This thread

kuisma

Senior Member
Jun 30, 2009
360
215
Sweden
whiteboard.ping.se
I've put together a tool undoing what mkbootimg does. There are other tools splitting a boot image into the
kernel and root file system, but I didn't find any extracting the command line and base addresses, so I wrote this one.
It handles plain boot images as well as boot images embedded in larger filer, e.g. update-images.

Code:
$ unmkbootimg boot.img 
Kernel size 2419636
Kernel address 0x20008000
Ramdisk size 152656
Ramdisk address 0x21000000
Secondary size 0
Secondary address 0x20f00000
Kernel tags address 0x20000100
Flash page size 2048
Board name is ""
Command line "no_console_suspend=1"
This image is built using standard mkbootimg
Extracting kernel to file zImage ...
Extracting root filesystem to file initramfs.cpio.gz ...
All done.
---------------
To recompile this image, use:
  mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x20000000 --cmdline 'no_console_suspend=1' -o new_boot.img
---------------

$ ls -l
totalt 5044
-rw-r--r-- 1 kuisma kuisma 2576384  9 sep 09.44 boot.img
-rw-r--r-- 1 kuisma kuisma  152656  9 sep 09.44 initramfs.cpio.gz
-rw-r--r-- 1 kuisma kuisma 2419636  9 sep 09.44 zImage

  • Version 1.2 - Support for embedded boot images
  • Version 1.1 - Support for non-standard mkbootimg images.
  • Version 1.0 - Initial release.

Including a gziped binary for GNU/Linux in this post (32 bit, linked static). Download, unzip, make sure it is executable.
If running on a 64bit machine, make sure you've got the ia32-libs installed to be able to run 32bit binaries.
 

Attachments

  • unmkbootimg.gz
    270.6 KB · Views: 22,865
Last edited:

kuisma

Senior Member
Jun 30, 2009
360
215
Sweden
whiteboard.ping.se
I've updated unmkbootimg. Now it detects and warns if the boot.img is built using a non-standard mkbootimg, and tells you how to patch it.

$ unmkbootimg samsung-boot.img
Kernel size 4905092
Kernel address 0x40408000
Ramdisk size 893395
Ramdisk address 0x41800000
Secondary size 0
Secondary address 0x41300000
Kernel tags address 0x40400100
Flash page size 2048
Board name is ""
Command line "androidboot.hardware=qcom msm_watchdog.appsbark=0 msm_watchdog.enable=1 loglevel=4"

*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_RAMDISK_ADDR is 0x01400000
Please modify mkbootimg.c using the above values to build your image.
****************


Extracting kernel to file zImage ...
Extracting root filesystem to file initramfs.cpio.gz ...
All done.
---------------
To recompile this image, use:
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x40400000 --cmdline 'androidboot.hardware=qcom msm_watchdog.appsbark=0 msm_watchdog.enable=1 loglevel=4' -o new_boot.img
---------------
 

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
Thank you for your tool my friend :)
Though I have one question regarding this:
--cmdline 'no_console_suspend=1'
When I attempt to compile kernel from source, Sony said in the read me file that memory layout and other stuff are passed to kernel via cmdline. I do that just like it's written in the cmdline I quoted?! because I want to use the latest kernel source with an existing zRam but i'm unable to make the newly compiled kernel to boot because I am unable to pass arguments via cmdline on boot :crying:
 

kuisma

Senior Member
Jun 30, 2009
360
215
Sweden
whiteboard.ping.se
Thank you for your tool my friend :)
Though I have one question regarding this:

When I attempt to compile kernel from source, Sony said in the read me file that memory layout and other stuff are passed to kernel via cmdline. I do that just like it's written in the cmdline I quoted?! because I want to use the latest kernel source with an existing zRam but i'm unable to make the newly compiled kernel to boot because I am unable to pass arguments via cmdline on boot :crying:

As far as I know, Sony passes all important parameters via kernel ATAGs, not command line.
 
  • Like
Reactions: OmarBizreh

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
As far as I know, Sony passes all important parameters via kernel ATAGs, not command line.

I'm sorry I wasn't clear in the previous comment, here is what Sony mentioned:
In the official SW the following command line arguments are given
to the kernel:
cachepolicy=writealloc
noinitrd
init=init
board_id=1
logo.nologo
root=/dev/ram0
rw
rootwait
console=ttyAMA2,115200n8
androidboot.console=ttyAMA2
androidboot.hardware=st-ericsson
<memory layout>
mpcore_wdt.mpcore_margin=359

I'm sorry I went out of subject but I was using tools like yours to get zRam from other boot.img file.
 

kuisma

Senior Member
Jun 30, 2009
360
215
Sweden
whiteboard.ping.se
unmkbootimg as of version 1.2 now supports embedded boot images, e.g. a boot image embedded deep in an update.img file.

$ unmkbootimg update.img
unmkbootimg version 1.2 - Mikael Q Kuisma <[email protected]>
File update.img not a plain boot image, seeking for embedded image ... found!
Kernel size 8073252
Kernel address 0x60408000
Ramdisk size 6380372
Ramdisk address 0x62000000
Secondary size 0
Secondary address 0x60f00000
Kernel tags address 0x60088000
Flash page size 16384
Board name is ""
Command line ""

*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_KERNEL_ADDR is 0x00380100
OFF_RAMDISK_ADDR is 0x01F78100
OFF_SECOND_ADDR is 0x00E78100
Please modify mkbootimg.c using the above values to build your image.
****************

Extracting kernel to file zImage ...
Extracting root filesystem to file initramfs.cpio.gz ...
All done.
---------------
To recompile this image, use:
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x60087f00 --pagesize 16384 -o new_boot.img
---------------
$ ls
initramfs.cpio.gz update.img zImage
$
 
Last edited:

jeevas.v

Member
Jun 24, 2009
29
6
Hi, could you please post the source here or upload in github or similar and provide the link. That will be much better.

Sent from my Amazon Kindle Fire HD using xda app-developers app
 

jeevas.v

Member
Jun 24, 2009
29
6
That is very bad and unethical. It is not a question of I or somebody can do it. Even it violates many things by saying no. What a pathetic situation.

Sent from my Amazon Kindle Fire HD using xda app-developers app
 

jeevas.v

Member
Jun 24, 2009
29
6
I'm saying that you are using Foss as you like and hesitating to publish even a trivial change that you made. How can the community trust your binaries unless they don't have the source. What kind of mindset is that? Have you ever read GPL?

What do you think you are doing? Social service the Microsoft way? What a joke!


Sent from my Amazon Kindle Fire HD using xda app-developers app
 

kuisma

Senior Member
Jun 30, 2009
360
215
Sweden
whiteboard.ping.se
I'm saying that you are using Foss as you like and hesitating to publish even a trivial change that you made. How can the community trust your binaries unless they don't have the source. What kind of mindset is that? Have you ever read GPL?

What do you think you are doing? Social service the Microsoft way? What a joke!

GPL? My code is written from scratch, and is not a subject of GPL whatsoever.

You, my friend, are making a fool of your self. Please, don't let me hinder you. ;)
 
  • Like
Reactions: infrag

jeevas.v

Member
Jun 24, 2009
29
6
I am trying to spread the awareness against the closed source behaviour and I hope I achieved that in whatever miniscule way.

I don't care about your binary or code but thought of asking you to know if you are intentionally not giving the source by giving just the 32bit binaries. Anyway so now everyone knows...:)



Sent from my Amazon Kindle Fire HD using xda app-developers app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 53
    I've put together a tool undoing what mkbootimg does. There are other tools splitting a boot image into the
    kernel and root file system, but I didn't find any extracting the command line and base addresses, so I wrote this one.
    It handles plain boot images as well as boot images embedded in larger filer, e.g. update-images.

    Code:
    $ unmkbootimg boot.img 
    Kernel size 2419636
    Kernel address 0x20008000
    Ramdisk size 152656
    Ramdisk address 0x21000000
    Secondary size 0
    Secondary address 0x20f00000
    Kernel tags address 0x20000100
    Flash page size 2048
    Board name is ""
    Command line "no_console_suspend=1"
    This image is built using standard mkbootimg
    Extracting kernel to file zImage ...
    Extracting root filesystem to file initramfs.cpio.gz ...
    All done.
    ---------------
    To recompile this image, use:
      mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x20000000 --cmdline 'no_console_suspend=1' -o new_boot.img
    ---------------
    
    $ ls -l
    totalt 5044
    -rw-r--r-- 1 kuisma kuisma 2576384  9 sep 09.44 boot.img
    -rw-r--r-- 1 kuisma kuisma  152656  9 sep 09.44 initramfs.cpio.gz
    -rw-r--r-- 1 kuisma kuisma 2419636  9 sep 09.44 zImage

    • Version 1.2 - Support for embedded boot images
    • Version 1.1 - Support for non-standard mkbootimg images.
    • Version 1.0 - Initial release.

    Including a gziped binary for GNU/Linux in this post (32 bit, linked static). Download, unzip, make sure it is executable.
    If running on a 64bit machine, make sure you've got the ia32-libs installed to be able to run 32bit binaries.
    4
    Hi!

    Those concerned about using closed-source system software (as I am) may try abootimg written by Gilles Grandou:

    - Handles packing and unpacking boot images (no need for mkbootimg either).
    - Can do kernel/initrd updates on an image.
    - Includes convenient initrd packing/unpacking scripts.
    - Free (GPL) software, public source repository.
    - Already included in Debian/Ubuntu (just one apt-get away)

    Debian/Ubuntu install:

    $ sudo apt-get install abootimg

    Source code repository:

    https://gitorious.org/ac100/abootimg
    3
    I've updated unmkbootimg. Now it detects and warns if the boot.img is built using a non-standard mkbootimg, and tells you how to patch it.

    $ unmkbootimg samsung-boot.img
    Kernel size 4905092
    Kernel address 0x40408000
    Ramdisk size 893395
    Ramdisk address 0x41800000
    Secondary size 0
    Secondary address 0x41300000
    Kernel tags address 0x40400100
    Flash page size 2048
    Board name is ""
    Command line "androidboot.hardware=qcom msm_watchdog.appsbark=0 msm_watchdog.enable=1 loglevel=4"

    *** WARNING ****
    This image is built using NON-standard mkbootimg!
    OFF_RAMDISK_ADDR is 0x01400000
    Please modify mkbootimg.c using the above values to build your image.
    ****************


    Extracting kernel to file zImage ...
    Extracting root filesystem to file initramfs.cpio.gz ...
    All done.
    ---------------
    To recompile this image, use:
    mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x40400000 --cmdline 'androidboot.hardware=qcom msm_watchdog.appsbark=0 msm_watchdog.enable=1 loglevel=4' -o new_boot.img
    ---------------
    3
    unmkbootimg as of version 1.2 now supports embedded boot images, e.g. a boot image embedded deep in an update.img file.

    $ unmkbootimg update.img
    unmkbootimg version 1.2 - Mikael Q Kuisma <[email protected]>
    File update.img not a plain boot image, seeking for embedded image ... found!
    Kernel size 8073252
    Kernel address 0x60408000
    Ramdisk size 6380372
    Ramdisk address 0x62000000
    Secondary size 0
    Secondary address 0x60f00000
    Kernel tags address 0x60088000
    Flash page size 16384
    Board name is ""
    Command line ""

    *** WARNING ****
    This image is built using NON-standard mkbootimg!
    OFF_KERNEL_ADDR is 0x00380100
    OFF_RAMDISK_ADDR is 0x01F78100
    OFF_SECOND_ADDR is 0x00E78100
    Please modify mkbootimg.c using the above values to build your image.
    ****************

    Extracting kernel to file zImage ...
    Extracting root filesystem to file initramfs.cpio.gz ...
    All done.
    ---------------
    To recompile this image, use:
    mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x60087f00 --pagesize 16384 -o new_boot.img
    ---------------
    $ ls
    initramfs.cpio.gz update.img zImage
    $
    1
    Thank you for your tool my friend :)
    Though I have one question regarding this:

    When I attempt to compile kernel from source, Sony said in the read me file that memory layout and other stuff are passed to kernel via cmdline. I do that just like it's written in the cmdline I quoted?! because I want to use the latest kernel source with an existing zRam but i'm unable to make the newly compiled kernel to boot because I am unable to pass arguments via cmdline on boot :crying:

    As far as I know, Sony passes all important parameters via kernel ATAGs, not command line.