msm7630 mmc flash partition table
read the MBR
dd if=/dev/block/mmcblk0 of=/sdcard/aa.bak bs=512 count=1
pull the MBR file and will analyze it
adb pull /sdcard/aa.bak .
split the MBR file to two parts include bootstrap codes and partition table record
split -b 446b aa.bak
ls -al
-rw-r--r-- 1 alex alex 512 2011-09-27 09:22 aa.bak
-rw-r--r-- 1 alex alex 446 2011-09-27 09:23 xaa
-rw-r--r-- 1 alex alex 66 2011-09-27 09:23 xab
ghex2 xab
check the line two , the first bytes 80 it means this partition is a bootable partition.
the fifth byte of line 4 "05" means this is an external partition.
open the partition.xml
the section as follows
and the external partition sections
dbl.mbn will be wrote to this bootable partition. (dbl= "Device Boot Loader")
code snapshot in lk
- #define BLOCK_SIZE 0x200
#define TABLE_ENTRY_0 0x1BE
#define TABLE_ENTRY_1 0x1CE
#define TABLE_ENTRY_2 0x1DE
#define TABLE_ENTRY_3 0x1EE
#define TABLE_SIGNATURE 0x1FE
#define TABLE_ENTRY_SIZE 0x010
- #define OFFSET_STATUS 0x00
#define OFFSET_TYPE 0x04
#define OFFSET_FIRST_SEC 0x08
#define OFFSET_SIZE 0x0C
- static unsigned int mmc_boot_read_MBR(void)
-
{
-
unsigned char buffer[MMC_BOOT_RD_BLOCK_LEN];
-
unsigned int dtype;
-
unsigned int dfirstsec;
-
unsigned int EBR_first_sec;
-
unsigned int EBR_current_sec;
-
int ret = 0;
-
int idx, i;
-
-
/* Print out the MBR first */
-
ret = mmc_boot_read_from_card( &mmc_host, &mmc_card, 0, \
-
MMC_BOOT_RD_BLOCK_LEN, \
-
(unsigned int *)buffer);
-
if (ret)
-
{
-
return ret;
-
}
-
-
/* Check to see if signature exists */
-
if ((buffer[TABLE_SIGNATURE] != 0x55) || \
-
(buffer[TABLE_SIGNATURE + 1] != 0xAA))
-
{
-
dprintf(CRITICAL, "MBR signature does not match. \n" );
-
return MMC_BOOT_E_FAILURE;
-
}
-
-
/* Print out the first 4 partition */
-
idx = TABLE_ENTRY_0;
-
for (i = 0; i < 4; i++)
-
{
-
mbr[mmc_partition_count].dstatus = \
-
buffer[idx + i * TABLE_ENTRY_SIZE + OFFSET_STATUS];
-
mbr[mmc_partition_count].dtype = \
-
buffer[idx + i * TABLE_ENTRY_SIZE + OFFSET_TYPE];
-
mbr[mmc_partition_count].dfirstsec = \
-
GET_LWORD_FROM_BYTE(&buffer[idx + \
-
i * TABLE_ENTRY_SIZE + \
-
OFFSET_FIRST_SEC]);
-
mbr[mmc_partition_count].dsize = \
-
GET_LWORD_FROM_BYTE(&buffer[idx + \
-
i * TABLE_ENTRY_SIZE + \
-
OFFSET_SIZE]);
-
dtype = mbr[mmc_partition_count].dtype;
-
dfirstsec = mbr[mmc_partition_count].dfirstsec;
-
mbr_fill_name(&mbr[mmc_partition_count], \
-
mbr[mmc_partition_count].dtype);
-
mmc_partition_count++;
-
if (mmc_partition_count == MAX_PARTITIONS)
-
return ret;
-
}
-
-
/* See if the last partition is EBR, if not, parsing is done */
-
if (dtype != 0x05)
-
{
-
return ret;
-
}
-
-
}
this is only
overlook view ,i will write more details about msm7630_surf partition table.
阅读(1709) | 评论(0) | 转发(0) |