4/5/13

Unpack - repacking -ramdisk

Bài viết dành cho KTV, tôi ghi lại để ghi nhớ những gì đã làm.

Hôm nay tôi mày mò tìm cách giải nén ramdisk chỉnh sửa rồi nén nó lại, đa phần tôi làm trên ubuntu của mình. Bạn có thề tìm tools tương tự chạy trên windows để làm.

Đầu tiên là lấy boot.img từ android copy vào working dir

$ ./unpackbootimg /path/to/boot.img


section sizes incorrect
kernel 800 50bcc8
ramdisk 50c800 7de00
second 58a800 0
total 58a800 a00000
...but we can still continue
WARNING: non-standard load addresses!
WARNING: SHA checksum does not match



Bây giờ chúng ta nên có 1 file nén ramdisk và kernel image, tùy chỉnh theo yêu cầu rồi repack lại như sao:

$ ./mkbootfs /path/to/ramdisk | gzip > ramdisk-new.gz

Xem lại file boot.img-mk trong thư mục chứa ramdisk.gz và kernel.img để repack

$ ./mkbootimg --output boot-hot.img --kernel boot.img-kernel --ramdisk ramdisk-new.gz   --cmdline '' --board '' --base 80000000 --pagesize 4096

done...

PS: Working with sky a820l kernel I found standard unpacking method did not work anymore, take a look at split_bootimg.pl output:


Page size: 2048 (0x00000800)
Kernel size: 5291208 (0x0050bcc8)
Ramdisk size: 515584 (0x0007de00)
Second size: 0 (0x00000000)
Board name:
Command line: console=ttyHSL0,115200,n8 androidboot.hardware=qcom androidboot.carrier=LGT-KOR loglevel=0
Writing cm10boot.img-kernel ... complete.
Writing cm10boot.img-ramdisk.gz ... complete.


while unpackbootimg show:

WARNING: non-standard load addresses!
WARNING: SHA checksum does not match

Haiz...now dump to get more info

$ hexdump -n 40 cm10boot.img

0000000 4e41 5244 494f 2144 bcc8 0050 8000 4020
0000010 de00 0007 0000 4150 0000 0000 0000 4110
0000020 0100 4020 0800 0000                  
0000028


So:

Android! = 4e41 5244 494f 2144
Kernel size = 0050 bcc8
Kernel address = 4020 8000 base maybe 4020 0000
Ramdisk size = 0007 de00
Ramdisk address = 4150 0000 base maybe 4050000
Secondary size = 0000 0000
Secondary Address = 4110 0000 base maybe 4020 0000
Tags address = 4020 0100 confirm base = 40200 000
Page size = 0000 0800 = 2048

split-bootimg seem to get the right sizes, so i assumed it got the right image and i worked with it.
As mkbootimg.c working with options:

            hdr.kernel_addr =  base + 0x00008000;
            hdr.ramdisk_addr = base + 0x01000000;
            hdr.second_addr =  base + 0x00F00000;
            hdr.tags_addr =    base + 0x00000100;
It will break boot.img, repair those options is necessary

Now to check if it work again...


$ hexdump -n 40 boottest.img
0000000 4e41 5244 494f 2144 bcc8 0050 8000 4020
0000010 de00 0007 0000 4150 0000 0000 0000 4110
0000020 0100 4020 0800 0000                  
0000028
$ hexdump -n 40 cm10boot.img
0000000 4e41 5244 494f 2144 bcc8 0050 8000 4020
0000010 de00 0007 0000 4150 0000 0000 0000 4110
0000020 0100 4020 0800 0000                  
0000028
Nice...







Không có nhận xét nào:

Đăng nhận xét