dimanche 4 novembre 2012

Creating a dd-able image (Mele_4.0_V1.3BETA_revised_en_us_4.img.bz2)


I saw the lundman method (see conversation: http://ibot.rikers.org/%23arm-netbook/20120702.html.gz, 03:01.59):
- dd if=/dev/zero of=/dev/sdx bs=4096 count=128000 #an image does not exceed 512MB, and I take 4096 as blocksize for read/write flash speedup.
- flash the firmware on the sdcard using PhoenixCard,
- using fdisk -l /dev/sdx you know the FAT partition begin, and as as consequence, the hidden partition end.
- hexdump the /dev/sdx -s <at supposed end of last partition>, see when it gets some zero, you have the real end of the flash image.
Example, on Mele_4.0_V1.3BETA_revised_en_us_4.img
Result: Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2
I flashed my firmware on my sdcard, that is shown as /dev/sdb.

fdisk -l /dev/sdb shows (I have a 2GB  SDCard):

Disk /dev/sdb: 1967 MB, 1967128576 bytes
1 heads, 62 sectors/track, 61968 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *      695166     3839998     1572416+   b  W95 FAT32

Start of the visible partition is at 695166 sector # (means at 695166*512=355924992 bytes):

xxd -a -skip 355924992 /dev/sdb
1536fc00:eb3c 904d 5344 4f53 352e 3000 0208 2000  .<.MSDOS5.0... .
1536fc10:0200 0000 00f0 0000 0000 0000 0000 0000  ................
1536fc20:81fc 2f00 fd0b 0000 0000 0000 0200 0000  ../.............
1536fc30:0100 0600 0000 0000 0000 0000 0000 0000  ................
1536fc40:8000 296f 0000 0020 2020 2020 2020 2020  ..)o...         
1536fc50:2020 4641 5433 3220 2020 0000 0000 0000    FAT32   ......
1536fc60:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
1536fdf0:0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.
1536fe00:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15373c00:f8ff ffff ffff ffff ffff ff0f 0000 0000  ................
15373c10:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
154f3600:f8ff ffff ffff ffff 0000 0000 0000 0000  ................
154f3610:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15673000:2020 2020 2020 2020 2020 2008 d0da e18c             .....
15673010:6441 6441 0000 e18c 6441 0000 0000 0000  dAdA....dA......
15673020:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
1576fc00:f8ff ffff ffff ff0f ffff ff0f 0000 0000  ................
1576fc10:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15943600:f8ff ffff ffff ff0f ffff ff0f 0000 0000  ................
15943610:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15b17000:2020 2020 2020 2020 2020 2008 0000 0000             .....
15b17010:0000 0000 0000 0000 0000 0000 0000 0000  ................
... and nothing more until a little time.

Remember: I zeroed 4096*128000 bytes, I must find out the end, where there are many zeroes until this limit (4096*128000=0x1f400000).
In this case: 0x15b17010 seems to be the end of my FAT32 partition.

So you can suppose that the end of image (including the fat32 partitions) is at 0x15b17010.
0x15b17010 makes in decimal: 88856 blocks of 4096 bytes (rounded up).

dd if=/dev/sdb bs=4096 count=88856 |bzip2 -9 > Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2
The resulting file is a compressed dd-able image.

To write this dd-able image, you can perform:
bzip2 -cd Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2|dd of=/dev/sdx bs=4096


Aucun commentaire:

Enregistrer un commentaire