When flashing official stock firmware onto modern Android smartphones, flashing utilities like SP Flash Tool, QFIL, and QPST do not guess where binary partitions belong on physical storage. Instead, they rely on structured partition descriptor maps: MediaTek Scatter Files (.txt format) and Qualcomm Rawprogram & Patch0 Files (.xml format).
For mobile repair technicians, mastering how scatter files and rawprogram XMLs define physical storage sectors, boundary alignments, and partition labels is vital. This knowledge prevents disastrous partition overlaps, solves memory size mismatch errors, and enables successful unbricking when restoring damaged partition tables.
1. MediaTek Scatter File Architecture
A MediaTek scatter file is a structured plain text configuration file that instructs the Download Agent (DA) exactly how the internal eMMC or UFS storage is segmented into logical blocks.
Key Elements of a Modern MediaTek Scatter File:
- general: MT6768
compiler: ARM
chip: MT6768
platform: MT6768
- partition_index: SYS15
partition_name: boot
file_name: boot.img
is_download: true
type: NORMAL_ROM
linear_start_addr: 0x14800000
physical_start_addr: 0x14800000
partition_size: 0x4000000
region: EMMC_USER
Anatomy of Key Scatter Parameters:
- partition_name: The exact internal label recognized by Android Verified Boot and the partition table (e.g.,
boot,super,nvdata). - file_name: The physical file on disk that SP Flash Tool will read and write to this partition (e.g.,
boot.img). - is_download: A boolean flag (
trueorfalse) indicating whether this partition should be updated during standard flashing routines. - linear_start_addr & physical_start_addr: The hexadecimal start byte offset on the storage medium.
- partition_size: The maximum allowable byte size allocated for this partition. If a firmware binary exceeds this size, SP Flash Tool raises a PMT (Partition Map Table) error.
- region: Specifies the physical hardware partition on the memory chip, such as
EMMC_USER,EMMC_BOOT_1, orUFS_LUN0.
2. Qualcomm Rawprogram & Patch0 XML Architecture
Qualcomm chipsets utilize Extensible Markup Language (XML) files to configure Emergency Download (EDL) flashing routines through the Sahara and Firehose protocols.
The Rawprogram XML (e.g., rawprogram0.xml):
The rawprogram file maps raw binary images to absolute 512-byte disk sectors:
<data>
<program
SECTOR_SIZE_IN_BYTES="512"
file_sector_offset="0"
filename="boot.img"
label="boot"
num_partition_sectors="131072"
physical_partition_number="0"
start_sector="655360" />
</data>
- SECTOR_SIZE_IN_BYTES: Hardware sector block size, standardly
512bytes for eMMC and emulated UFS blocks. - start_sector: The exact logical sector address where writing begins. Multiplying start_sector by 512 yields the byte offset.
- num_partition_sectors: The number of contiguous sectors allocated for the partition.
- physical_partition_number: Maps to the physical storage LUN (Logical Unit Number). On UFS devices, LUN0 through LUN5 hold separate system, boot, and provisioning partitions.
The Essential Role of patch0.xml:
Unlike MediaTek scatter files which contain fixed absolute addresses, modern Qualcomm devices use dynamic GUID Partition Tables (GPT). Because eMMC and UFS memory chips can vary in capacity (e.g., 64GB, 128GB, 256GB variants for the same smartphone model), the backup GPT header must reside at the very end of the physical disk.
The patch0.xml file tells the Firehose programmer how to calculate dynamic disk boundaries at runtime:
<patch
SECTOR_SIZE_IN_BYTES="512"
filename="DISK"
action="patch"
what="Update Last LBA in GPT Header"
start_sector="NUM_DISK_SECTORS-33" />
Without running patch0.xml, the phone will suffer a corrupted GPT table, resulting in a hard-brick (9008 loop) upon reboot.
Technical Comparison: Scatter vs. Rawprogram/Patch0
| Feature / Parameter | MediaTek Scatter (.txt) | Qualcomm Rawprogram / Patch0 (.xml) |
|---|---|---|
| Target Flashing Protocol | MediaTek BROM / DA Protocol | Qualcomm Sahara & Firehose Protocol |
| Addressing Unit | Byte addresses in Hexadecimal (e.g., 0x14800000) |
512-byte Sector Units in Decimal (e.g., start_sector="655360") |
| Dynamic Disk Patching | Handled via internal DA dynamic calculation | Explicitly executed via patch0.xml instructions |
| Multi-LUN / Region Support | Defined via region: EMMC_USER / EMMC_BOOT1 |
Defined via physical_partition_number="0, 1, 2..." |
Technician Guidelines for Modifying Partition Maps
Important Notice: Never manually alterlinear_start_addrin scatter files orstart_sectorin rawprogram XMLs unless you are restructuring custom memory maps on verified developer boards. An address error as small as a single byte offset will overwrite adjacent security partitions (such as NVRAM, EFS, or RPMB), permanently destroying cellular network connectivity.