meta-iot2050 icon indicating copy to clipboard operation
meta-iot2050 copied to clipboard

install-on-emmc: Improve the robustness

Open BaochengSu opened this issue 2 years ago • 3 comments

Main change point:

  1. When using Win32 Disk Imager to make the boot-able SD card or USB stick that bigger than the eMMC size (16GB), the Backup LBA of the GPT header is set to the end of the device, which is beyond the 16GB range. After copying such image to the eMMC, linux does not treat the GPT partition table as a correct one and some wired problems happen, such as the new p1 could not be informed to kernel.

    The solution is, the Backup LBA must be adjusted to the end of the eMMC after copying the image to the eMMC. gdisk provides an easy way to handle that.

  2. If the eMMC has old partition data, (which is true for the Advanced device with Industrial OS), then better to wipe the eMMC partition table before copying the data to eMMC. This is because according to UEFI spec, there is a GPT backup header and backup partition table at the end of the device. When copying the new image via dd, normally the tail part of the device will not be touched. This is ok when everything goes smoothly, however, if problem happen during the install-on-emmc, the old backup partition data could be recovered during next boot.

    For example in the above problem, when Backup LBA is beyond the eMMC size, the new partition p1 could not be informed to kernel. however, the since there is already the old p1 before install-on-emmc, the script still continue to reboot the device, however, during next booting, the Backup LBA offset error is detected and the old backup partition table is recovered to overwrite the new GPT table.

    It is very hard to notice this issue especially when the old image and the new image have similar partition layout.

    The solution is, before install-on-emmc, wipe the old GPT partitioning data, including the backup LBA. sgdisk also provides an easy way to wipe it, meanwhile sfdisk could not do it easily.

BaochengSu avatar Jul 29 '22 04:07 BaochengSu

If this PR is got approved, the target merge point is after the 1.3.1 release, since the new introduced gdisk tool.

BaochengSu avatar Jul 29 '22 04:07 BaochengSu

For handling GPT, gdisk is doing better than fdisk

BaochengSu avatar Jul 29 '22 04:07 BaochengSu

There more have to tweak on this, there clearer it gets that we rather need an flasher stick instead.

jan-kiszka avatar Aug 02 '22 05:08 jan-kiszka

Let's have a thorough rethinking of this feature first, before that, close this PR.

BaochengSu avatar Jan 11 '23 05:01 BaochengSu