themactep.com

A home of miscellaneous projects by Paul Philippov.

Notes

How to extract a partition from full firmware file

First, look at bootargs for partitions sizes. Let’s take this line as an example:

...
bootargs=mem=${osmem} console=ttyAMA0,115200 root=/dev/mtdblock1 rootfstype=cramfs mtdparts=hi_sfc:256K(boot),3520K(romfs),2560K(user),1280K(web),256K(custom),320K(mtd)
...

Then calculate starting position and length of the partition you need. Say, you need to extract web partition. Then you need to sum up sizes of all partitions before that and turn it into bytes:

$ echo "(256+3520+2560)*1024" | bc
6488064

Then calculate the extracting partition’s length, in bytes, as well:

$ echo "1280*1024" | bc
1310720

Then extract it like this:

$ dd if=full.bin of=web.bin bs=1 skip=6488064 count=1310720