[TOOL] Boot.img tools [unpack, repack, ramdisk]

Search This thread

pr0_JeR

New member
May 21, 2020
3
0
My problem


# boot_info original_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01000000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

I create new boot and see boot_info



# boot_info new_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01300000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

RAMDISK ADDRESS is bad
 

gee one

Senior Member
Jul 29, 2010
1,979
866
linux command line
My problem


# boot_info original_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01000000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

I create new boot and see boot_info



# boot_info new_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01300000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

RAMDISK ADDRESS is bad
Are you setting the ramdisk address and it's coming out wrong, or are you not setting it at all?

What command did you use to repack the boot image?
 

pr0_JeR

New member
May 21, 2020
3
0
Are you setting the ramdisk address and it's coming out wrong, or are you not setting it at all?

What command did you use to repack the boot image?

I use the command
Code:
mkbootimg --kernel zImage --ramdisk ramdisk.cpio.gz --base 0x0 --cmdline 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug' --pagesize 4096 -o new_boot.img
 

pr0_JeR

New member
May 21, 2020
3
0
I think you can set the ramdisk address.

Try mkbootimg --help and see if there is a way to set the recovery address.

Now everything is correct, but the phone still loads endlessly. That's what I do :
# adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully
~ # ls -al /dev/block/*/by-name/* | grep "/boot -"
lrwxrwxrwx 1 root root 21 Feb 6 1970 /dev/block/bootdevice/by-name/boot -> /dev/block/mmcblk0p68
# adb pull /dev/block/mmcblk0p68 original_boot.img
/dev/block/mmcblk0p68: 1 file pulled. 23.9 MB/s (67108864 bytes in 2.674s)
# adb reboot bootloader
# fastboot devices
1fa8e889 fastboot
# fastboot boot original_boot.img
downloading 'boot.img'...
OKAY [ 2.085s]
booting...
OKAY [ 0.074s]
finished. total time: 2.159s
After that, the phone loads without problems. But as soon as I take it apart and put it back together, my phone loads endlessly.
# unpack original_boot.img
Boot = original_boot.img
unmkbootimg version 1.2 - Mikael Q Kuisma <kuisma@ping.se>
Kernel size 13689184
Kernel address 0x8000
Ramdisk size 1049563
Ramdisk address 0x1000000
Secondary size 0
Secondary address 0xf00000
Kernel tags address 0x100
Flash page size 4096
Board name is ""
Command line "console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug"
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 0x0 --cmdline 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug' --pagesize 4096 -o new_boot.img
---------------
# boot_info original_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01000000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'
# cd original_boot/
mkbootimg --kernel zImage --ramdisk ramdisk.cpio.gz --base 0x0 --cmdline 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug' --pagesize 4096 --ramdiskaddr '0x1000000' -o new_boot.img
# ls -al
итого 28820
drwxr-xr-x 3 root root 4096 мая 26 10:52 .
drwxr-xr-x 5 root root 4096 мая 26 10:48 ..
-rw-r--r-- 1 root root 14749696 мая 26 10:52 new_boot.img
drwxr-xr-x 9 root root 4096 мая 26 10:48 ramdisk
-rw-r--r-- 1 root root 1049563 мая 26 10:48 ramdisk.cpio.gz
-rw-r--r-- 1 root root 13689184 мая 26 10:48 zImage
# boot_info new_boot.img
PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x01000000
CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'
# adb reboot bootloader
# fastboot boot new_boot.img

Now the RAMDISK ADDRESS matches, what else could be the problem?:confused:
 

Wilson630

New member
Jul 6, 2022
3
0
hi, i'm new to this. Just used tool "imgRePacker_206". now among the files generated i have "boot-resource.fex.iso" in which there is the "bootlogo.bmp" file that i want to replace. how do i unpack and repack it.
 

QATech20

New member
Apr 10, 2023
3
0
Trying to use the split_boot script with cygwin but each time I try to run it I get "-bash: ./split_boot: cannot execute: required file not found". Saw in an earlier post where it was mentioned that the scripts make use of gzip, gunzip, cpio, and others but what exactly are the others?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 182
    I have not seen this posted anywhere, so I thought I would post it here. This is NOT purely my work, and I do not take credit for it as such.

    Included in the attached ZIP are the following files:

    • boot_info - prints information about the boot.img passed to it, including the base address and ramdisk address. This tool prints out everything needed to repack the boot.img correctly.
    • split_boot - More commonly known as split_bootimg.pl, this rips apart the boot.img to extract the ramdisk and zImage. It has been modified by me to split the boot.img into a separate folder (specified by the file name of the boot.img passed to it) and to extract the ramdisk into a sub-folder as well (extracts the cpio from the gz and then extracts the actual files from the cpio archive)
    • unpack_ramdisk - unpacks the given ramdisk file.
      Code:
      Usage: unpack_ramdisk <ramdiskFile>
    • repack_ramdisk - repacks the ramdisk from the given directory (found online and modified slightly to take a directory)
      Code:
      Usage: repack_ramdisk <ramdiskDirectory> [outputFile]
    • mkbootimg - mkbootimg binary that creates a boot.img file from the given ramdisk and zImage. Updated to a version compiled by me to support the --ramdiskaddr option (ramdisk address) so that even nonstandard boot.img's can be repacked correctly (Use with boot_info for best results).
    • umkbootimg - included for convenience. Not made by me. Original thread here.
    • unpack - wrapper script made by me for the umkbootimg binary^ to unpack the boot.img into a separate directory and then unpack the ramdisk into a sub-directory.

    Note: These tools were made for Linux. They may also work on Cygwin, but I have not personally tested them.

    ANYONE is free to use / modify / kang these files as they see fit. No need to ever ask or do anything more than download.

    Enjoy.
    14
    Updated tools with a new boot_info script, also added my own mkbootimg binary compiled with the ramdisk address option.

    Boot_info now displays the following information:
    Commandline
    Pagesize
    Base address
    Ramdisk address.

    Which is everything you need to make a functional boot.img, even when the original boot.img is packed with a non-standard mkbootimg (ie, the ramdisk offset is different than the normal offset).
    13
    UPDATE: If you downloaded, please redownload. There was an error with my repack_ramdisk script, but it's fixed now.
    6
    All the scripts must be in a folder in your path (~/bin for example)

    Then it should work, because they call on each other. I keep all of them in my ~/bin folder, but they can be anywhere in your PATH

    Sent from my buttered S3
    3
    How exactly do we use these files to unpack and repack?
    I've tried running the scripts with chmod at 755 but it doesn't work.
    I am i missing something?