2013年9月26日 星期四

boot.img to image (binary vmlinux)

1. download image unpack tools
http://www.mediafire.com/file/2zcwc74bzjxej4b/android_bootimg_tools.tar.gz

2.
mkdir ./zimage
./unpackbootimg -i boot.img -o ./zimage

3.
cd zimage
/mnt/projects/iTOP-iMX6_android4.4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-objdump -EL -b binary -D -m armv5t ./boot.img-zImage | grep 8b1f

show:
    49fc:    00088b1f     andeq    r8, r8, pc, lsl fp
   18f7c:    6d748b1f     ldclvs    11, cr8, [r4, #-124]!    ; 0xffffff84

4.
0x49fc = 18940
dd if=boot.img-zImage of=piggy.gz bs=1 skip=18940

5.
gunzip -c ./piggy.gz > ./image
then compare to
/mnt/projects/iTOP-iMX6_android4.4.2/kernel_imx/arch/arm/boot/Image
must be same

6. (option)
cp /mnt/projects/iTOP-iMX6_android4.4.2/kernel_imx/vmlinux ./

//check parameter
/mnt/projects/iTOP-iMX6_android4.4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-objcopy --info

//refer to
OBJCOPYFLAGS of /mnt/projects/iTOP-iMX6_android4.4.2/kernel_imx/arch/arm/Makefile
//we get
OBJCOPYFLAGS :=-O binary -R .comment -S

/mnt/projects/iTOP-iMX6_android4.4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-objcopy -O binary -R .comment -S ./vmlinux ./image

//then compare to
/mnt/projects/iTOP-iMX6_android4.4.2/kernel_imx/arch/arm/boot/Image
must be same

7.  (option)
//revert to elf
/mnt/projects/iTOP-iMX6_android4.4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-objdump -D -b binary -marm ./image
//and compare to

/mnt/projects/iTOP-iMX6_android4.4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-objdump -d ./vmlinux
//both arm code are the same

Ref:
1. https://acassis.wordpress.com/2015/06/04/how-to-recover-and-decompress-a-linux-kernel-dumped-mtd-partition
2. https://blog.csdn.net/shiyongyue/article/details/73732511
3. https://www.veryarm.com/12058.html

沒有留言:

張貼留言