Amlogic proprietary eMMC partition table: GraphViz block diagram (.dot) source

This is an unnamed and undocumented partition table format implemented by the bootloader and kernel that Amlogic provides for their Linux SoCs (Meson series at least, and probably others). They appear to use this rather than GPT, the industry standard, because their BootROM loads and executes the next stage loader from offset 512 (0x200) on the eMMC, which is exactly where the GPT header would have to start. So instead of changing their BootROM, Amlogic devised this partition table, which lives at an offset of 36MiB (0x240_0000) on the eMMC and so doesn't conflict. This parser expects as input just the partition table from that offset. The maximum number of partitions in a table is 32, which corresponds to a maximum table size of 1304 bytes (0x518).

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.9

This page hosts a formal specification of Amlogic proprietary eMMC partition table using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

amlogic_emmc_partitions.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__amlogic_emmc_partitions {
		label="AmlogicEmmcPartitions";
		graph[style=dotted];

		amlogic_emmc_partitions__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="magic_pos">0</TD><TD PORT="magic_size">4</TD><TD></TD><TD PORT="magic_type">magic</TD></TR>
			<TR><TD PORT="version_pos">4</TD><TD PORT="version_size">12</TD><TD>str(UTF-8)</TD><TD PORT="version_type">version</TD></TR>
			<TR><TD PORT="num_partitions_pos">16</TD><TD PORT="num_partitions_size">4</TD><TD>s4le</TD><TD PORT="num_partitions_type">num_partitions</TD></TR>
			<TR><TD PORT="checksum_pos">20</TD><TD PORT="checksum_size">4</TD><TD>u4le</TD><TD PORT="checksum_type">checksum</TD></TR>
			<TR><TD PORT="partitions_pos">24</TD><TD PORT="partitions_size">40</TD><TD>Partition</TD><TD PORT="partitions_type">partitions</TD></TR>
			<TR><TD COLSPAN="4" PORT="partitions__repeat">repeat num_partitions times</TD></TR>
		</TABLE>>];
		subgraph cluster__partition {
			label="AmlogicEmmcPartitions::Partition";
			graph[style=dotted];

			partition__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="name_pos">0</TD><TD PORT="name_size">16</TD><TD>str(UTF-8)</TD><TD PORT="name_type">name</TD></TR>
				<TR><TD PORT="size_pos">16</TD><TD PORT="size_size">8</TD><TD>u8le</TD><TD PORT="size_type">size</TD></TR>
				<TR><TD PORT="offset_pos">24</TD><TD PORT="offset_size">8</TD><TD>u8le</TD><TD PORT="offset_type">offset</TD></TR>
				<TR><TD PORT="flags_pos">32</TD><TD PORT="flags_size">4</TD><TD>PartFlags</TD><TD PORT="flags_type">flags</TD></TR>
				<TR><TD PORT="padding_pos">36</TD><TD PORT="padding_size">4</TD><TD></TD><TD PORT="padding_type">padding</TD></TR>
			</TABLE>>];
			subgraph cluster__part_flags {
				label="AmlogicEmmcPartitions::Partition::PartFlags";
				graph[style=dotted];

				part_flags__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
					<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
					<TR><TD PORT="is_code_pos">0</TD><TD PORT="is_code_size">1b</TD><TD>BitsType1(LittleBitEndian)</TD><TD PORT="is_code_type">is_code</TD></TR>
					<TR><TD PORT="is_cache_pos">0:1</TD><TD PORT="is_cache_size">1b</TD><TD>BitsType1(LittleBitEndian)</TD><TD PORT="is_cache_type">is_cache</TD></TR>
					<TR><TD PORT="is_data_pos">0:2</TD><TD PORT="is_data_size">1b</TD><TD>BitsType1(LittleBitEndian)</TD><TD PORT="is_data_type">is_data</TD></TR>
				</TABLE>>];
			}
		}
	}
	amlogic_emmc_partitions__seq:partitions_type -> partition__seq [style=bold];
	amlogic_emmc_partitions__seq:num_partitions_type -> amlogic_emmc_partitions__seq:partitions__repeat [color="#404040"];
	partition__seq:flags_type -> part_flags__seq [style=bold];
}