Chinaunix首页 | 论坛 | 博客
  • 博客访问: 137843
  • 博文数量: 52
  • 博客积分: 203
  • 博客等级: 入伍新兵
  • 技术积分: 310
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-20 10:43
文章分类

全部博文(52)

文章存档

2015年(2)

2012年(11)

2011年(39)

分类: LINUX

2011-09-27 10:32:05

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
  1. #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

  2. #define OFFSET_STATUS             0x00
    #define OFFSET_TYPE               0x04
    #define OFFSET_FIRST_SEC          0x08
    #define OFFSET_SIZE               0x0C

  3. static unsigned int mmc_boot_read_MBR(void)
  4. {
  5.     unsigned char buffer[MMC_BOOT_RD_BLOCK_LEN];
  6.     unsigned int dtype;
  7.     unsigned int dfirstsec;
  8.     unsigned int EBR_first_sec;
  9.     unsigned int EBR_current_sec;
  10.     int ret = 0;
  11.     int idx, i;

  12.     /* Print out the MBR first */
  13.     ret = mmc_boot_read_from_card( &mmc_host, &mmc_card, 0, \
  14.                                    MMC_BOOT_RD_BLOCK_LEN, \
  15.                                    (unsigned int *)buffer);
  16.     if (ret)
  17.     {
  18.         return ret;
  19.     }

  20.     /* Check to see if signature exists */
  21.     if ((buffer[TABLE_SIGNATURE] != 0x55) || \
  22.         (buffer[TABLE_SIGNATURE + 1] != 0xAA))
  23.     {
  24.         dprintf(CRITICAL, "MBR signature does not match. \n" );
  25.         return MMC_BOOT_E_FAILURE;
  26.     }

  27.     /* Print out the first 4 partition */
  28.     idx = TABLE_ENTRY_0;
  29.     for (i = 0; i < 4; i++)
  30.     {
  31.         mbr[mmc_partition_count].dstatus = \
  32.                     buffer[idx + i * TABLE_ENTRY_SIZE + OFFSET_STATUS];
  33.         mbr[mmc_partition_count].dtype = \
  34.                     buffer[idx + i * TABLE_ENTRY_SIZE + OFFSET_TYPE];
  35.         mbr[mmc_partition_count].dfirstsec = \
  36.                     GET_LWORD_FROM_BYTE(&buffer[idx + \
  37.                                         i * TABLE_ENTRY_SIZE + \
  38.                                         OFFSET_FIRST_SEC]);
  39.         mbr[mmc_partition_count].dsize = \
  40.                     GET_LWORD_FROM_BYTE(&buffer[idx + \
  41.                                         i * TABLE_ENTRY_SIZE + \
  42.                                         OFFSET_SIZE]);
  43.         dtype = mbr[mmc_partition_count].dtype;
  44.         dfirstsec = mbr[mmc_partition_count].dfirstsec;
  45.         mbr_fill_name(&mbr[mmc_partition_count], \
  46.                       mbr[mmc_partition_count].dtype);
  47.         mmc_partition_count++;
  48.         if (mmc_partition_count == MAX_PARTITIONS)
  49.             return ret;
  50.     }

  51.     /* See if the last partition is EBR, if not, parsing is done */
  52.     if (dtype != 0x05)
  53.     {
  54.         return ret;
  55.     }

  56. }
this is only  overlook view ,i will write more details about msm7630_surf partition table.



阅读(1716) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~