From: Sughosh Ganu <sughosh.ganu@arm.com>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: u-boot@lists.denx.de,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tom Rini" <trini@konsulko.com>,
"Patrice Chotard" <patrice.chotard@foss.st.com>,
"Paul HENRYS" <paul.henrys_ext@softathome.com>,
"Greg Malysa" <malysagreg@gmail.com>,
"Arturs Artamonovs" <arturs.artamonovs@analog.com>,
"Vasileios Bimpikas" <vasileios.bimpikas@analog.com>,
"Utsav Agarwal" <utsav.agarwal@analog.com>,
"Nathan Barrett-Morrison" <nathan.morrison@timesys.com>,
"Peng Fan" <peng.fan@nxp.com>, "Simon Glass" <sjg@chromium.org>,
"Duje Mihanović" <duje@dujemihanovic.xyz>,
"Stefan Roese" <stefan.roese@mailbox.org>,
"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
"Sumit Garg" <sumit.garg@kernel.org>,
"Heiko Schocher" <hs@nabladev.com>,
"Alif Zakuan Yuslaimi" <alif.zakuan.yuslaimi@altera.com>,
"E Shattow" <e@freeshell.de>,
"Raymond Mao" <raymondmaoca@gmail.com>,
"Jan Kiszka" <jan.kiszka@siemens.com>,
"Shiji Yang" <yangshiji66@outlook.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Leonard Anderweit" <l.anderweit@phytec.de>,
"Yao Zi" <me@ziyao.cc>
Subject: Re: [PATCH v3 6/6] tools: mkfwumdata: Remove dependency on fwu_mdata.h header
Date: Wed, 18 Feb 2026 15:18:43 +0530 [thread overview]
Message-ID: <aZWK--beAfDJR5_C@a079122.arm.com> (raw)
In-Reply-To: <20260216-feature_fwumdata-v3-6-9ecc5b10456d@bootlin.com>
On Mon, Feb 16, 2026 at 02:35:36PM +0100, Kory Maincent wrote:
> The dependency on fwu_mdata.h creates unnecessary configuration
> requirements. To generate metadata V1, CONFIG_FWU_MDATA_V1 must be
> enabled, which in turn requires enabling FWU_MULTI_BANK_UPDATE,
> EFI_CAPSULE_ON_DISK, PARTITION_TYPE_GUID, and other unrelated configs.
> This is not suitable for a simple standalone tool.
>
> Additionally, even with the "-v 1" option to generate V1 metadata, the
> tool will still include the firmware store description if
> CONFIG_FWU_MDATA_V1 is not enabled. This structure should only be
> present in metadata V2.
>
> Replace the fwu_mdata.h dependency with the new fwumdata header to make
> the tool compatible with both V1 and V2 without requiring any defconfig
> changes. This also uses the access helper functions from the header to
> eliminate code duplication.
>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
Acked-by: Sughosh Ganu <sughosh.ganu@arm.com>
Tested-by: Sughosh Ganu <sughosh.ganu@arm.com>
-sughosh
>
> Change in v2:
> - Fix mdata->desc_offset value.
> ---
> tools/fwumdata_src/mkfwumdata.c | 96 ++++++++---------------------------------
> 1 file changed, 17 insertions(+), 79 deletions(-)
>
> diff --git a/tools/fwumdata_src/mkfwumdata.c b/tools/fwumdata_src/mkfwumdata.c
> index 8b25539fd57..b8b60473b91 100644
> --- a/tools/fwumdata_src/mkfwumdata.c
> +++ b/tools/fwumdata_src/mkfwumdata.c
> @@ -17,26 +17,7 @@
> #include <u-boot/crc.h>
> #include <uuid/uuid.h>
>
> -typedef uint8_t u8;
> -typedef int16_t s16;
> -typedef uint16_t u16;
> -typedef uint32_t u32;
> -typedef uint64_t u64;
> -
> -#undef CONFIG_FWU_NUM_BANKS
> -#undef CONFIG_FWU_NUM_IMAGES_PER_BANK
> -
> -/* This will dynamically allocate the fwu_mdata */
> -#define CONFIG_FWU_NUM_BANKS 0
> -#define CONFIG_FWU_NUM_IMAGES_PER_BANK 0
> -
> -/* version 2 supports maximum of 4 banks */
> -#define MAX_BANKS_V2 4
> -
> -#define BANK_INVALID (u8)0xFF
> -#define BANK_ACCEPTED (u8)0xFC
> -
> -#include <fwu_mdata.h>
> +#include "fwumdata.h"
>
> static const char *opts_short = "b:i:a:p:v:V:gh";
>
> @@ -116,6 +97,7 @@ static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks,
> sizeof(struct fwu_image_bank_info) * banks) * images;
> } else {
> mobj->size = sizeof(struct fwu_mdata) +
> + sizeof(struct fwu_mdata_ext) +
> sizeof(struct fwu_fw_store_desc) +
> (sizeof(struct fwu_image_entry) +
> sizeof(struct fwu_image_bank_info) * banks) * images;
> @@ -146,50 +128,6 @@ alloc_err:
> return NULL;
> }
>
> -static struct fwu_image_entry *
> -fwu_get_image(struct fwu_mdata_object *mobj, size_t idx)
> -{
> - size_t offset;
> -
> - if (mobj->version == 1) {
> - offset = sizeof(struct fwu_mdata) +
> - (sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * mobj->banks) *
> - idx;
> - } else {
> - offset = sizeof(struct fwu_mdata) +
> - sizeof(struct fwu_fw_store_desc) +
> - (sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * mobj->banks) *
> - idx;
> - }
> -
> - return (struct fwu_image_entry *)((char *)mobj->mdata + offset);
> -}
> -
> -static struct fwu_image_bank_info *
> -fwu_get_bank(struct fwu_mdata_object *mobj, size_t img_idx, size_t bnk_idx)
> -{
> - size_t offset;
> -
> - if (mobj->version == 1) {
> - offset = sizeof(struct fwu_mdata) +
> - (sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * mobj->banks) *
> - img_idx + sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * bnk_idx;
> - } else {
> - offset = sizeof(struct fwu_mdata) +
> - sizeof(struct fwu_fw_store_desc) +
> - (sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * mobj->banks) *
> - img_idx + sizeof(struct fwu_image_entry) +
> - sizeof(struct fwu_image_bank_info) * bnk_idx;
> - }
> -
> - return (struct fwu_image_bank_info *)((char *)mobj->mdata + offset);
> -}
> -
> /**
> * convert_uuid_to_guid() - convert UUID to GUID
> * @buf: UUID binary
> @@ -239,11 +177,13 @@ static int
> fwu_parse_fill_image_uuid(struct fwu_mdata_object *mobj,
> size_t idx, char *uuids)
> {
> - struct fwu_image_entry *image = fwu_get_image(mobj, idx);
> struct fwu_image_bank_info *bank;
> + struct fwu_image_entry *image;
> char *p = uuids, *uuid;
> int i;
>
> + image = fwu_get_image_entry(mobj->mdata, mobj->version,
> + mobj->banks, idx);
> if (!image)
> return -ENOENT;
>
> @@ -266,7 +206,8 @@ fwu_parse_fill_image_uuid(struct fwu_mdata_object *mobj,
>
> /* Fill bank image-UUID */
> for (i = 0; i < mobj->banks; i++) {
> - bank = fwu_get_bank(mobj, idx, i);
> + bank = fwu_get_bank_info(mobj->mdata, mobj->version,
> + mobj->banks, idx, i);
> if (!bank)
> return -ENOENT;
> bank->accepted = 1;
> @@ -281,25 +222,22 @@ fwu_parse_fill_image_uuid(struct fwu_mdata_object *mobj,
> return 0;
> }
>
> -#if defined(CONFIG_FWU_MDATA_V1)
> -static void fwu_fill_version_specific_mdata(struct fwu_mdata_object *mobj)
> -{
> -}
> -#else
> static void fwu_fill_version_specific_mdata(struct fwu_mdata_object *mobj)
> {
> int i;
> struct fwu_fw_store_desc *fw_desc;
> - struct fwu_mdata *mdata = mobj->mdata;
> + struct fwu_mdata_ext *mdata_ext;
>
> - mdata->metadata_size = mobj->size;
> - mdata->desc_offset = sizeof(struct fwu_mdata);
> + mdata_ext = fwu_get_fw_mdata_ext(mobj->mdata);
> + mdata_ext->metadata_size = mobj->size;
> + mdata_ext->desc_offset = sizeof(struct fwu_mdata) +
> + sizeof(struct fwu_mdata_ext);
>
> for (i = 0; i < MAX_BANKS_V2; i++)
> - mdata->bank_state[i] = i < mobj->banks ?
> - BANK_ACCEPTED : BANK_INVALID;
> + mdata_ext->bank_state[i] = i < mobj->banks ?
> + FWU_BANK_ACCEPTED : FWU_BANK_INVALID;
>
> - fw_desc = (struct fwu_fw_store_desc *)((u8 *)mdata + sizeof(*mdata));
> + fw_desc = fwu_get_fw_desc(mobj->mdata);
> fw_desc->num_banks = mobj->banks;
> fw_desc->num_images = mobj->images;
> fw_desc->img_entry_size = sizeof(struct fwu_image_entry) +
> @@ -307,7 +245,6 @@ static void fwu_fill_version_specific_mdata(struct fwu_mdata_object *mobj)
> fw_desc->bank_info_entry_size =
> sizeof(struct fwu_image_bank_info);
> }
> -#endif /* CONFIG_FWU_MDATA_V1 */
>
> /* Caller must ensure that @uuids[] has @mobj->images entries. */
> static int fwu_parse_fill_uuids(struct fwu_mdata_object *mobj, char *uuids[])
> @@ -320,7 +257,8 @@ static int fwu_parse_fill_uuids(struct fwu_mdata_object *mobj, char *uuids[])
> mdata->active_index = active_bank;
> mdata->previous_active_index = previous_bank;
>
> - fwu_fill_version_specific_mdata(mobj);
> + if (mdata->version == 2)
> + fwu_fill_version_specific_mdata(mobj);
>
> for (i = 0; i < mobj->images; i++) {
> ret = fwu_parse_fill_image_uuid(mobj, i, uuids[i]);
>
> --
> 2.43.0
>
-sughosh
prev parent reply other threads:[~2026-02-18 9:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 13:35 [PATCH v3 0/6] Add support for fwumdata Kory Maincent
2026-02-16 13:35 ` [PATCH v3 1/6] tools: gitignore: Add mkfwumdata to the git ignore file Kory Maincent
2026-02-16 13:35 ` [PATCH v3 2/6] tools: Reorganize mkfwumdata tool into fwumdata_src directory Kory Maincent
2026-02-16 13:35 ` [PATCH v3 3/6] tools: mkfwumdata: Improve error message specificity Kory Maincent
2026-02-16 13:35 ` [PATCH v3 4/6] tools: mkfwumdata: Add bank count validation for FWU metadata v2 Kory Maincent
2026-02-16 13:35 ` [PATCH v3 5/6] tools: Add support for fwumdata tool Kory Maincent
2026-02-18 9:47 ` Sughosh Ganu
2026-02-18 9:56 ` Sughosh Ganu
2026-02-18 10:31 ` Kory Maincent
2026-02-18 10:45 ` Sughosh Ganu
2026-02-18 11:08 ` Kory Maincent
2026-02-18 11:23 ` Sughosh Ganu
2026-02-18 13:55 ` Ilias Apalodimas
2026-02-18 15:17 ` Kory Maincent
2026-02-18 9:53 ` Sughosh Ganu
2026-02-18 10:36 ` Kory Maincent
2026-02-16 13:35 ` [PATCH v3 6/6] tools: mkfwumdata: Remove dependency on fwu_mdata.h header Kory Maincent
2026-02-18 9:48 ` Sughosh Ganu [this message]
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=aZWK--beAfDJR5_C@a079122.arm.com \
--to=sughosh.ganu@arm.com \
--cc=alif.zakuan.yuslaimi@altera.com \
--cc=arturs.artamonovs@analog.com \
--cc=daniel@makrotopia.org \
--cc=duje@dujemihanovic.xyz \
--cc=e@freeshell.de \
--cc=hs@nabladev.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jan.kiszka@siemens.com \
--cc=kory.maincent@bootlin.com \
--cc=l.anderweit@phytec.de \
--cc=malysagreg@gmail.com \
--cc=me@ziyao.cc \
--cc=mkorpershoek@kernel.org \
--cc=nathan.morrison@timesys.com \
--cc=patrice.chotard@foss.st.com \
--cc=paul.henrys_ext@softathome.com \
--cc=peng.fan@nxp.com \
--cc=raymondmaoca@gmail.com \
--cc=sjg@chromium.org \
--cc=stefan.roese@mailbox.org \
--cc=sumit.garg@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=utsav.agarwal@analog.com \
--cc=vasileios.bimpikas@analog.com \
--cc=xypron.glpk@gmx.de \
--cc=yangshiji66@outlook.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox