FORUMS
Remove All Ads from XDA
OnePlus 6 On Sale

[UTIL] unmkbootimg

361 posts
Thanks Meter: 209
 
By kuisma, Senior Member on 9th September 2012, 08:51 AM
Post Reply Email Thread
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.
Attached Files
File Type: gz unmkbootimg.gz - [Click for QR Code] (270.6 KB, 18786 views)
The Following 51 Users Say Thank You to kuisma For This Useful Post: [ View ] Gift kuisma Ad-Free
 
 
10th September 2012, 09:30 AM |#2  
manoranjan2050's Avatar
Senior Member
Flag JAGATSINGHPUR
Thanks Meter: 1,424
 
Donate to Me
More
Thumbs up
Great Tool........ i Always use it..........Thanks For Share
25th October 2012, 10:38 AM |#3  
kuisma's Avatar
OP Senior Member
Flag Sweden
Thanks Meter: 209
 
More
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.

Quote:

$ 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
---------------

The Following 3 Users Say Thank You to kuisma For This Useful Post: [ View ] Gift kuisma Ad-Free
25th October 2012, 04:33 PM |#4  
OmarBizreh's Avatar
Recognized Developer
Flag Damascus
Thanks Meter: 3,496
 
Donate to Me
More
Thank you for your tool my friend
Though I have one question regarding this:
Quote:

--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
25th October 2012, 04:46 PM |#5  
kuisma's Avatar
OP Senior Member
Flag Sweden
Thanks Meter: 209
 
More
Quote:
Originally Posted by DeepUnknown

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

As far as I know, Sony passes all important parameters via kernel ATAGs, not command line.
The Following User Says Thank You to kuisma For This Useful Post: [ View ] Gift kuisma Ad-Free
25th October 2012, 04:55 PM |#6  
OmarBizreh's Avatar
Recognized Developer
Flag Damascus
Thanks Meter: 3,496
 
Donate to Me
More
Quote:
Originally Posted by kuisma

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:
Quote:

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.
28th November 2012, 11:46 PM |#7  
fivefour's Avatar
Senior Member
Flag Emerald Coast
Thanks Meter: 1,293
 
More
Very nice tool, thanks for sharing.
15th February 2013, 12:28 PM |#8  
kuisma's Avatar
OP Senior Member
Flag Sweden
Thanks Meter: 209
 
More
unmkbootimg as of version 1.2 now supports embedded boot images, e.g. a boot image embedded deep in an update.img file.

Quote:

$ unmkbootimg update.img
unmkbootimg version 1.2 - Mikael Q Kuisma <kuisma@ping.se>
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
$

The Following 3 Users Say Thank You to kuisma For This Useful Post: [ View ] Gift kuisma Ad-Free
18th February 2013, 02:50 AM |#9  
fivefour's Avatar
Senior Member
Flag Emerald Coast
Thanks Meter: 1,293
 
More
Re: [UTIL] unmkbootimg
Quote:
Originally Posted by kuisma

unmkbootimg as of version 1.2 now supports embedded boot images, e.g. a boot image embedded deep in an update.img file.

Thanks for the update, very cool feature.
10th April 2013, 09:13 AM |#10  
Member
Thanks Meter: 1
 
More
Question Can not extract zImage?
Could you check why I Can not extract zImage from this Kernel:

http://forum.xda-developers.com/show...3&postcount=56
10th April 2013, 09:45 AM |#11  
kuisma's Avatar
OP Senior Member
Flag Sweden
Thanks Meter: 209
 
More
Quote:
Originally Posted by mafamafa

Could you check why I Can not extract zImage from this Kernel:

http://forum.xda-developers.com/show...3&postcount=56

It's because it's not an Android boot image, but a Rockchip specific kernel image file.
Post Reply Subscribe to Thread

Tags
mkbootimg unpack boot image

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes