[PATCH v7 06/13] FWU: stm32mp1: Add helper functions for accessing FWU metadata
Ilias Apalodimas
ilias.apalodimas at linaro.org
Fri Jul 15 09:52:15 CEST 2022
Hi Sughosh,
On Thu, 14 Jul 2022 at 21:40, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
>
> Add helper functions needed for accessing the FWU metadata which
> contains information on the updatable images. These functions have
> been added for the STM32MP157C-DK2 board which has the updatable
> images on the uSD card, formatted as GPT partitions.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> Reviewed-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
> ---
> Changes since V6: None
>
> board/st/stm32mp1/stm32mp1.c | 40 ++++++++++++++++
> include/fwu.h | 3 ++
> lib/fwu_updates/Makefile | 6 +++
> lib/fwu_updates/fwu_gpt.c | 88 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 137 insertions(+)
> create mode 100644 lib/fwu_updates/Makefile
> create mode 100644 lib/fwu_updates/fwu_gpt.c
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index e3a04f8d8a..44c7943f1d 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -7,9 +7,11 @@
>
> #include <common.h>
> #include <adc.h>
> +#include <blk.h>
> #include <bootm.h>
> #include <clk.h>
> #include <config.h>
> +#include <dfu.h>
> #include <dm.h>
> #include <efi_loader.h>
> #include <env.h>
> @@ -25,9 +27,11 @@
> #include <log.h>
> #include <malloc.h>
> #include <misc.h>
> +#include <mmc.h>
> #include <mtd_node.h>
> #include <net.h>
> #include <netdev.h>
> +#include <part.h>
> #include <phy.h>
> #include <remoteproc.h>
> #include <reset.h>
> @@ -962,3 +966,39 @@ static void board_copro_image_process(ulong fw_image, size_t fw_size)
> }
>
> U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);
> +
> +#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> +
> +#include <fwu.h>
> +#include <fwu_mdata.h>
> +
> +int fwu_plat_get_alt_num(struct udevice *dev, efi_guid_t *image_guid,
> + int *alt_num)
> +{
> + struct blk_desc *desc;
> + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev);
> +
> + desc = dev_get_uclass_plat(priv->blk_dev);
> + if (!desc) {
> + log_err("Block device not found\n");
> + return -ENODEV;
> + }
> +
> + return fwu_gpt_get_alt_num(desc, image_guid, alt_num, DFU_DEV_MMC);
> +}
> +
> +int fwu_plat_get_update_index(u32 *update_idx)
> +{
> + int ret;
> + u32 active_idx;
> +
> + ret = fwu_get_active_index(&active_idx);
> +
> + if (ret < 0)
> + return -1;
> +
> + *update_idx = active_idx ^= 0x1;
> +
> + return ret;
> +}
I'dl ike to move those 2 out to the generic API as well. Sure a
device might be paranoid and have more than 2 banks for firmware
redundancy, however I believe 2 will be the main case. So we can use
these 2 as generic weak functions and special devices can override
that
Regards
/Ilias
> +#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */
> diff --git a/include/fwu.h b/include/fwu.h
> index 8259c75d12..38dceca9c5 100644
> --- a/include/fwu.h
> +++ b/include/fwu.h
[...]
More information about the U-Boot
mailing list