Skip to content

Commit 0506113

Browse files
author
Patrice Chotard
committed
stm32mp1: 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: I35d01c8601f2489ccd4ace3fc42271b56f6cb682 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/382101 ACI: CIBUILD <MDG-smet-aci-builds@list.st.com>
1 parent e678412 commit 0506113

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

board/st/stm32mp1/stm32mp1.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,92 @@ int ft_board_setup(void *blob, struct bd_info *bd)
12171217
}
12181218
#endif
12191219

1220+
#if defined(CONFIG_OF_BOARD_FIXUP)
1221+
1222+
int fdt_update_fwu_properties(void *blob, int nodeoff,
1223+
const char *compat_str,
1224+
const char *storage_path)
1225+
{
1226+
int ret;
1227+
int storage_off;
1228+
1229+
ret = fdt_increase_size(blob, 100);
1230+
if (ret) {
1231+
printf("fdt_increase_size: err=%s\n", fdt_strerror(ret));
1232+
return ret;
1233+
}
1234+
1235+
ret = fdt_setprop_string(blob, nodeoff, "compatible", compat_str);
1236+
if (ret) {
1237+
log_err("Can't set compatible property\n");
1238+
return ret;
1239+
}
1240+
1241+
storage_off = fdt_path_offset(blob, storage_path);
1242+
if (storage_off < 0) {
1243+
log_err("Can't find %s path\n", storage_path);
1244+
return nodeoff;
1245+
}
1246+
1247+
ret = fdt_setprop_string(blob, nodeoff, "fwu-mdata-store", storage_path);
1248+
1249+
if (ret < 0)
1250+
log_err("Can't set fwu-mdata-store property\n");
1251+
1252+
return ret;
1253+
}
1254+
1255+
int fdt_update_fwu_mdata(void *blob)
1256+
{
1257+
int nodeoff, ret = 0;
1258+
u32 bootmode;
1259+
1260+
nodeoff = fdt_path_offset(blob, "/fwu-mdata");
1261+
if (nodeoff < 0) {
1262+
log_info("no /fwu-mdata node ?\n");
1263+
1264+
return 0;
1265+
}
1266+
1267+
bootmode = get_bootmode() & TAMP_BOOT_DEVICE_MASK;
1268+
1269+
switch (bootmode) {
1270+
case BOOT_FLASH_SD:
1271+
/* sdmmc1 : nothing to do, already the default device tree configuration */
1272+
break;
1273+
case BOOT_FLASH_EMMC:
1274+
/* sdmmc2 */
1275+
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-mtd",
1276+
"/soc/mmc@58007000");
1277+
break;
1278+
1279+
case BOOT_FLASH_NAND:
1280+
/* nand@0 */
1281+
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-gpt",
1282+
"/soc/etzpc@5c007000/memory-controller@58002000/nand-controller@4,0/nand@0");
1283+
break;
1284+
1285+
case BOOT_FLASH_SPINAND:
1286+
case BOOT_FLASH_NOR:
1287+
/* flash0 */
1288+
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-gpt",
1289+
"/soc/etzpc@5c007000/spi@58003000/flash@0");
1290+
break;
1291+
}
1292+
1293+
return ret;
1294+
}
1295+
1296+
int board_fix_fdt(void *blob)
1297+
{
1298+
int ret = 0;
1299+
if (CONFIG_IS_ENABLED(FWU_MDATA) && board_is_stm32mp15x_ev1())
1300+
ret = fdt_update_fwu_mdata(blob);
1301+
1302+
return ret;
1303+
}
1304+
#endif /* CONFIG_OF_BOARD_FIXUP */
1305+
12201306
static void board_copro_image_process(ulong fw_image, size_t fw_size)
12211307
{
12221308
int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */

0 commit comments

Comments
 (0)