Unpack and pack Rockchip boot.img image (RK3066/RK3188)

Rockchip's boot image is different from standard Android boot image in that it does not contain a kernel image. actually, it's a gizped cpio ramdisk image that takes over the booting process from the kernel. In addition, there is a 8 byte header in the boot image and you need to strip that part off before you can uncompress it using gzip command.

unpack the boot images

As mentioned before, first we need to remove the 8 byte header from the image. The command is

dd if=boot.img of=boot.img.gz skip=8 bs=1 count=100000000000

We use the Linux DD command to dump the boot image to a new boot file without the first 8 byte header
if stands for input file
of stands for output file
skip tell the DD command to skip the first 8 blocks
bs is the block size
count is the number of block. you can specify any random number but it must be larger than the boot image size.

When this is done, you can use gzip command to decompress it.

mv boot.img boot.img.gz

gunzip boot.img.gz

Now you get a cpio file

the next step is to further uncompress the cpio archive file

first we create a new directory to contain the file system

mkdir unpacked

then enter the new directory and use the cpio command to uncompress it

cd unpacked

cpio -i <../boot.img

Repack the boot image

After making changes to the boot ramdisk, now we need to repack it into a working image

first, we need to restore its original date

find . | xargs -I file touch -d "1970-01-01 01:00" file

Then compress it using gzip and cpio commands


find . | cpio -o -H newc | gzip -n >../newboot.img.gz

the last step is using rkcrc command to make it compatible with Rockchip device

./rkcrc -k newboot.img.gz newboot.img