Typical SD Card Layout for ARM Systems
Most modern ARM boards and systems support at least one SD, Micro SD, or eMMC device. This article outlines some of the common ways partitions are laid out due to the requirements of various boot loaders. Within this arcticle, when the term SD is used it refers to SD cards, Micro-SD cards, and eMMC devices.
Booting an ARM system
Many systems use SD as the primary boot device; the SoC itself has ROM code that can load U-Boot directly from the SD. Occasionally the primary boot device is SPI or NAND flash which contains just U-Boot and other files required for very early boot, and the main OS and its filesystems are on the SD card.
When the SoC has builtin support for booting directly from SD, sometimes that support knows nothing of filesystems, and it just loads whatever is at some fixed sector number on the SD. Other SoCs have support for FAT16 or FAT32 filesystems and load a file with a fixed name from that filesystem, which typically needs to be the first partition in an MBR partition map in sector 0.
In addition to the SoC's requirements, U-Boot itself understands FAT filesystems, but not FreeBSD filesystems, so often the U-Boot environment and other data is stored on a FAT partition.
More or less Standard Layout
Note: FreeBSD uses the term slices for the concept that the rest of the world calls partitions. In FreeBSD, a partition is a FreeBSD-specific subdivision within a slice. That terminology is used from this point on.
The requirements of bootloaders living in unpartitioned space at a fixed address and U-Boot's love of FAT leads to a pretty typical layout on the SD:
- MBR partition map in sector zero. It contains no boot code, just the info describing up to 4 slices.
- Potentially some unallocated space between the MBR and the FAT slice for U-Boot and other boot data.
- The first slice has a type of FAT16 or FAT32, and a formatted FAT filesystem in it.
The second slice has a type of 165 and contains the FreeBSD partitions. Typically there is at least an a partition for the root filesystem, and a b partition for swap space.
- The third and fourth slices typically aren't used.
Occasionally the SoC builtin FAT support requires the more or less standard MSDOS layout that starts the FAT partition in sector 63, as if it doesn't even check the MBR.
Sometimes I've seen a FAT12 or FAT16 filesystem in a slice marked as FAT32 type in the MBR, and that doesn't seem to hurt anything, U-Boot copes with it just fine.