ALL-H3-CC (Tritium) Allwinner H2+ H3 H5 Partition Table and Bootloader Basic Considerations
ALL-H3-CC (Tritium) comes in three variants with the Allwinner H2+, H3, and H5 SoCs. Allwinner H2+ and H3 are the same ARMv7 (32-bit) chip with nearly identical features. Allwinner H5 is a different ARMv8 (64-bit) chip. The Tritium platform is a first generation Libre Computer platform and does not have onboard SPI NOR to store u-boot firmware. OS images needs to have a board specific u-boot firmware flashed to the beginning of the image.
The two types of partition tables are MBR and GPT. Partition tables define partition size and offsets along with a few other parameters like UUID. MBR is a very old and very simple partition table format that is widely supported and occupies LBA 0. LBA (Logical Block Address) are 512 bytes so the MBR partition table takes up 512 bytes at the beginning of the disk. There is no redundancy so if the table is damaged, the partition definitions will not be recoverable without a manual scan of the disk for potential partition starts. MBR only supports 4 partitions but you can have "logicial" partitions that rests on one of the partitions defined in the MBR. These logical partitions are not identified in the MBR however. Old computers use LBA 1 through LBA 33 for legacy bootloaders and the first partition would start on LBA 34.
The more mode partition table is GPT. GPT supports up to 128 partitions up from 4 in MBR scheme and includes a variety of other extended attributes for each partition. It also saves a copy of the partition table at the end of the disk range so that the partition definitions can be recovered if the ones at the start of the disk becomes corrupted. The downside of this is that you are also fixing the size of the disk so if you were to do a raw copy of disk data to a drive of a different size, the GPT redundant copy must be re-initialized to account for the new disk size. GPT starts at LBA 1 (512 byte) and can use up to LBA 33 (16896 bytes) to store the details on 128 partitions. Older partitioning tools would start the first partition at LBA 34 to maximize space but modern partitioning tools would start the first partition at LBA 2048 (1MB) or higher because it aligns better with the sector sizes of modern storage devices where as LBA 34 would cause read and writes to span physical device sectors and compromise performance.
GPT also accounts for the necessity of backwards compatibility with MBR tools and OSes that do not understand GPT so it preserves a basic copy of partition information in LBA 0 and continues to use the format of MBR as a "protective" copy for tools that do not know how to read GPT. This reference does not have all of the partition's additional GPT attributes but it appears to be MBR for the sake of not breaking utilities that read this data. This is not a problem as long as those tools do not attempt to modify the partition layout since they will only modify this "protective" MBR rather than the GPT tables and cause other problems.
Tritium's SoCs have a built-in boot ROM that will run on power on. It will search for the actual software bootloader in LBA 16 (8KB) for various interfaces like SPI, MMC (SD card and eMMC), NAND, etc. Since GPT uses LBA 0 through LBA 33, parts of the GPT table will conflict with the location of the bootloader (u-boot). If we use GPT, we must restrict the number of partition information that GPT stores. GPT header occupies LBA 1 and each subsequent LBA holds information on 4 partitions. LBA 2 through LBA 15 is 14 LBA long which means that we must restrict the GPT table to 56 entries. To do this with gdisk, we must enable advanced functionality by pressing "x" and then setting the partition table size by pressing "x" and entering 56. This will make sure that the backup table at the end of the disk is appropriately sized so that there is no conflict between the partition table and the actual partitions themselves.
Please note, the SoC ROM will start reading at 8KB for MMC-based devices like SD cards and eMMC. For SPI NOR and NAND, the ROM will read from the first block.
The two types of partition tables are MBR and GPT. Partition tables define partition size and offsets along with a few other parameters like UUID. MBR is a very old and very simple partition table format that is widely supported and occupies LBA 0. LBA (Logical Block Address) are 512 bytes so the MBR partition table takes up 512 bytes at the beginning of the disk. There is no redundancy so if the table is damaged, the partition definitions will not be recoverable without a manual scan of the disk for potential partition starts. MBR only supports 4 partitions but you can have "logicial" partitions that rests on one of the partitions defined in the MBR. These logical partitions are not identified in the MBR however. Old computers use LBA 1 through LBA 33 for legacy bootloaders and the first partition would start on LBA 34.
The more mode partition table is GPT. GPT supports up to 128 partitions up from 4 in MBR scheme and includes a variety of other extended attributes for each partition. It also saves a copy of the partition table at the end of the disk range so that the partition definitions can be recovered if the ones at the start of the disk becomes corrupted. The downside of this is that you are also fixing the size of the disk so if you were to do a raw copy of disk data to a drive of a different size, the GPT redundant copy must be re-initialized to account for the new disk size. GPT starts at LBA 1 (512 byte) and can use up to LBA 33 (16896 bytes) to store the details on 128 partitions. Older partitioning tools would start the first partition at LBA 34 to maximize space but modern partitioning tools would start the first partition at LBA 2048 (1MB) or higher because it aligns better with the sector sizes of modern storage devices where as LBA 34 would cause read and writes to span physical device sectors and compromise performance.
GPT also accounts for the necessity of backwards compatibility with MBR tools and OSes that do not understand GPT so it preserves a basic copy of partition information in LBA 0 and continues to use the format of MBR as a "protective" copy for tools that do not know how to read GPT. This reference does not have all of the partition's additional GPT attributes but it appears to be MBR for the sake of not breaking utilities that read this data. This is not a problem as long as those tools do not attempt to modify the partition layout since they will only modify this "protective" MBR rather than the GPT tables and cause other problems.
Tritium's SoCs have a built-in boot ROM that will run on power on. It will search for the actual software bootloader in LBA 16 (8KB) for various interfaces like SPI, MMC (SD card and eMMC), NAND, etc. Since GPT uses LBA 0 through LBA 33, parts of the GPT table will conflict with the location of the bootloader (u-boot). If we use GPT, we must restrict the number of partition information that GPT stores. GPT header occupies LBA 1 and each subsequent LBA holds information on 4 partitions. LBA 2 through LBA 15 is 14 LBA long which means that we must restrict the GPT table to 56 entries. To do this with gdisk, we must enable advanced functionality by pressing "x" and then setting the partition table size by pressing "x" and entering 56. This will make sure that the backup table at the end of the disk is appropriately sized so that there is no conflict between the partition table and the actual partitions themselves.
Please note, the SoC ROM will start reading at 8KB for MMC-based devices like SD cards and eMMC. For SPI NOR and NAND, the ROM will read from the first block.