[PATCH 4/5] tools: Add dumpfwumdata tool for FWU metadata image
Kory Maincent
kory.maincent at bootlin.com
Mon Jan 19 10:33:42 CET 2026
On Sat, 17 Jan 2026 12:11:18 +0100
Dario Binacchi <dario.binacchi at amarulasolutions.com> wrote:
> Hello Kory,
>
> On Mon, Jan 12, 2026 at 10:24 AM Kory Maincent
> <kory.maincent at bootlin.com> wrote:
> >
> > On Mon, 12 Jan 2026 10:05:50 +0100
> > Michal Simek <monstr at monstr.eu> wrote:
> >
> > > On 1/11/26 16:17, Dario Binacchi wrote:
> > > > Hello Michal,
> > > >
> > > > On Mon, Jan 5, 2026 at 4:40 PM Michal Simek <monstr at monstr.eu> wrote:
> > > >>
> > > >> ne 28. 12. 2025 v 16:19 odesílatel Dario Binacchi
> > > >> <dario.binacchi at amarulasolutions.com> napsal:
> > > >>>
> > > >>> Allow reading FWU metadata from userspace.
> > > >>>
> > > >>> According to [1], after updating the software on bank B, setting
> > > >>> active_index to point to it (i. e. 1) and marking it as a Valid bank,
> > > >>> it must be possible to read this information from userspace on the
> > > >>> next boot to verify whether the boot chain of bank B succeeded.
> > > >>>
> > > >>> The metadata must then be updated again, marking the bank as INVALID
> > > >>> if the active_index points to bank A (i. e. 0) or as VALID if the
> > > >>> boot was successful.
> > > >>>
> > > >>> To allow reading the active_index and bank state, this new tool has
> > > >>> been added.
> > > >>>
> > > >>> Signed-off-by: Dario Binacchi <dario.binacchi at amarulasolutions.com>
> >
> > ...
> >
> > > >>> +}
> > > >>> +
> > > >>> +static int fwu_read_mdata(struct fwu_mdata *mdata, const char
> > > >>> *mdata_file) +{
> > > >>> + FILE *mfile = NULL;
> > > >>> + size_t ret, size = sizeof(struct fwu_mdata);
> > > >>> +
> > > >>> + mfile = fopen(mdata_file, "r");
> > > >>> + if (!mfile) {
> > > >>> + fprintf(stderr, "Error: Failed to open %s\n",
> > > >>> + mdata_file);
> > > >>> + return -1;
> > > >>> + }
> > > >>> +
> > > >>> + ret = fread(mdata, 1, size, mfile);
> > > >>> + fclose(mfile);
> > > >>> + if (ret != size) {
> > > >>> + fprintf(stderr, "Error: Failed to read from %s\n",
> > > >>> + mdata_file);
> > > >>> + return -1;
> > > >>> + }
> > > >>> +
> > > >>> + return 0;
> > > >>> +}
> > > >>> +
> > > >>> +int main(int argc, char *argv[])
> > > >>> +{
> > > >>> + int c, ret;
> > > >>> + struct fwu_mdata mdata;
> > > >>> +
> > > >>> + if (argc < 3) {
> > > >>> + print_usage();
> > > >>> + return -EINVAL;
> > > >>> + }
> > > >>
> > > >> above you have only help and here you are asking for 3 args which
> > > >> seems to me wrong.
> > > >
> > > > Thank you for your review and the feedback on my patch series.
> > > > After I sent the series, I realized that this series had previously
> > > > been posted:
> > > > https://lore.kernel.org/all/20251212-feature_fwumdata-v2-0-ad51572fbe79@bootlin.com/.
> > > > From what I understand, it starts from the same need as mine, namely
> > > > the implementation of a tool that
> > > > allows reading FWU metadata from Linux. My version is definitely more
> > > > minimal compared to what Kory
> > > > has done.
> > > > Therefore, before sending a v2, I think it would be useful to
> > > > understand which of the two makes more sense
> > > > to move forward with. Could you help me with that? I have also CCed
> > > > Kory to keep the discussion shared.
> > >
> > > Kory's version looks more complete. If Kory is happy to send another
> > > version I think you should test it, review it. If he is not going to send
> > > v3 I think you should merge your series with his and send another
> > > version.
> >
> > Hello,
> >
> > I was going to ping reviews on my series.
> > I will be glad to send a 3rd version but there will be no change from v2 as
> > nobody reviewed it for now, but if needed I can resend it.
> > It would be nice if you review and test it on you side to know if it match
> > your requirements.
>
> I'll be resuming work on swupdate for our STM32MP-based custom board shortly
> and will test your series as soon as possible.
>
> Just one question: I was expecting the introduction of a tool to read the
> data contained in fwu-metadata. Why does your new tool also add write
> functionality, considering that mkfwumdata already exists?
Hello,
Because we don't want to generate a new FWU metadata every time and then write
it on the FWU metadata partition. It is better to read and edit part of it
directly with the same tool.
The way I saw it was that mkfwumdata should only to be used on the host side to
generate the first FWU metadata.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
More information about the U-Boot
mailing list