On 22 February 2017 at 20:23, Alex Elder elder@linaro.org wrote:
On 02/22/2017 01:06 PM, Ard Biesheuvel wrote:
If we simply put an MBR in sector 0 that does not cover sector 1 at all (or any subsequent sectors that are part of the primary boot image), I don't think we need to bother at all with GPTs or protective MBRs or anything else that is specific to UEFI. Let's just start the first partition at the next eraseblock boundary, and make it around 128 MB in size, so we can use it as the EFI System Partition (ESP).
Is there any reason, other than the read-modify-write cost of writes smaller than the erase block size that you suggest the first partition lies at the next erase block boundary?
The idea is that file system blocks should not cover more than one erase block, because hitting such blocks will double the rate the flash blocks are worn out. Since the FS block size is an a priori unknown, the best way to achieve this is simply to align partitions on erase block boundaries. Note that MBR secondary partitions use the first sector for themselves, so those should start 1 sector /before/ an eraseblock boundary.
The MBR at offset 0 and the boot loader at offset 1 LBA will (most likely) have to be in the same erase block. I do realize that we don't want to be rewriting these blocks with writes to the front of the first partition.
Indeed. Usually, eMMC is optimized for FAT, so the region that is usually covered by the FAT tables is wear-leveled in a different way, and so hitting eraseblock 0 often should not result in any problems. But given risk of bricking the board when the boot image is corrupted, I think it makes sense to reserve it for the boot image and MBR partition table.
I just want to be sure I'm not missing some other constraint.
I don't think so, no