#37 The 1 MiB gap between MBR and the first partition is not enough to store the MLO & uboot images
Closed: fixed by pbrobinson. Opened by javierm.

Writing a Fedora IoT image for the am335x_evm target corrupts the first partition used for the ESP.

This happens because there is only 1 MiB (512 * 2048) as a gap between the partition table and the start of first partition:

$ fdisk -l Fedora-IoT-33-20201102.0.armhfp.raw 
Disk Fedora-IoT-33-20201102.0.armhfp.raw: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xeb748c05
Device                               Boot   Start     End Sectors  Size Id Type
Fedora-IoT-33-20201102.0.armhfp.raw1 *       2048 1028095 1026048  501M  6 FAT16
Fedora-IoT-33-20201102.0.armhfp.raw2      1028096 3125247 2097152    1G 83 Linux
Fedora-IoT-33-20201102.0.armhfp.raw3      3125248 8386559 5261312  2.5G 83 Linux

but the script to write the uboot images for this target is the following:

$ cat /usr/share/arm-image-installer/boards.d/am335x_evm 
# write MLO & U-Boot
echo "= Writing MLO for $TARGET...."
dd if=$PREFIX/usr/share/uboot/$TARGET/MLO of=$MEDIA count=1 seek=1 conv=notrunc bs=128k; sync
echo "= Writing u-boot.img for $TARGET...."
dd if=$PREFIX/usr/share/uboot/$TARGET/u-boot.img of=$MEDIA count=2 seek=1 conv=notrunc bs=384k; sync
# set console
SYSCON=ttyS0,115200

So the MLO will be written between sectors 256 and 512 while the u-boot.img between
2304. The latter corrupts the filesystem in the first partition since it starts at sector 2048 in the Fedora IoT images.

This issue is not present for armhfp (non-IoT) images because in that case the gap size is 4 MiB (512 * 8192) so the uboot images fit there:

$ sudo fdisk -l Fedora-Minimal-armhfp-33-1.2-sda.raw
Disk Fedora-Minimal-armhfp-33-1.2-sda.raw: 2.04 GiB, 2193620992 bytes, 4284416 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x92ac8b97
Device                                Boot   Start     End Sectors  Size Id Type
Fedora-Minimal-armhfp-33-1.2-sda.raw1         8192  163839  155648   76M  c W95 FAT32 (LBA)
Fedora-Minimal-armhfp-33-1.2-sda.raw2 *     163840 1163263  999424  488M 83 Linux
Fedora-Minimal-armhfp-33-1.2-sda.raw3      1163264 4093951 2930688  1.4G 83 Linux

Fixed when we moved to osbuild images

Metadata Update from @pbrobinson:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata