The Sunxi family of SoCs from Allwinner, have a very specific boot process. When an SD card is available, the boot ROM expects to find the SPL (Secondary Program Loader) at exactly block 16 (8KB) of the SD card. This creates a problem when using the (GPT) GUID Partition Table 1 scheme because the entire partition table takes up 16KB.
When using the GPT scheme, the boot ROM will instead read part of the partition table instead of the SPL. This is still an issue even if there are only a few partitions, the entire space needs to be reserved for the table.
Fortunately, it’s possible to adjust the partition table so there is a gap between the headers and entries. This is because in the GPT Header there is a field that references the start of the GPT entries. Typically it is Block 2, but it can be adjusted to be any block on the disk.
Tools like sgdisk can set this value. In
sgdisk’s case it’s done with the
-j command. This means the following set of commands, will create a new partition table and relocate the start of the entries to sector 4064. This provides ample room to place the SPL and a boot loader.
After the above commands the GPT looks like this.
Once this is done,
sgdisk can be used to add partitions and it will preserve the empty space in the table. The SPL can be written to the gap without issue so long as there is enough space. Usiing this method it’s possible to have a GPT formatted disk contain the SPL and the data, which is useful for devices that only have an SD card to boot from.
Usually when you want to use EFI boot or follow the Discoverable Partitions Specification↩︎