Skip to content

Commit 2231911

Browse files
kmaincentPatrice CHOTARD
authored andcommitted
board: stm32mp2: Fix fwu-mdata node update for NOR boot
The fwu-mdata devicetree node was incorrectly updated for NOR boot. The previous implementation wrote the memory node path as a string to the fwu-mdata-store property, but the FWU metadata driver expects a phandle reference, causing the driver to fail loading the metadata. Fix this by using a proper phandle ID instead of a string path. Also add the mdata-parts property to specify the metadata partition location within the NOR memory, as required by the FWU driver. Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Change-Id: I62dbfebcd94224ebc04014304957697ba0c63663 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/543885 ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com>
1 parent 08422c6 commit 2231911

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

board/st/stm32mp2/stm32mp2.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,36 @@ void *env_sf_get_env_addr(void)
819819
#define HYPERFLASH_PATH "/soc@0/ommanager@40500000/memory-controller@40430000/flash@0"
820820
#endif
821821

822+
static int fdt_update_fwu_mtdpart(void *blob, int nodeoff)
823+
{
824+
int ret;
825+
826+
ret = fdt_increase_size(blob, 100);
827+
if (ret) {
828+
printf("fdt_increase_size: err=%s\n", fdt_strerror(ret));
829+
return ret;
830+
}
831+
832+
ret = fdt_setprop_string(blob, nodeoff, "mdata-parts", "metadata1");
833+
if (ret) {
834+
log_err("Can't set mdata-parts property to metadata1\n");
835+
return ret;
836+
}
837+
838+
ret = fdt_appendprop_string(blob, nodeoff, "mdata-parts", "metadata2");
839+
if (ret)
840+
log_err("Can't append metadata2 to mdata-parts property\n");
841+
842+
return ret;
843+
}
844+
822845
int fdt_update_fwu_properties(void *blob, int nodeoff,
823846
const char *compat_str,
824847
const char *storage_path)
825848
{
826849
int ret;
827850
int storage_off;
851+
u32 phandle;
828852

829853
ret = fdt_increase_size(blob, 100);
830854
if (ret) {
@@ -844,8 +868,16 @@ int fdt_update_fwu_properties(void *blob, int nodeoff,
844868
return nodeoff;
845869
}
846870

847-
ret = fdt_setprop_string(blob, nodeoff, "fwu-mdata-store", storage_path);
871+
phandle = fdt_get_phandle(blob, storage_off);
872+
if (phandle < 0) {
873+
log_err("Can't get phandle: err=%d\n", phandle);
874+
return phandle;
875+
} else if (phandle == 0) {
876+
log_err("Can't get phandle: no phandle\n");
877+
return -ENOENT;
878+
}
848879

880+
ret = fdt_setprop_u32(blob, nodeoff, "fwu-mdata-store", phandle);
849881
if (ret < 0)
850882
log_err("Can't set fwu-mdata-store property\n");
851883

@@ -881,11 +913,19 @@ int fdt_update_fwu_mdata(void *blob)
881913
/* flash0 */
882914
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-mtd",
883915
SPINAND_NOR_PATH);
916+
if (ret)
917+
return ret;
918+
919+
ret = fdt_update_fwu_mtdpart(blob, nodeoff);
884920
break;
885921
case BOOT_FLASH_HYPERFLASH:
886922
/* flash0 */
887923
ret = fdt_update_fwu_properties(blob, nodeoff, "u-boot,fwu-mdata-mtd",
888924
HYPERFLASH_PATH);
925+
if (ret)
926+
return ret;
927+
928+
ret = fdt_update_fwu_mtdpart(blob, nodeoff);
889929
break;
890930
default:
891931
/* TF-A firmware update not supported for other boot device */

0 commit comments

Comments
 (0)