[PATCH 0/4] Enable EFI capsule updates for PHYTEC K3 SoMs

This implements capsule updates for all our K3 SoMs for eMMC, OSPI NOR and uSD cards.
We can use capsule updates to update the bootloader on all our supported flash devices.
Wadim Egorov (4): arm: dts: k3-am625-phycore-som-binman: Provide capsule nodes arm: dts: k3-am642-phycore-som-binman: Provide capsule nodes board: phytec: k3: Add EFI capsule update support configs: phycore_am6*_a53_defconfig: Enable capsule update
arch/arm/dts/k3-am625-phycore-som-binman.dtsi | 39 +++++++++ arch/arm/dts/k3-am642-phycore-som-binman.dtsi | 38 +++++++++ board/phytec/common/k3/board.c | 80 +++++++++++++++++++ configs/phycore_am62x_a53_defconfig | 10 +++ configs/phycore_am64x_a53_defconfig | 8 ++ include/configs/phycore_am62x.h | 4 + include/configs/phycore_am64x.h | 4 + 7 files changed, 183 insertions(+)

Fill in phycore-am62x capsule GUID properties of the base binman capsule nodes.
Signed-off-by: Wadim Egorov w.egorov@phytec.de --- arch/arm/dts/k3-am625-phycore-som-binman.dtsi | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/arch/arm/dts/k3-am625-phycore-som-binman.dtsi b/arch/arm/dts/k3-am625-phycore-som-binman.dtsi index 63f2eed7ccb..31456d23167 100644 --- a/arch/arm/dts/k3-am625-phycore-som-binman.dtsi +++ b/arch/arm/dts/k3-am625-phycore-som-binman.dtsi @@ -137,6 +137,20 @@ }; }; }; + +#include "k3-binman-capsule-r5.dtsi" + +&capsule_tiboot3 { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am625-r5-phycore-som-2gb.dtb PHYCORE_AM62X_TIBOOT3 + */ + image-guid = "C7D64D6D-10B2-54BC-A3BF-06A9DC3653D9"; + }; +}; + #endif /* CONFIG_TARGET_PHYCORE_AM62X_R5 */
#ifdef CONFIG_TARGET_PHYCORE_AM62X_A53 @@ -460,4 +474,29 @@ }; }; }; + +#include "k3-binman-capsule.dtsi" + +&capsule_tispl { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am625-phyboard-lyra-rdk.dtb PHYCORE_AM62X_SPL + */ + image-guid = "09841C3F-F177-5D57-B1F6-754D92879205"; + }; +}; + +&capsule_uboot { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am625-phyboard-lyra-rdk.dtb PHYCORE_AM62X_UBOOT + */ + image-guid = "D11A9016-515E-503A-8872-3FF65384D0C4"; + }; +}; + #endif /* CONFIG_TARGET_PHYCORE_AM62X_A53 */

Fill in phycore-am64x capsule GUID properties of the base binman capsule nodes.
Signed-off-by: Wadim Egorov w.egorov@phytec.de --- arch/arm/dts/k3-am642-phycore-som-binman.dtsi | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/arch/arm/dts/k3-am642-phycore-som-binman.dtsi b/arch/arm/dts/k3-am642-phycore-som-binman.dtsi index 88d6c40e95c..ffc4a02a03f 100644 --- a/arch/arm/dts/k3-am642-phycore-som-binman.dtsi +++ b/arch/arm/dts/k3-am642-phycore-som-binman.dtsi @@ -118,6 +118,19 @@ }; };
+#include "k3-binman-capsule-r5.dtsi" + +&capsule_tiboot3 { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am642-r5-phycore-som-2gb.dtb PHYCORE_AM64X_TIBOOT3 + */ + image-guid = "B0A6B4FA-5DF0-5CD1-90EC-B60BDE798486"; + }; +}; + #endif
#ifdef CONFIG_TARGET_PHYCORE_AM64X_A53 @@ -502,4 +515,29 @@ }; }; }; + +#include "k3-binman-capsule.dtsi" + +&capsule_tispl { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am642-phyboard-electra-rdk.dtb PHYCORE_AM64X_SPL + */ + image-guid = "D0F34382-C2C4-509C-A1D4-BC1CB1B992A8"; + }; +}; + +&capsule_uboot { + efi-capsule { + /* + * The GUID is generated dynamically by taking a namespace UUID and hashing + * it with the board compatible and fw_image name: + * mkeficapsule guidgen k3-am642-phyboard-electra-rdk.dtb PHYCORE_AM64X_UBOOT + */ + image-guid = "0BB40539-DB41-5407-B4D4-EAD057FE10F4"; + }; +}; + #endif /* CONFIG_TARGET_PHYCORE_AM64X_A53 */

Implement EFI capsule update functionality for PHYTEC K3-based SoMs. These SoMs feature various flash device options, including eMMC, OSPI NOR, and uSD card at the board level.
This update provides the necessary logic to enable EFI capsule updates across all three flash devices, ensuring flexible and robust firmware upgrade capabilities.
The GUID is dynamically generated for the board, to get it:
efidebug capsule esrt ======================================== ESRT: fw_resource_count=3 ESRT: fw_resource_count_max=3 ESRT: fw_resource_version=1 [entry 0]============================== ESRT: fw_class=C7D64D6D-10B2-54BC-A3BF-06A9DC3653D9 ESRT: fw_type=unknown ESRT: fw_version=0 ESRT: lowest_supported_fw_version=0 ESRT: capsule_flags=0 ESRT: last_attempt_version=0 ESRT: last_attempt_status=success [entry 1]============================== ESRT: fw_class=09841C3F-F177-5D57-B1F6-754D92879205 ESRT: fw_type=unknown ESRT: fw_version=0 ESRT: lowest_supported_fw_version=0 ESRT: capsule_flags=0 ESRT: last_attempt_version=0 ESRT: last_attempt_status=success [entry 2]============================== ESRT: fw_class=D11A9016-515E-503A-8872-3FF65384D0C4 ESRT: fw_type=unknown ESRT: fw_version=0 ESRT: lowest_supported_fw_version=0 ESRT: capsule_flags=0 ESRT: last_attempt_version=0 ESRT: last_attempt_status=success ========================================
On the board (from uSD card containing capsule binaries at boot):
load mmc 1:1 $loadaddr tiboot3-capsule.bin efidebug capsule update $loadaddr
load mmc 1:1 $loadaddr tispl-capsule.bin efidebug capsule update $loadaddr
load mmc 1:1 $loadaddr uboot-capsule.bin efidebug capsule update $loadaddr
The binaries will be flashed to the flash device you are booted from.
Signed-off-by: Wadim Egorov w.egorov@phytec.de --- board/phytec/common/k3/board.c | 80 +++++++++++++++++++++++++++++++++ include/configs/phycore_am62x.h | 4 ++ include/configs/phycore_am64x.h | 4 ++ 3 files changed, 88 insertions(+)
diff --git a/board/phytec/common/k3/board.c b/board/phytec/common/k3/board.c index 346b2b6491a..065e446e154 100644 --- a/board/phytec/common/k3/board.c +++ b/board/phytec/common/k3/board.c @@ -4,15 +4,92 @@ * Author: Wadim Egorov w.egorov@phytec.de */
+#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <dm/ofnode.h> +#include <mtd.h> #include <spl.h> #include <malloc.h> #include <asm/arch/hardware.h>
#include "../am6_som_detection.h"
+#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_image fw_images[] = { + { + .fw_name = PHYCORE_AM6XX_FW_NAME_TIBOOT3, + .image_index = 1, + }, + { + .fw_name = PHYCORE_AM6XX_FW_NAME_SPL, + .image_index = 2, + }, + { + .fw_name = PHYCORE_AM6XX_FW_NAME_UBOOT, + .image_index = 3, + } +}; + +struct efi_capsule_update_info update_info = { + .dfu_string = NULL, + .num_images = ARRAY_SIZE(fw_images), + .images = fw_images, +}; + +/** + * configure_capsule_updates() - Set up the DFU string for capsule updates + * + * Configures all three bootloader binaries for updates on the current + * booted flash device, which may be eMMC, OSPI NOR, or a uSD card. If + * booting from USB or Serial, capsule updates will be performed on the + * eMMC device. + * + * Note: Currently, eMMC hardware partitions are not differentiated; Updates + * are always applied to the first boot partition. + */ +void configure_capsule_updates(void) +{ + static char dfu_string[128] = { 0 }; + const char *dfu_raw = "tiboot3.bin raw 0x0 0x400 mmcpart 1;" + "tispl.bin raw 0x400 0x1000 mmcpart 1;" + "u-boot.img.raw raw 0x1400 0x2000 mmcpart 1"; + const char *dfu_fat = "tiboot3.bin fat 1 1;" + "tispl.bin fat 1 1;" + "u-boot.img fat 1 1"; + const char *dfu_spi = "tiboot3.bin part 1;" + "tispl.bin part 2;" + "u-boot.img part 3"; + u32 boot_device = get_boot_device(); + + switch (boot_device) { + case BOOT_DEVICE_MMC1: + snprintf(dfu_string, 128, "mmc 0=%s", dfu_raw); + break; + case BOOT_DEVICE_MMC2: + snprintf(dfu_string, 128, "mmc 1=%s", dfu_fat); + break; + case BOOT_DEVICE_SPI: + mtd_probe_devices(); + snprintf(dfu_string, 128, "mtd nor0=%s", dfu_spi); + break; + default: + snprintf(dfu_string, 128, "mmc 0=%s", dfu_raw); + break; + }; + + update_info.dfu_string = dfu_string; +} +#endif + +#if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO) +void set_dfu_alt_info(char *interface, char *devstr) +{ + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) + env_set("dfu_alt_info", update_info.dfu_string); +} +#endif + #if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) || IS_ENABLED(CONFIG_ENV_IS_IN_MMC) int mmc_get_env_dev(void) { @@ -94,6 +171,9 @@ int board_late_init(void) } }
+ if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) + configure_capsule_updates(); + return 0; } #endif diff --git a/include/configs/phycore_am62x.h b/include/configs/phycore_am62x.h index 10b78b6f537..2bc6e7e16f9 100644 --- a/include/configs/phycore_am62x.h +++ b/include/configs/phycore_am62x.h @@ -12,4 +12,8 @@ /* DDR Configuration */ #define CFG_SYS_SDRAM_BASE 0x80000000
+#define PHYCORE_AM6XX_FW_NAME_TIBOOT3 u"PHYCORE_AM62X_TIBOOT3" +#define PHYCORE_AM6XX_FW_NAME_SPL u"PHYCORE_AM62X_SPL" +#define PHYCORE_AM6XX_FW_NAME_UBOOT u"PHYCORE_AM62X_UBOOT" + #endif /* __PHYCORE_AM62X_H */ diff --git a/include/configs/phycore_am64x.h b/include/configs/phycore_am64x.h index 9377db30a91..dd3dfa94270 100644 --- a/include/configs/phycore_am64x.h +++ b/include/configs/phycore_am64x.h @@ -12,4 +12,8 @@ /* DDR Configuration */ #define CFG_SYS_SDRAM_BASE 0x80000000
+#define PHYCORE_AM6XX_FW_NAME_TIBOOT3 u"PHYCORE_AM64X_TIBOOT3" +#define PHYCORE_AM6XX_FW_NAME_SPL u"PHYCORE_AM64X_SPL" +#define PHYCORE_AM6XX_FW_NAME_UBOOT u"PHYCORE_AM64X_UBOOT" + #endif /* __PHYCORE_AM64X_H */

Enable raw & on disk capsule updates and provide configs required for updating MTD devices. Also resync after savedefconfig.
Signed-off-by: Wadim Egorov w.egorov@phytec.de --- configs/phycore_am62x_a53_defconfig | 10 ++++++++++ configs/phycore_am64x_a53_defconfig | 8 ++++++++ 2 files changed, 18 insertions(+)
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig index 43b0dac5efd..551fd4415c6 100644 --- a/configs/phycore_am62x_a53_defconfig +++ b/configs/phycore_am62x_a53_defconfig @@ -36,6 +36,9 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y # CONFIG_PSCI_RESET is not set # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_EFI_SET_TIME=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000 CONFIG_BOOTSTD_FULL=y @@ -61,12 +64,16 @@ CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x280000 CONFIG_SPL_YMODEM_SUPPORT=y +# CONFIG_CMD_BOOTEFI_HELLO is not set +CONFIG_CMD_BOOTEFI_SELFTEST=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_DFU=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_CACHE=y +CONFIG_CMD_EFIDEBUG=y CONFIG_CMD_RTC=y CONFIG_CMD_SMC=y CONFIG_OF_CONTROL=y @@ -91,6 +98,7 @@ CONFIG_CLK=y CONFIG_SPL_CLK=y CONFIG_CLK_TI_SCI=y CONFIG_DFU_MMC=y +CONFIG_DFU_MTD=y CONFIG_DFU_RAM=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x40000 CONFIG_SYS_DFU_MAX_FILE_SIZE=0x800000 @@ -107,6 +115,7 @@ CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y CONFIG_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SFDP_SUPPORT=y # CONFIG_SPI_FLASH_SMART_HWCAPS is not set @@ -157,3 +166,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6165 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_SPL_DFU=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +# CONFIG_HEXDUMP is not set diff --git a/configs/phycore_am64x_a53_defconfig b/configs/phycore_am64x_a53_defconfig index ac9731d9674..bc450004722 100644 --- a/configs/phycore_am64x_a53_defconfig +++ b/configs/phycore_am64x_a53_defconfig @@ -35,6 +35,8 @@ CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000 CONFIG_BOOTSTD_FULL=y @@ -65,7 +67,10 @@ CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x280000 CONFIG_SPL_YMODEM_SUPPORT=y +# CONFIG_CMD_BOOTEFI_HELLO is not set +CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CMD_ASKENV=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -73,6 +78,7 @@ CONFIG_CMD_MMC=y CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_CACHE=y +CONFIG_CMD_EFIDEBUG=y CONFIG_CMD_RTC=y CONFIG_CMD_TIME=y CONFIG_CMD_SMC=y @@ -98,6 +104,7 @@ CONFIG_SPL_CLK_CCF=y CONFIG_CLK_CCF=y CONFIG_CLK_TI_SCI=y CONFIG_DFU_MMC=y +CONFIG_DFU_MTD=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x40000 @@ -121,6 +128,7 @@ CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y CONFIG_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SFDP_SUPPORT=y # CONFIG_SPI_FLASH_SMART_HWCAPS is not set

On Wed, 27 Nov 2024 13:17:32 +0100, Wadim Egorov wrote:
This implements capsule updates for all our K3 SoMs for eMMC, OSPI NOR and uSD cards.
We can use capsule updates to update the bootloader on all our supported flash devices.
Wadim Egorov (4): arm: dts: k3-am625-phycore-som-binman: Provide capsule nodes arm: dts: k3-am642-phycore-som-binman: Provide capsule nodes board: phytec: k3: Add EFI capsule update support configs: phycore_am6*_a53_defconfig: Enable capsule update
[...]
Applied to u-boot/next, thanks!
participants (2)
-
Tom Rini
-
Wadim Egorov