1.Partition.xml
<physical_partition number="0">
<primary order="1" type="c" bootable="false" label="FAT" size="819200"
readonly="false">
</primary>
<primary order="2" type="4d" bootable="true" label="CFG_DATA" size="1000"
readonly="true">
<file name="dbl.mbn" offset="0"/>
</primary>
<primary order="3" type="46" bootable="false" label="OEMSBL" size="3000"
readonly="false">
<file name="osbl.mbn" offset="0"/>
</primary>
2. MBR in Partition.bin(example)
MBR is programmed in the first block of physical user partition and it has
four entries including one link to EBR.
Here, 0x1BE(446 + code size(440) + 4 bytes disk sig + 2 bytes null bytes) is
the start of first entry
of partition_entry in structure listed in section 5. The contents will be
flashed to The first sector
of eMMC card user physical partition when use mjsdload.cmm or msp to program
the partition.bin to the
eMMC card. More detail can be found in ms_program_card.c.
such as the following partition.bin matched the partition.xml listed above
000001b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000001c0h: 00 00 0C 00 00 00 01 00 00 00 00 80 0C 00 80 00 ; ...........�.�
000001d0h: 00 00 4D 00 00 00 01 80 0C 00 E8 03 00 00 00 00 ; ..M....�.?....
000001e0h: 00 00 46 00 00 00 E9 83 0C 00 B8 0B 00 00 00 00 ; ..F...�..?....
000001f0h: 00 00 05 00 00 00 A1 8F 0C 00 40 42 0F 00 55 AA ; ......�..@B..U
0x1BE is FAT (MBR_ENTRY_0)
0x1BE = boot able = 0 FALSE
0x1BE+4 = type = 0xC = FAT
0x1BE+8= start sector = 0x1
0x1BE+0xC = Size = 0xC0800 = 8192000 (if it is not the last entry of partition
, the size is matched to partition.xml)
0x1BE+0x10 =0x1CE is the format of MBR_entry_1
0x1CE is DBL (MBR_ENTRY_1) DBL is taken as boot able partition.
0x1CE = Boot able = 0x80 = TRUE.
0x1CE+4 = 0x1D2 = type = 0x4D
0x1D2+4 = 0x1D6 = start sector = 0xC08001 = 819201
0x1D6+4 = size = 0x300
0x1DE is the osbl(MBR_ENTRY_2)
0x1EE is the EBR entry
0x1EE+4 = type = 0x5(EBR type)
The size of last entry in MBR is automatically align to WP_GROUP_SIZE(64MB),
that means it will fill the 64MB space.
3. EBR in partition bin(example)
Each EBR has 512 bytes , it has one partition entry and one link to next EBR.
example for the FOTA partition in EBR.
in XML it is
<extended order="2" type="4c" label="FOTA" size="64000" readonly="false">
</extended>>
in partiton.bin, it is
000005b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000005c0h: 00 00 4C 00 00 00 5E 70 03 00 00 FA 00 00 00 00 ; ..L...^p...?...
000005d0h: 00 00 05 00 00 00 02 00 00 00 01 18 00 00 00 00 ; ................
000005e0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000005f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ; ..............U
the EBR will be programmed to type is
0x5C2 = 0xC = FOTA
0x5C6 = start sector = 0030705E (start location of EBR, the content will
write to next adjacent sector)
0x5EA = size = 0x0000FA00 = 64000 (bytes)
If the entry is the last entry partition in EBR, then the size of the last
entry will automatically fill up to the size of the
card(physical user partition)
4. How PBL read the MBR.
In PBL, we will read the first sector (512 bytes) and map to following structure.
flash_status = pbl_sdc_read_sector_bytes( sdc_dev, 0, 0, (uint32)sizeof(
mbr_sector_t), (uint8*) &mbr);
So we can see
Last 16bytes is 0x55AA for the MBR magic number
The start sector and length in partition_entry will match to the start sector
and length in MBR_ENTRY_x(X=0…3)
status is map to the boot able field in the MBR_ENTRY_X(X=0…3)
/* MBR structure definition */
typedef __packed struct
{
/* Code region. Unused but leave it here to compliance with MBR standard */
uint8 code_section[CODE_AREA_SIZE];
CODE_AREA_SIZE = 440bytes.
/* Disk Signature */
uint32 disk_sig;
/* NULL */
uint16 null_bytes;
/* 4 partition table entry */
partition_entry_t partition_entry[4];
/* 0x55AA */
uint16 mbr_signature;
}mbr_sector_t;
typedef __packed struct partition_entry
{
/* current status unused */
uint8 status;
/* CHS address of the first sector, unused */
CHS_type CHS_start;
/* unused */
uint8 partition_type;
/* CHS address of the last sector, unused */
CHS_type CHS_end;
/* logical address of first sector, in sectors */
uint32 start_sector;
/* length of partion, in sectors*/
uint32 lenght;
}partition_entry_t ;
No comments:
Post a Comment