[Miscellaneous Android Development] sambwel:
-rwxr-xr-x@ 1 sambwel staff 7149568 6 May 17:59 boot.img

$ ./mtkimg unpack boot.img -v
MTKIMG V0.36(osx64) by rom1nux
Unpacking boot image 'boot.img'...
Reading image header (596 bytes)...
Seeking to start of kernel (0x00000800)...
Reading MTK header (512 bytes)...
Unpacking kernel to 'kernel.img' (6151958 bytes)...
Reading kernel zimage header from 'kernel.img' (4 bytes)...
Seeking to start of ramdisk (0x005DF000)...
Reading MTK header (512 bytes)...
Unpacking ramdisk to 'ramdisk-tmp.cpio.gz' (991716 bytes)...
Reading gzip header from 'ramdisk-tmp.cpio.gz' (2 bytes)...
Unpacking ramdisk content to 'ramdisk.d'...
Create directory 'ramdisk.d'...
Changing directory 'ramdisk.d'...
Unpacking ramdisk content...
gzip -d -c ../ramdisk-tmp.cpio.gz | cpio -i --quiet
Changing directory '/Users/sambwel/mtkimg/build'...
Removing file 'ramdisk-tmp.cpio.gz'...
Writing image configuration file 'image.ini'...
Boot image successfully unpacked !

ramdisk.d/ size seems normal...

image.ini:

; Image configuration file - Write by mtkimg V0.36(osx64)

; Layout

size=7149568
type=ROOTFS

; Header

signature=ANDROID!
kernel-load-addr=0x40008000
ramdisk-load-addr=0x44000000
second-load-addr=0x40F00000
tags-addr=0x4E000000
page-size=2048
product=B04
cmdline=bootopt=64S3,32S1,32S1
id=3564B1A5EC7589240E045EA9E4CC3F50F5700080

$ ./mtkimg repack new_boot.img -k kernel.img -r ramdisk.d -v
MTKIMG V0.36(osx64) by rom1nux
Repacking image to 'new_boot.img'...
Packing ramdisk content from 'ramdisk.d'...
Changing directory 'ramdisk.d'...
Packing ramdisk content...
find . | cpio -o -H newc --quiet | gzip -6 -n > ../ramdisk-tmp.cpio.gz
Changing directory '/Users/sambwel/mtkimg/build'...
Reading mtk header from 'kernel.img' (4 bytes)...
Reading kernel zimage header from 'kernel.img' (4 bytes)...
File 'kernel.img' is ARM Linux zImage file !
Reading mtk header from 'ramdisk-tmp.cpio.gz' (4 bytes)...
Reading gzip header from 'ramdisk-tmp.cpio.gz' (2 bytes)...
File 'ramdisk-tmp.cpio.gz' is GZIP file !
Loading image configuration file 'image.ini'...
Writing image header (596 bytes)...
Padding (1452 bytes)...
Writing MTK header (512 bytes)...
Repacking kernel 'kernel.img' (6151958 bytes)...
Padding (1770 bytes)...
Writing MTK header (512 bytes)...
Repacking ramdisk 'ramdisk-tmp.cpio.gz' (994466 bytes)...
Padding (-1698 bytes)...
Removing file 'ramdisk-tmp.cpio.gz'...
Image successfully repacked !

Immediately after "Padding (-1698 bytes)..." it seems to hang for some time while it keeps processing.... -1698 bytes doesn't sound right! :p

-rw-r--r-- 1 sambwel staff 4302116864 16 Jul 21:12 new_boot.img

:silly:

now with -n option:

$ ./mtkimg unpack boot.img -n -k kernel.img -r ramdisk.cpio.gz -v
MTKIMG V0.36(osx64) by rom1nux
Unpacking boot image 'boot.img'...
Reading image header (596 bytes)...
Seeking to start of kernel (0x00000800)...
Reading MTK header (512 bytes)...
Unpacking kernel to 'kernel.img' (6151958 bytes)...
Reading kernel zimage header from 'kernel.img' (4 bytes)...
Seeking to start of ramdisk (0x005DF000)...
Reading MTK header (512 bytes)...
Unpacking ramdisk to 'ramdisk.cpio.gz' (991716 bytes)...
Reading gzip header from 'ramdisk.cpio.gz' (2 bytes)...
Writing image configuration file 'image.ini'...
Boot image successfully unpacked !

-rw-r--r-- 1 sambwel staff 6151958 16 Jul 21:18 kernel.img
--rw-r--r-- 1 sambwel staff 991716 16 Jul 21:18 ramdisk.cpio.gz

$ ./mtkimg repack newboot.img -n -k kernel.img -r ramdisk.cpio.gz -v
MTKIMG V0.36(osx64) by rom1nux
Repacking image to 'newboot.img'...
Reading mtk header from 'kernel.img' (4 bytes)...
Reading kernel zimage header from 'kernel.img' (4 bytes)...
File 'kernel.img' is ARM Linux zImage file !
Reading mtk header from 'ramdisk.cpio.gz' (4 bytes)...
Reading gzip header from 'ramdisk.cpio.gz' (2 bytes)...
File 'ramdisk.cpio.gz' is GZIP file !
Loading image configuration file 'image.ini'...
Writing image header (596 bytes)...
Padding (1452 bytes)...
Writing MTK header (512 bytes)...
Repacking kernel 'kernel.img' (6151958 bytes)...
Padding (1770 bytes)...
Writing MTK header (512 bytes)...
Repacking ramdisk 'ramdisk.cpio.gz' (991716 bytes)...
Padding (1052 bytes)...
Image successfully repacked !

very quick this time - instant!

-rw-r--r-- 1 sambwel staff 7149568 16 Jul 21:24 newboot.img

yep, seems perfect.

so the problem looks like it's just about compressing the ramdisk folder when repacking.... hope it's simple to fix :)