Files
edk2-rk3588/edk2-rockchip/Silicon
Mario Bălănică 437888c733 Improve SD/eMMC var store detection robustness
The hardware boot order on all platforms is: FSPI->EMMC->SD->USB.

U-Boot SPL (our chainloader), however, is told by its DTB to boot in
this order: SD->EMMC->FSPI. It then populates `RkAtagTypeBootDev` with
the device it decided to boot from. We use this information to determine
the drive we belong to, in order to write the variable store there.

While this behavior is useful for testing, it should generally be
avoided because it bypasses the SPL version we intended to ship with
UEFI, which could lead to all sorts of issues.

One such issue is that some SPL builds (namely Orange Pi's) flashed to
SPI will happily boot from SD card while setting the ATAG to EMMC
instead. Obviously, this leads UEFI to use the wrong device (or none at
all if EMMC is missing) for writing variables. Since SPL only reads the
variable store into memory from the actual boot device (SD card),
settings will not persist.

To address this, we'll no longer rely on that ATAG unless it indicates
FSPI boot, in which case it would most likely be correct due to FSPI
having priority in hardware - well, assuming there no further broken
SPLs in the wild that might set it to FSPI while booting from SD :P.

Instead, we'll look through the SD->EMMC devices (same order as SPL) to
find a FIT image matching our own, indicating that's likely the boot
device.

Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
2024-12-19 16:16:23 +02:00
..