1. Download our Official Android App: Forums for Android!

Root [Without PC] Unpack, Edit, Repack boot.img

Discussion in 'Android Devices' started by ModdingMyMind, Dec 27, 2013.

  1. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Hello friends, I'm back again with something I wish to share with you all. I have compiled three files to work flawlessly for ARM devices which will allow users to unpack, edit, and repack their boot.img without the use of a PC and all straight from their device.

    ---unmkbootimg, mkbootfs, mkbootimg---

    https://github.com/ModdingMyMind/boot_manipulation
    Hey guys, since I have made this thread a while back there has been a LOT of changes made to the resource. For starters, it is now a multi call binary. In addition, I have updated mkbootfs for better support, mkbootimg.c has dt support, unmkbootimg.c has dt support, bootimg.h has dt support, as well as adding dtbtool, and dtc. Lets not also forget about lz4 for those whos ramdisks are not gz compressed. I am continuously making changes to the source and the op attachment will not be kept up to date. To stay up to date you will need to build the multi call binary from the source provided by the link above. Just simply run: make multi.



    Note:
    -- The mkbootimg binary is based upon the AOSP with some added modifications to work in conjunction with unmkbootimg.
    -- The unmkbootimg binary is based on the original mkbootimg source but with reverse engineering to compliment its helpful use in extraction and thus providing the needed command to rebuild properly.
    -- The mkbootfs binary is based on the source provided within the dsixda kitchen to insure the proper structural repacking of the ramdisk, etc.


    Requirements:
    -- BusyBox (cpio, gunzip and gzip is mandatory)
    -- /System Write Permissions (Does not need to be a modified kernel)
    -- Terminal Emulator
    -- ES File Explorer (or similar)
    -- Hex Editor (or use of DD)

    -- Unzip boot_manipulation.zip on your device and copy the three files over to /system/bin. Those three files inside the .zip will be named unmkbootimg, mkbootfs and mkbootimg.
    -- EDIT: I have included a flashable zip for these files.
    -- Set permissions to rwxr-xr-x (755) on each binary. Note: The flash zip does this already.

    -- Open up your android terminal emulator.

    -- Now go ahead and pull your boot.img from your device (or use another one if you wish). Here is an example:
    Code (Text):
    1. root@android:/ # [COLOR="Red"]dd if=/dev/block/mmcblk0p20 of=/data/local/tmp/boot.img[/COLOR]
    2. dd if=/dev/block/mmcblk0p20 of=/data/local/tmp/boot.img
    3. 32768+0 records in
    4. 32768+0 records out
    5. 16777216 bytes transferred in 1.496 secs (11214716 bytes/sec)
    6. root@android:/ #

    -- Open up your boot.img with the Hex Editor and look for: ANDROID!. Remove everything before it so that the ANDROID! header is the first to be read then save it over top of the boot.img. NOTE: This is only required if you are using a stock boot.img. Here is an example:
    Code (Text):
    1. Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    2.  
    3. 00000000  [COLOR="red"]A5 F0 BA B7 B0 43 E3 F8 3C E1 63 55 AE 75 C6 69  
     

    Attached Files:

    fnesveda, dhrtlockeroo9 and irishobo like this.
  2. irishobo

    irishobo Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    301
    Joined:
    Nov 12, 2011

    Nov 12, 2011
    301
    66
    53
    Male
    Telecommunications Contractor Co-Owner Splice Pros
    Tennessee
    Great work!
     
  3. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Yea, works great but for some reason I am having trouble with the modboot.img when flashing it. Not sure if I am repacking it properly. Grrrr.... Lol
     
  4. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    I posted up in the Q&A over at XDA about it. Seems like I got people stumped with it or they are too lazy to look in to it. :)
     
  5. irishobo

    irishobo Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    301
    Joined:
    Nov 12, 2011

    Nov 12, 2011
    301
    66
    53
    Male
    Telecommunications Contractor Co-Owner Splice Pros
    Tennessee
  6. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    I have an unmkbootimg that is compiled for arm devices now. Gonna mess with it and see what's up :). My goal is to make every need of using linux to be properly done on our devices. I'm always on the go so without a pc I have to find ways to do them on my phone. This is a very good start lol.
     
    irishobo likes this.
  7. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Well, got a start lol. This time the boot.img worked sort of. I must be using the wrong ramdisk address and/or base address..... When I booted up this time it hanged for a minute then rebooted automatically in to the TWRP recovery.
     
  8. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    I'm not repacking it properly. Which would be human error on my part.
     
  9. palmtree5

    palmtree5 Sunny Vacation Supporter!
    Moderator
    Rank:
     #35
    Points:
    633
    Posts:
    4,580
    Joined:
    May 2, 2012

    May 2, 2012
    4,580
    3,498
    633
    Male
    Student
    USA
    Out of curiosity, what are using that is providing cpio on your device? I can't seem to install it via Busybox...
     
  10. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    DevilHunterDante and palmtree5 like this.
  11. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Its working now. The last mkbootimg compiled wasn't compiled properly. I have fixed it now. Works like a boss :). Went through some mess fixing it lol.
     
    irishobo likes this.
  12. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

  13. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Added download link to open source. See OP.
     
  14. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    OP has been updated. I have included an additional binary called mkbootfs to work in conjuction with the other two given the necessary structural building properties of the boot.img. I have tested this on A LOT of boot.img's and all have been successful. I have also updated the instructions for using these binaries on your android device. Enjoy.
     
  15. ruvort

    ruvort Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jul 30, 2011

    Jul 30, 2011
    3
    0
    5
    Each time I try to run this on my rooted LG G2 I get an error...
    u0_a92@vs980:/ $ cd /sdcard/download
    u0_a92@vs980:/sdcard/download $ unmkbootimg -i boot.img
    /system/bin/sh: unmkbootimg: can't execute: Permission denied
     
  16. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    You aren't following my instructions lol. You can't run them on the sdcard because the sdcard is a vfat format which doesn't allow such processing to be completed. That's why I mentioned to place the three binaries in /system/bin and chmod them to 755, then place the boot.img or recovery.img in to /data/local/tmp.
     
  17. palmtree5

    palmtree5 Sunny Vacation Supporter!
    Moderator
    Rank:
     #35
    Points:
    633
    Posts:
    4,580
    Joined:
    May 2, 2012

    May 2, 2012
    4,580
    3,498
    633
    Male
    Student
    USA
    Can you post the output of "ls -l /system/bin" (minus quotes)"
     
  18. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Me or him? Lol
     
  19. ruvort

    ruvort Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jul 30, 2011

    Jul 30, 2011
    3
    0
    5
    Never mind I had to just set the permissions correctly
     
  20. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    So, confirmed working for you? Glad to hear it :)
     
    ruvort likes this.
  21. ruvort

    ruvort Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jul 30, 2011

    Jul 30, 2011
    3
    0
    5
    I also had the error when following your instructions. It was the permissions for the 3 files that needed fixed.
     
  22. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    Yea, I updated this tutorial over on xda. I need to do the same for this one as well. I also need to add a flashable zip like I did over on xda. Thanks.
     
  23. ModdingMyMind

    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    OP Updated with flashable zip and also instructions to insure users chmod such binaries to 755.

    777 is just bad practice ;-)
     
    palmtree5 likes this.
  24. palmtree5

    palmtree5 Sunny Vacation Supporter!
    Moderator
    Rank:
     #35
    Points:
    633
    Posts:
    4,580
    Joined:
    May 2, 2012

    May 2, 2012
    4,580
    3,498
    633
    Male
    Student
    USA
    Him lol but not needed since he got it working





    Good to hear! :)
     
  25. Lordvincent 90

    Lordvincent 90 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    Rank:
    None
    Points:
    583
    Posts:
    5,559
    Joined:
    Oct 5, 2011

    Oct 5, 2011
    5,559
    4,445
    583
    Male
    entertainer
    grand rapids,mi
    Added to all things root guide :)
     
    russellvone likes this.

Share This Page

Loading...