All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sughosh Ganu <sughosh.ganu@linaro.org>
To: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
Cc: u-boot@lists.denx.de,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	 Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Alexander Graf <agraf@csgraf.de>, Simon Glass <sjg@chromium.org>,
	 Bin Meng <bmeng.cn@gmail.com>, Peng Fan <peng.fan@nxp.com>,
	 AKASHI Takahiro <takahiro.akashi@linaro.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	 Jose Marinho <jose.marinho@arm.com>,
	Grant Likely <grant.likely@arm.com>,
	 Jason Liu <jason.hui.liu@nxp.com>
Subject: Re: [RFC PATCH 05/10] FWU: stm32mp1: Add helper functions for accessing metadata
Date: Wed, 8 Dec 2021 15:48:47 +0530	[thread overview]
Message-ID: <CADg8p957TvtUn3Zq32oNWLdvShE-RXQde07YX=x2iTyx3jwCYQ@mail.gmail.com> (raw)
In-Reply-To: <a886542f-58f3-a692-4b07-b7ed19c1883f@foss.st.com>

hi Patrick,

On Tue, 7 Dec 2021 at 20:03, Patrick DELAUNAY <patrick.delaunay@foss.st.com>
wrote:

> Hi Sanghosh
>
> On 11/25/21 8:01 AM, Sughosh Ganu wrote:
> > Add helper functions needed for accessing the 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@linaro.org>
> > ---
> >   board/st/stm32mp1/stm32mp1.c | 63 ++++++++++++++++++++++++++++++++++++
> >   include/fwu_metadata.h       |  3 ++
> >   2 files changed, 66 insertions(+)
> >
> > diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> > index 84592677e4..a6884d2772 100644
> > --- a/board/st/stm32mp1/stm32mp1.c
> > +++ b/board/st/stm32mp1/stm32mp1.c
> > @@ -7,6 +7,7 @@
> >
> >   #include <common.h>
> >   #include <adc.h>
> > +#include <blk.h>
> >   #include <bootm.h>
> >   #include <clk.h>
> >   #include <config.h>
> > @@ -14,6 +15,7 @@
> >   #include <env.h>
> >   #include <env_internal.h>
> >   #include <fdt_support.h>
> > +#include <fwu_metadata.h>
> >   #include <g_dnl.h>
> >   #include <generic-phy.h>
> >   #include <hang.h>
> > @@ -23,6 +25,7 @@
> >   #include <log.h>
> >   #include <malloc.h>
> >   #include <misc.h>
> > +#include <mmc.h>
> >   #include <mtd_node.h>
> >   #include <net.h>
> >   #include <netdev.h>
> > @@ -938,3 +941,63 @@ 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);
> > +
> > +#ifdef CONFIG_FWU_MULTI_BANK_UPDATE
> > +
> > +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;
> > +}
> > +
> > +int fwu_plat_get_blk_desc(struct blk_desc **desc)
> > +{
> > +     int ret;
> > +     struct mmc *mmc;
> > +     struct udevice *dev;
> > +
> > +     /*
> > +      * Initial support is being added for the DK2
> > +      * platform
> > +      */
> > +     if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
> > +         (of_machine_is_compatible("st,stm32mp157c-dk2"))) {
> > +             ret = uclass_get_device(UCLASS_MMC, 0, &dev);
> > +             if (ret)
> > +                     return -1;
> > +
> > +             mmc = mmc_get_mmc_dev(dev);
> > +             if (!mmc)
> > +                     return -1;
> > +
> > +             if (mmc_init(mmc))
> > +                     return -1;
> > +
> > +             *desc = mmc_get_blk_desc(mmc);
> > +             if (!*desc)
> > +                     return -1;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> > +struct fwu_metadata_ops *get_plat_fwu_metadata_ops(void)
> > +{
> > +     if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
> > +         (of_machine_is_compatible("st,stm32mp157c-dk2"))) {
> > +             return &fwu_gpt_blk_ops;
> > +     }
> > +
> > +     return NULL;
> > +}
> > +
> > +#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */
> > diff --git a/include/fwu_metadata.h b/include/fwu_metadata.h
> > index e692ef7506..6a5e814ab6 100644
> > --- a/include/fwu_metadata.h
> > +++ b/include/fwu_metadata.h
> > @@ -122,4 +122,7 @@ int fwu_accept_image(efi_guid_t *img_type_id);
> >   int fwu_clear_accept_image(efi_guid_t *img_type_id, u32 bank);
> >   int fwu_get_metadata(struct fwu_metadata **metadata);
> >
> > +int fwu_plat_get_update_index(u32 *update_idx);
> > +int fwu_plat_get_blk_desc(struct blk_desc **desc);
> > +
> >   #endif /* _FWU_METADATA_H_ */
>
>
> One general question:
>
>
> How we can handle the EV1 board with 2 MMC devices => eMMC (mmc1) /
> SDCard (mmc0)
>

The current metadata structure has a location_uuid, which can be used to
identify the device which will contain the banks of firmware images. The
current code for DK2 board does not have this implemented, but adding this
logic should not be difficult. Based on the location_uuid, we can identify
the device and return the blk_desc of that device.


>
> and how to managed HW partition of eMMC boot1 / boot2
>
> => for eMMC boot, the TF-A BL2 is located in these eMMC hw partition.
>
>
> in the serie, I see only support for partition > 0 => partition in GPT
> but not the update of eMMC boot partition.
>

I will get back to you on this. The current specification is dealing with
GPT formatted devices. Need to check how the boot partitions will be
supported for multiple banks of images.

 -sughosh


>
> Regards
>
> Patrick
>
>

  reply	other threads:[~2021-12-08 10:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25  7:01 [RFC PATCH 00/10] FWU: Add support for FWU Multi Bank Update feature Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 01/10] GPT: Add function to get gpt header and partition entries Sughosh Ganu
2021-12-07 15:35   ` Patrick DELAUNAY
2021-12-08  7:40     ` Sughosh Ganu
2021-12-09  1:32       ` AKASHI Takahiro
2021-12-09  9:00         ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 02/10] stm32mp: dfu: Move the ram partitions to the end of the dfu_alt_info variable Sughosh Ganu
2021-12-08 13:13   ` Etienne Carriere
2021-12-09  9:04     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 03/10] FWU: Add metadata structure and functions for accessing metadata Sughosh Ganu
2021-12-08 13:53   ` Etienne Carriere
2021-12-09  9:42     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 04/10] FWU: Add metadata access functions for GPT partitioned block devices Sughosh Ganu
2021-12-07 14:23   ` Patrick DELAUNAY
2021-12-08  7:18     ` Sughosh Ganu
2021-12-09  2:32   ` Simon Glass
2021-12-09  9:01     ` Sughosh Ganu
2021-12-09  9:35   ` Jason Liu
2021-12-09  9:46     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 05/10] FWU: stm32mp1: Add helper functions for accessing metadata Sughosh Ganu
2021-12-07 14:33   ` Patrick DELAUNAY
2021-12-08 10:18     ` Sughosh Ganu [this message]
2021-11-25  7:01 ` [RFC PATCH 06/10] FWU: STM32MP1: Add support to read boot index from backup register Sughosh Ganu
2021-12-07 14:27   ` Patrick DELAUNAY
2021-12-08  7:21     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 07/10] EFI: FMP: Add provision to update image's ImageTypeId in image descriptor Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 08/10] FWU: Add boot time checks as highlighted by the FWU specification Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 09/10] FWU: Add support for FWU Multi Bank Update feature Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 10/10] FWU: cmd: Add a command to read metadata Sughosh Ganu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADg8p957TvtUn3Zq32oNWLdvShE-RXQde07YX=x2iTyx3jwCYQ@mail.gmail.com' \
    --to=sughosh.ganu@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=bmeng.cn@gmail.com \
    --cc=grant.likely@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jason.hui.liu@nxp.com \
    --cc=jose.marinho@arm.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.