Skip to content

Commit cce9bd3

Browse files
author
Patrice Chotard
committed
stm32mp2: Update fwu_mdata node accordingly to boot device
Update dynamically fwu_mdata node properties accordingly to boot device. Depending of boot device, fwu_mdata node's properties must be updated to allow to EFI framework to get access to metadata. This fixes the following EFI error message "FWU metadata read failed". By default, the fwu-mdata node in stm32mp1***-u-boot.dtsi indicates that metadata are located on sdmmc1. This is used by default, in this case boot device is sdcard : fwu-mdata { compatible = "u-boot,fwu-mdata-gpt"; fwu-mdata-store = <&sdmmc1>; }; For emmc boot, the compatible and fwu-mdata-store properties must be updated as following : fwu-mdata { compatible = "u-boot,fwu-mdata-gpt"; fwu-mdata-store = <&sdmmc2>; }; For nor boot, the fwu-mdata-store and compatible properties must be updated as following: fwu-mdata { compatible = "u-boot,fwu-mdata-mtd"; fwu-mdata-store = <&flash0>; }; For nand boot, the fwu-mdata-store and compatible properties must be updated as following: fwu-mdata { compatible = "u-boot,fwu-mdata-mtd"; fwu-mdata-store = <&nand0>; }; Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Change-Id: I8232e1037aac9908caeef5906e78a6ac00c221a8 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/382102 ACI: CIBUILD <MDG-smet-aci-builds@list.st.com>
1 parent 0506113 commit cce9bd3

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

board/st/stm32mp2/stm32mp2.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,3 +791,86 @@ void *env_sf_get_env_addr(void)
791791
{
792792
return NULL;
793793
}
794+
795+
#if defined(CONFIG_OF_BOARD_FIXUP)
796+
797+
int fdt_update_fwu_properties(void *blob, int nodeoff,
798+
const char *compat_str,
799+
const char *storage_path)
800+
{
801+
int ret;
802+
int storage_off;
803+
804+
ret = fdt_increase_size(blob, 100);
805+
if (ret) {
806+
printf("fdt_increase_size: err=%s\n", fdt_strerror(ret));
807+
return ret;
808+
}
809+
810+
ret = fdt_setprop_string(blob, nodeoff, "compatible", compat_str);
811+
if (ret) {
812+
log_err("Can't set compatible property\n");
813+
return ret;
814+
}
815+
816+
storage_off = fdt_path_offset(blob, storage_path);
817+
if (storage_off < 0) {
818+
log_err("Can't find %s path\n", storage_path);
819+
return nodeoff;
820+
}
821+
822+
ret = fdt_setprop_string(blob, nodeoff, "fwu-mdata-store", storage_path);
823+
824+
if (ret < 0)
825+
log_err("Can't set fwu-mdata-store property\n");
826+
827+
return ret;
828+
}
829+
830+
int fdt_update_fwu_mdata(void *blob)
831+
{
832+
int nodeoff, ret = 0;
833+
u32 bootmode;
834+
835+
nodeoff = fdt_path_offset(blob, "/fwu-mdata");
836+
if (nodeoff < 0) {
837+
log_info("no /fwu-mdata node ?\n");
838+
839+
return 0;
840+
}
841+
842+
bootmode = get_bootmode() & TAMP_BOOT_DEVICE_MASK;
843+
844+
switch (bootmode) {
845+
case BOOT_FLASH_SD:
846+
/* sdmmc1 : nothing to do, already the default device tree configuration */
847+
break;
848+
case BOOT_FLASH_EMMC:
849+
/* sdmmc2 */
850+
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-mtd",
851+
"/soc@0/rifsc@42080000/mmc@48230000");
852+
break;
853+
854+
case BOOT_FLASH_SPINAND:
855+
case BOOT_FLASH_NOR:
856+
/* flash0 */
857+
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-gpt",
858+
"/soc@0/ommanager@40500000/spi@40430000/flash@0");
859+
break;
860+
}
861+
862+
return ret;
863+
}
864+
865+
int board_fix_fdt(void *blob)
866+
{
867+
int ret = 0;
868+
869+
if (CONFIG_IS_ENABLED(FWU_MDATA) &&
870+
(board_is_stm32mp257_eval() || board_is_stm32mp257_disco()))
871+
ret = fdt_update_fwu_mdata(blob);
872+
873+
return ret;
874+
}
875+
#endif /* CONFIG_OF_BOARD_FIXUP */
876+

0 commit comments

Comments
 (0)