@@ -11,6 +11,12 @@
config {
u-boot,mmc-env-partition = "u-boot-env";
};
+
+ /* moved to the eMMC, when booting from it, by board_fix_fdt() */
+ fwu-mdata {
+ compatible = "u-boot,fwu-mdata-gpt";
+ fwu-mdata-store = <&sdmmc1>;
+ };
};
/ {
@@ -12,6 +12,7 @@
#include <env.h>
#include <event.h>
#include <extension_board.h>
+#include <fdt_support.h>
#include <log.h>
#include <splash.h>
#include <asm/arch/stm32.h>
@@ -146,6 +147,45 @@ int splash_screen_prepare(void)
}
#endif
+#if CONFIG_IS_ENABLED(OF_BOARD_FIXUP)
+/*
+ * The FWU metadata are stored in the boot device, the SD card or the
+ * eMMC, so point the "fwu-mdata-store" property to it. The phandle is
+ * replaced in place, since the devicetree is already in use.
+ */
+int board_fix_fdt(void *blob)
+{
+ u32 bootmode = get_bootmode();
+ unsigned int instance = (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
+ int node, store;
+ char alias[8];
+ u32 phandle;
+
+ node = fdt_node_offset_by_compatible(blob, -1, "u-boot,fwu-mdata-gpt");
+ if (node < 0)
+ return 0;
+
+ switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
+ case BOOT_FLASH_SD:
+ case BOOT_FLASH_EMMC:
+ break;
+ default:
+ return 0;
+ }
+
+ snprintf(alias, sizeof(alias), "mmc%u", instance);
+ store = fdt_path_offset(blob, alias);
+ if (store < 0)
+ return store;
+
+ phandle = fdt_get_phandle(blob, store);
+ if (!phandle)
+ return -ENOENT;
+
+ return fdt_setprop_inplace_u32(blob, node, "fwu-mdata-store", phandle);
+}
+#endif
+
int board_late_init(void)
{
const char *fdt_compat;
@@ -14,10 +14,13 @@ CONFIG_CMD_STM32KEY=y
CONFIG_MFD_STM32_TIMERS=y
CONFIG_ENV_OFFSET_REDUND=0x940000
CONFIG_TARGET_MICROGEA_STM32MP257=y
+CONFIG_FWU_NUM_IMAGES_PER_BANK=3
+CONFIG_OF_BOARD_FIXUP=y
CONFIG_SYS_MEMTEST_START=0x84000000
CONFIG_SYS_MEMTEST_END=0x88000000
CONFIG_API=y
CONFIG_SYS_MMC_MAX_DEVICE=3
+CONFIG_EFI_CAPSULE_ON_DISK=y
CONFIG_FIT=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
@@ -25,6 +28,7 @@ CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
# CONFIG_BOARD_INIT is not set
CONFIG_SYS_PROMPT="STM32MP> "
# CONFIG_CMD_BDI is not set
+CONFIG_CMD_FWU_METADATA=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_ADTIMG=y
# CONFIG_CMD_ELF is not set
@@ -118,3 +122,5 @@ CONFIG_WDT_STM32MP=y
CONFIG_WDT_ARM_SMC=y
# CONFIG_UBIFS_SILENCE_DEBUG_DUMP is not set
CONFIG_ERRNO_STR=y
+CONFIG_FWU_MULTI_BANK_UPDATE=y
+CONFIG_FWU_MDATA_V2=y
Enable the FWU multi-bank update. The FWU metadata are stored in the boot device, so point the "fwu-mdata-store" property to it at runtime. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- ...m32mp257d-engicam-microgea-rmm-u-boot.dtsi | 6 +++ board/engicam/stm32mp2/stm32mp2.c | 40 +++++++++++++++++++ configs/stm32mp25-microgea-rmm_defconfig | 6 +++ 3 files changed, 52 insertions(+)