Wednesday, September 12, 2012

How to split boot.img and get kernel config.

boot_cm9.img  file from mk802_legacy-compatibility_v1.zip
Device: Rikomagic MK802
Script files : Split_bootimg.pl , extract-ikconfig ( in {kernel_source}/script )

1. split boot.img
$ mkdir split_boot
$ cd split_boot
Copy boot_cm9.img, Split_bootimg.pl, extract-ikconfig into 'split_boot'
$ ./split_bootimg.pl boot_cm9.img
Page size: 2048 (0x00000800)
Kernel size: 8094708 (0x007b83f4)
Ramdisk size: 178940 (0x0002bafc)
Second size: 0 (0x00000000)
Board name:
Command line: console=ttyS0,115200 rw init=/init loglevel=8
Writing boot_cm9.img-kernel ... complete.
Writing boot_cm9.img-ramdisk.gz ... complete.

Get kernel image (boot_cm9.img-kernel) and ramdisk (boot_cm9.img-ramdisk.gz)

2. extract kernel config
$ dd if=boot_cm9.img-kernel of=dd_uImage bs=1024 skip=1
7903+1 records in
7903+1 records out
8093684 bytes (8.1 MB) copied, 0.0178518 s, 453 MB/s
$./extract-ikconfig dd_uImage > kernel_config


3. extract ramdisk
$ mkdir ramdisk
$ cd ramdisk
$ gzip -dc ../boot_cm9.img-ramdisk.gz | cpio -i
6677 blocks
$ tree .
.
├── data
├── default.prop
├── dev
├── init
├── init.goldfish.rc
├── initlogo.rle
├── init.rc
├── init.sun4i.rc
├── init.sun4i.usb.rc
├── proc
├── sbin
│   ├── adbd
│   └── ueventd -> ../init
├── sys
├── system
├── ueventd.goldfish.rc
├── ueventd.rc
└── ueventd.sun4i.rc


Ref : HOWTO: Unpack, Edit, and Re-Pack Boot Images