User Tools

Site Tools


doc:appunti:hardware:android_partitions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:hardware:android_partitions [2020/01/17 07:44] – [sgdisk] niccolodoc:appunti:hardware:android_partitions [2020/01/17 12:37] – [The Scatter File] niccolo
Line 8: Line 8:
 **eMMC Flash** combines NAND memory with a built-in controller, that handles most of the things you have to take care of when dealing with NAND flash. **eMMC Flash** combines NAND memory with a built-in controller, that handles most of the things you have to take care of when dealing with NAND flash.
  
 +===== The Scatter File =====
 +
 +A Scatter File is a .txt file which is used to describe **parts of flash memory** in an Android device which is running on a MediaTek’s MTK chipeset. Usually, such files are needed at the time of flashing firmware using tools like the **SP Flash Tool**.
 +
 +Here it is an **excerpt** of a scatter file, showing **where** to **flash** or **readback** the **recovery partition**:
 +
 +<file>
 +- partition_index: SYS9
 +  partition_name: recovery
 +  file_name: recovery.img
 +  is_download: true
 +  type: NORMAL_ROM
 +  linear_start_addr: 0x2D80000
 +  physical_start_addr: 0x2D80000
 +  partition_size: 0x1000000
 +  region: EMMC_USER
 +  storage: HW_STORAGE_EMMC
 +  boundary_check: true
 +  is_reserved: false
 +  operation_type: UPDATE
 +  reserve: 0x00
 +</file>
 +
 +The most important data is **linear_start_addr** and **physical_start_addr** (which are always the same, or not?) that states the starting point of that partition into the flash memory, and **partition_size** which is obviously its lenght.
 +
 +The **SP Flash Tool** program - when performing a //download// (it means a //flashing//) operation - will write the file into the phone starting at the specified address, checking that the file does not exceed the partition size. During a //readback// operation it will read the entire size specified in the scatter file.
 ===== EMMC Regions ===== ===== EMMC Regions =====
  
-**EMMC_BOOT_1** and **EMMC_USER**+**Embedded Multi-Media Controller** (eMMC) refers to a package consisting of both flash memory and a flash memory controller integrated into a single on-board chip. Device supports several hardware partitions, it is on-board and thus non removable. 
 + 
 +  * **BOOT** - one or more small partitions intended for boot firmware; eMMC 4.3 spec requires 2 boot partitions. 
 +  * **RPMB** - Replay Protected Memory Block - intended to store secure data (ie DRM content protection keys); eMMC 4.4 spec adds the requirement of an RPMB partition. 
 +  * **USER** - a large partition intended for general storage; eMMC 4.3 spec requires 1 user partition. 
 + 
 +Into a **scatter file** you can see references to **region** labeled **EMMC_BOOT_1** and **EMMC_USER**, because partition images can live in that different //partitions// or //regions//. NOTICE: the USER partition or region is normally partitioned in turn into other partitions, so - when referring to eMMC partition - it is advisable to use the //region// term, to avoid confusion.
 ===== Inspecting partitions on the command line ===== ===== Inspecting partitions on the command line =====
  
-The following commands were executed on a **ZTE Blade A610**, running **Android 6.0**, via the **adb shell** command. The phone was rooted so that the **su** command was available.+The following commands were executed on a **ZTE Blade A610**, running **Android 6.0**, via the **adb shell** command line. The phone was rooted so that the **su** command was available.
  
 ==== cat /proc/partitions ==== ==== cat /proc/partitions ====
Line 53: Line 85:
 </code> </code>
  
 +The **mmcblk0** partition is actually the eMMC **USER** region, sized 15388672 blocks (15028 Mb). It is in turn partitioned in 23 partitions. The **boot0**, **boot1** and **rpmb** partitions have a size of 4096 blocks each, i.e. **4194304 (0x400000) bytes**.
 ==== sgdisk ==== ==== sgdisk ====
  
Line 58: Line 91:
  
 <code> <code>
-sgdisk --print /dev/block/mmcblk0                                              <+sgdisk --print /dev/block/mmcblk0
 Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB Disk /dev/block/mmcblk0: 30777344 sectors, 14.7 GiB
 Logical sector size: 512 bytes Logical sector size: 512 bytes
Line 92: Line 125:
   23        30743552        30776319   16.0 MiB    0700  flashinfo   23        30743552        30776319   16.0 MiB    0700  flashinfo
 </code> </code>
 +
 +Doing the math, you can see that the 23 partitions existing in **mmcblk0** leave some space: One is at the begin, sized 1024 sectors or **524288 (0x80000) bytes**. The other unpartitioned space is at the end, the size can be calculated by the difference of size shown by ''cat /proc/partitions'', it is again **524288 (0x80000) bytes**. Theese two spaces are referred into the scatter file as **pgpt** and **sgpt** respectively (primary and secondary GPT parition tables?).
 +==== /dev/block/mmcblk0boot0 ====
 +
 +The partition **/dev/block/mmcblk0boot0** is the one referred as region **EMMC_BOOT_1** in the scatter file, and it is dedicated to the **preloader**.
 +
 +The actual Linux device content starts with the characters **EMMC_BOOT**. It seems that it is an header of **2048 (0x800) bytes** and the actual preloader follows that header. FIXME Some stock ROMs include the preloader image, without that header. But if you readback the preloader partition using **SP Flash Tool**, you get an image with that heder included.
 ===== Web References ===== ===== Web References =====
  
-  * **[[http://www.lieberbiber.de/2015/07/02/mediatek-details-soc-startup/]]**+  * **[[http://www.lieberbiber.de/2015/07/02/mediatek-details-soc-startup/|MediaTek details: SoC startup]]**
   * **[[http://www.lieberbiber.de/2015/07/04/mediatek-details-partitions-and-preloader/|MediaTek details: Partitions and Preloader]]**   * **[[http://www.lieberbiber.de/2015/07/04/mediatek-details-partitions-and-preloader/|MediaTek details: Partitions and Preloader]]**
 +  * **[[http://trac.gateworks.com/wiki/MMC|MultiMediaCard (MMC)]]**