[PATCH] board: xilinx: Fold FWU dfu_alt_info into configure_capsule_updates()
Michal Simek
michal.simek at amd.com
Thu Jul 2 12:10:45 CEST 2026
On 6/30/26 15:02, Michal Simek wrote:
> Commit 371a6c1744f3 ("board: xilinx: Add capsule and FWU support") and
> commit 818c06faa119 ("board: amd: Add capsule and FWU support")
> introduced a separate set_dfu_alt_info() for the FWU multi-bank case
> (Versal and Versal Gen 2 respectively) which set the dfu_alt_info
> environment variable directly, while configure_capsule_updates() handled
> the non-FWU case by filling update_info.dfu_string. Having two functions
> generating the DFU description is redundant now that capsule update sets
> the dfu_alt_info variable on its own from update_info.dfu_string.
>
> Fold the FWU multi-bank generation (fwu_gen_alt_info_from_mtd() over the
> nor0 MTD partitions) into configure_capsule_updates() and drop the
> standalone set_dfu_alt_info(). The function now selects the source of the
> DFU string at run time via IS_ENABLED(): the MTD partitions when FWU
> multi-bank update is enabled, otherwise the boot-mode based layout. Both
> paths end up filling update_info.dfu_string.
>
> Signed-off-by: Michal Simek <michal.simek at amd.com>
> ---
>
> board/amd/versal2/board.c | 63 ++++++++++++++----------------------
> board/xilinx/versal/board.c | 64 ++++++++++++++-----------------------
> 2 files changed, 48 insertions(+), 79 deletions(-)
>
> diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
> index 2afd283b8ddd..6e09e408875d 100644
> --- a/board/amd/versal2/board.c
> +++ b/board/amd/versal2/board.c
> @@ -227,8 +227,7 @@ int board_late_init(void)
> int ret;
> u32 multiboot;
>
> - if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) &&
> - !IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE))
> + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
> configure_capsule_updates();
>
> if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> @@ -362,8 +361,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
>
> #define DFU_ALT_BUF_LEN SZ_1K
>
> -#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && \
> - !defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> static void mtd_found_part(u32 *base, u32 *size)
> {
> struct mtd_info *part, *mtd;
> @@ -399,6 +396,29 @@ void configure_capsule_updates(void)
>
> memset(buf, 0, DFU_ALT_BUF_LEN);
>
> + if (IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE)) {
> + struct mtd_info *mtd;
> + int ret;
> +
> + mtd_probe_devices();
> +
> + mtd = get_mtd_device_nm("nor0");
> + if (IS_ERR_OR_NULL(mtd))
> + return;
> +
> + ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
> + if (ret < 0) {
> + log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
> + return;
> + }
> + log_debug("Make dfu_alt_info: '%s'\n", buf);
> +
> + update_info.dfu_string = strdup(buf);
> + debug("Capsule DFU: %s\n", update_info.dfu_string);
> +
> + return;
> + }
> +
> multiboot = env_get_hex("multiboot", multiboot);
>
> switch (bootmode) {
> @@ -442,41 +462,6 @@ void configure_capsule_updates(void)
> }
> #endif
>
> -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> -
> -/* Generate dfu_alt_info from partitions */
> -void set_dfu_alt_info(char *interface, char *devstr)
> -{
> - int ret;
> - struct mtd_info *mtd;
> -
> - /*
> - * It is called multiple times for every image
> - * per bank that's why enough to set it up once.
> - */
> - if (env_get("dfu_alt_info"))
> - return;
> -
> - ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> - memset(buf, 0, DFU_ALT_BUF_LEN);
> -
> - mtd_probe_devices();
> -
> - mtd = get_mtd_device_nm("nor0");
> - if (IS_ERR_OR_NULL(mtd))
> - return;
> -
> - ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
> - if (ret < 0) {
> - log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
> - return;
> - }
> - log_debug("Make dfu_alt_info: '%s'\n", buf);
> -
> - env_set("dfu_alt_info", buf);
> -}
> -#endif
> -
> int spi_get_env_dev(void)
> {
> struct udevice *dev;
> diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
> index 0537517b1b2e..f06d3c59d055 100644
> --- a/board/xilinx/versal/board.c
> +++ b/board/xilinx/versal/board.c
> @@ -232,8 +232,7 @@ int board_late_init(void)
> {
> int ret;
>
> - if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) &&
> - !IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE))
> + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
> configure_capsule_updates();
>
> if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> @@ -314,8 +313,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
>
> #define DFU_ALT_BUF_LEN SZ_1K
>
> -#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && \
> - !defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> static void mtd_found_part(u32 *base, u32 *size)
> {
> struct mtd_info *part, *mtd;
> @@ -351,6 +348,29 @@ void configure_capsule_updates(void)
>
> memset(buf, 0, DFU_ALT_BUF_LEN);
>
> + if (IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE)) {
> + struct mtd_info *mtd;
> + int ret;
> +
> + mtd_probe_devices();
> +
> + mtd = get_mtd_device_nm("nor0");
> + if (IS_ERR_OR_NULL(mtd))
> + return;
> +
> + ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
> + if (ret < 0) {
> + log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
> + return;
> + }
> + log_debug("Make dfu_alt_info: '%s'\n", buf);
> +
> + update_info.dfu_string = strdup(buf);
> + debug("Capsule DFU: %s\n", update_info.dfu_string);
> +
> + return;
> + }
> +
> multiboot = env_get_hex("multiboot", multiboot);
>
> switch (bootmode) {
> @@ -392,39 +412,3 @@ void configure_capsule_updates(void)
> update_info.dfu_string = strdup(buf);
> debug("Capsule DFU: %s\n", update_info.dfu_string);
> }
> -#endif
> -
> -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> -
> -/* Generate dfu_alt_info from partitions */
> -void set_dfu_alt_info(char *interface, char *devstr)
> -{
> - int ret;
> - struct mtd_info *mtd;
> -
> - /*
> - * It is called multiple times for every image
> - * per bank that's why enough to set it up once.
> - */
> - if (env_get("dfu_alt_info"))
> - return;
> -
> - ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> - memset(buf, 0, DFU_ALT_BUF_LEN);
> -
> - mtd_probe_devices();
> -
> - mtd = get_mtd_device_nm("nor0");
> - if (IS_ERR_OR_NULL(mtd))
> - return;
> -
> - ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
> - if (ret < 0) {
> - log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
> - return;
> - }
> - log_debug("Make dfu_alt_info: '%s'\n", buf);
> -
> - env_set("dfu_alt_info", buf);
> -}
> -#endif
> ---
> base-commit: 8f4ec2a116ee7ff6d19e6baa60833586df985de7
>
v2 is required because fwu needs to be initialized first and if pass dfu_string
can be created.
Thanks,
Michal
More information about the U-Boot
mailing list