Giter Club home page Giter Club logo

android-unpackbootimg's Introduction

unpackbootimg

unpackbootimg & mkbootimg to work with Android boot images.

Since image tools are not part of Android SDK, this standalone port of AOSP system/core aims to avoid complex building chains.

$ make
$ ./unpackbootimg
usage: unpackbootimg
  -i|--input boot.img
  [ -o|--output output_directory]
  [ -p|--pagesize <size-in-hexadecimal> ]
$ ./mkbootimg
usage: mkbootimg
       --kernel <filename>
       [ --ramdisk <filename> ]
       [ --second <2ndbootloader-filename> ]
       [ --cmdline <kernel-commandline> ]
       [ --board <boardname> ]
       [ --base <address> ]
       [ --pagesize <pagesize> ]
       [ --dt <filename> ]
       [ --kernel_offset <base offset> ]
       [ --ramdisk_offset <base offset> ]
       [ --second_offset <base offset> ]
       [ --tags_offset <base offset> ]
       [ --os_version <A.B.C version> ]
       [ --os_patch_level <YYYY-MM-DD date> ]
       [ --hash <sha1(default)|sha256> ]
       [ --id ]
       -o|--output <filename>
$ ./mkbootimg.py
usage: mkbootimg.py [-h] --kernel KERNEL [--ramdisk RAMDISK] [--second SECOND]
                    [--cmdline CMDLINE] [--base BASE]
                    [--kernel_offset KERNEL_OFFSET]
                    [--ramdisk_offset RAMDISK_OFFSET]
                    [--second_offset SECOND_OFFSET] [--os_version OS_VERSION]
                    [--os_patch_level OS_PATCH_LEVEL]
                    [--tags_offset TAGS_OFFSET] [--board BOARD]
                    [--pagesize {2048,4096,8192,16384}] [--id] -o OUTPUT

Credits to @osm0sis for maintaining most of the unpackbootimg logic that is no longer present in AOSP.

android-unpackbootimg's People

Contributors

anestisb avatar intgr avatar valdikss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-unpackbootimg's Issues

How to use it ?

Please, can you explain how to use it ?
Examples ? Anything ? Has anyone used it with success ?

I myself could unpack, but ' mkbootimg ' never worked once.

It simply always says the same - no error, just repeats " usage: mkbootimg ... " ; I don't get what's wrong, there's nothing wrong but still only that message no matter what options I put or don't put.

I'll give you examples:

my command > ~/Bin/android-unpackbootimg/mkbootimg --kernel boot/boot.img-zImage --ramdisk boot/boot.img-ramdisk.gz --cmdline "console=null androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 androidboot.selinux=permissive" --base 0x80000000 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x02000000 second_offset 0x00f00000 --tags_offset 01e00000 --os_version 8.1.0 --os_patch_level 2019-04 --hash sha1 -o boot2.img

output > usage: mkbootimg
--kernel
[ --ramdisk ]
[ --second <2ndbootloader-filename> ]
[ --cmdline ]
[ --board ]
[ --base

]
[ --pagesize ]
[ --dt ]
[ --kernel_offset ]
[ --ramdisk_offset ]
[ --second_offset ]
[ --tags_offset ]
[ --os_version <A.B.C version> ]
[ --os_patch_level ]
[ --hash <sha1(default)|sha256> ]
[ --id ]
-o|--output

I tried all combinations I could think, yet nothing. Well, if I only use one param it does output an image that never matches the original ; I suppose because it lacks the info from those parameters.

On the other hand, the python implementation does accept all params but the output never matches the input by little, but sill not the same.
Not to mention the simple adjusts I had to make. For instance, now hex numbers must be precceded by ' 0x '. Some params are filenames other are the files content and so on.

My best regards

header v3 format not implemented

log:
~/dtimgextract/unpack$ ../dtimgextract ../boot.img-dtb
qc_magic: QCDT
version: 3
count: 204
header v3 format not implemented

When I try to unapck an android 4.4 boot.img-dtb file, it does not work.

Segfault if --input is a loop device

Looks like the source assumes the input is a normal file and not a block special device.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a9ccbb in __mempcpy_sse2 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7a9ccbb in __mempcpy_sse2 () from /lib64/libc.so.6
#1  0x00007ffff7a877ee in __GI__IO_file_xsgetn () from /lib64/libc.so.6
#2  0x00007ffff7a7c1ef in fread () from /lib64/libc.so.6
#3  0x0000000000402253 in main (argc=0, argv=0x7fffffffe400) at unpackbootimg.c:293
(gdb) up 3
#3  0x0000000000402253 in main (argc=0, argv=0x7fffffffe400) at unpackbootimg.c:293
293                 if(fread(second_test, second_test_size, 1, f)){};
(gdb) list
288             struct stat st;
289             stat(filename, &st);
290             int second_test_size = st.st_size - total_read;
291             if (second_test_size > header.dt_size) {
292                 byte* second_test = (byte*)malloc(second_test_size);
293                 if(fread(second_test, second_test_size, 1, f)){};
294                 u_int16_t *sbuf = (u_int16_t*)second_test;
295                 if (sbuf[0]) {
296                     int second_size = 0;
297                     while (sbuf[0]) {
(gdb) p second_test_size
$1 = -8976384
(gdb) p st.st_size
$2 = 0
(gdb) p filename
$3 = 0x7fffffffe6ad "/dev/loop10p30"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.