Skip to content

MTKPartitionLayout

Kees Jongenburger edited this page Jun 24, 2014 · 10 revisions

Mediatek partition layout

Mediatek uses some tools to generate it's partitions and manage the MMC.

It uses a xls source file and a tool called ptgen.pl to generate headers for handling partitions.

Ptgen generates headers for all the devices needing to access the storage:

  • The preloader.
  • U-Boot.
  • lk (the Android bootloader doinng fastboot and such).
  • The Linux kernel.
  • The scatter files used for uploading and flashing the device.
CUSTOM_MEMORYDEVICE_H_NAME  = "mediatek/custom/$PROJECT/preloader/inc/custom_MemoryDevice.h";
PARTITION_DEFINE_H_NAME     = "mediatek/custom/$PROJECT/common/partition_define.h"; # 
PARTITION_DEFINE_C_NAME		= "mediatek/platform/$platform/kernel/drivers/dum-char/partition_define.c";
EMMC_PART_SIZE_LOCATION		= "mediatek/config/$PROJECT/configs/EMMC_partition_size.mk" ; # store the partition size for ext4 buil

my $PMT_H_NAME          = "mediatek/custom/$PROJECT/common/pmt.h";
#for autogen uboot preload and kernel partition struct
ProjectConfig		="mediatek/config/$PROJECT/ProjectConfig.mk";
UbootH	="mediatek/custom/$PROJECT/uboot/inc/mt65xx_partition.h";
UbootC	="mediatek/custom/$PROJECT/uboot/mt65xx_partition.c";
PreloaderH	="mediatek/custom/$PROJECT/preloader/inc/cust_part.h";
PreloaderC	="mediatek/custom/$PROJECT/preloader/cust_part.c";
KernelH 	="mediatek/custom/$PROJECT/kernel/core/src/partition.h";
Uboot_PartitionC = "mediatek/custom/$PROJECT/uboot/partition.c"; 

LK_CUSTOM = "mediatek/custom/$PROJECT/lk";
LK_CUSTOM_INC = "mediatek/custom/$PROJECT/lk/inc";
LK_MT_PartitionH = "mediatek/custom/$PROJECT/lk/inc/mt_partition.h";
LK_PartitionC = "mediatek/custom/$PROJECT/lk/partition.c"; 
LK_CUSTOM_OUT_LK = "mediatek/custom/out/$FULL_PROJECT/lk";
LK_CUSTOM_OUT_LK_INC = "mediatek/custom/out/$FULL_PROJECT/lk/inc";

mediatek/custom/ahong89_wet_jb2/lk/inc/mt_partition.h mediatek/custom/ahong89_wet_jb2/lk/partition.c mediatek/custom/ahong89_wet_jb2/common/partition_define.h

Mapping of data to MBR EBR1 and EBR2 mediatek/platform/mt6589/kernel/drivers/dum-char/partition_define.c

Partitions and start address. mediatek/platform/mt6589/kernel/drivers/mmc-host/part_info_emmc.c

The dumchar.c driver is the kernel driver exposing partitions to userland. This is where a lot of magic happens.

Random info from the driver:

There are 3 address in eMMC Project: Linear Address, Logical Address, Physical Address
Linear Address: Used in scatter file, uboot, preloader,flash tool etc.
Linear Address: MBR linear address is fixed in eMMCComo.mk, that is same for all chips in the project
Logical Address: Used in /proc/dumchar_info, mmcblk0 etc. MBR logical address is 0
Physical Address: Used in eMMC driver, MBR Physical Address = MBR Linear Address - (BOOT1 size + BOOT2 Size + RPMB Size)
define  User_Region_Header (BOOT1 size + BOOT2 Size + RPMB Size)

/* Anotated content of a scatter file */

PRELOADER 0x0
MBR 0x600000                    /* Master boot record */
EBR1 0x680000			/* MTK extention like a Master boot record */
__NODL_PMT 0x700000		/* Something related to the partition(a binary version of scatter files) */
__NODL_PRO_INFO 0xb00000
__NODL_NVRAM 0xe00000		/* Storage for factory date serial number etc */
__NODL_PROTECT_F 0x1300000
__NODL_PROTECT_S 0x1d00000
__NODL_SECCFG 0x2700000
UBOOT 0x2720000			/* Uboot boot loader
BOOTIMG 0x2780000		/* Normal boot kernel/rootfs */
RECOVERY 0x2d80000		/* Recovery kernel/rootfs */
SEC_RO 0x3380000
__NODL_MISC 0x3980000
LOGO 0x3a00000			/* Animated boot logo */
EBR2 0x3d00000			/* Second extended boot record */
__NODL_EXPDB 0x3d80000
ANDROID 0x4780000		/* The Android /system partition */
CACHE 0x2d180000		/* The /cache partition */
USRDATA 0x34f80000		/* The /data partition */
__NODL_FAT 0x74f80000		/* The FAT partition */
130|root@android:/proc # cat emmc                                              
partno:    start_sect   nr_sects  partition_name
emmc_p1: 00000400 00000002 "ebr1"
emmc_p2: 00006800 00005000 "protect_f"
emmc_p3: 0000b800 00005000 "protect_s"
emmc_p4: 00016c00 00003000 "sec_ro"
emmc_p5: 00020c00 00145000 "android"
emmc_p6: 00165c00 0003f000 "cache"
emmc_p7: 001a4c00 00200000 "usrdata"
emmc_p8: 003a4c00 019f9d00 "fat"
root@android:/proc # cat dumchar_info                                          
Part_Name       Size    StartAddr       Type    MapTo
preloader    0x0000000000600000   0x0000000000000000   2   /dev/misc-sd
mbr          0x0000000000080000   0x0000000000000000   2   /dev/block/mmcblk0
ebr1         0x0000000000080000   0x0000000000080000   2   /dev/block/mmcblk0p1
pmt          0x0000000000400000   0x0000000000100000   2   /dev/block/mmcblk0
pro_info     0x0000000000300000   0x0000000000500000   2   /dev/block/mmcblk0
nvram        0x0000000000500000   0x0000000000800000   2   /dev/block/mmcblk0
protect_f    0x0000000000a00000   0x0000000000d00000   2   /dev/block/mmcblk0p2
protect_s    0x0000000000a00000   0x0000000001700000   2   /dev/block/mmcblk0p3
seccfg       0x0000000000020000   0x0000000002100000   2   /dev/block/mmcblk0
uboot        0x0000000000060000   0x0000000002120000   2   /dev/block/mmcblk0
bootimg      0x0000000000600000   0x0000000002180000   2   /dev/block/mmcblk0
recovery     0x0000000000600000   0x0000000002780000   2   /dev/block/mmcblk0
sec_ro       0x0000000000600000   0x0000000002d80000   2   /dev/block/mmcblk0p4
misc         0x0000000000080000   0x0000000003380000   2   /dev/block/mmcblk0
logo         0x0000000000300000   0x0000000003400000   2   /dev/block/mmcblk0
ebr2         0x0000000000080000   0x0000000003700000   2   /dev/block/mmcblk0
expdb        0x0000000000a00000   0x0000000003780000   2   /dev/block/mmcblk0
android      0x0000000028a00000   0x0000000004180000   2   /dev/block/mmcblk0p5
cache        0x0000000007e00000   0x000000002cb80000   2   /dev/block/mmcblk0p6
usrdata      0x0000000040000000   0x0000000034980000   2   /dev/block/mmcblk0p7
fat          0x000000033f3a0000   0x0000000074980000   2   /dev/block/mmcblk0p8
bmtpool      0x0000000001500000   0x00000000ff9f00a8   2   /dev/block/mmcblk0
Part_Name:Partition name you should open;
Size:size of partition
StartAddr:Start Address of partition;
Type:Type of partition(MTD=1,EMMC=2)
MapTo:actual device you operate
Clone this wiki locally