Skip to contentSkip to conversation

Add support for fwumdata

PATCH Superseded Kory Maincent 3 participants 12 messages Dec 12, 2025 – Feb 12

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for fwumdata

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Made a few change to mkfwumdata tool along the way.

Here is an output example

$ ./fwumdata -l
FWU Metadata:
	Version:            2
	Active Index:       0
	Previous Index:     1
	CRC32:              0x1f21ff7b
	Metadata Size:      120 bytes
	Descriptor Offset:  32
	Bank States:
		Bank 0: accepted (0xfc)
		Bank 1: accepted (0xfc)

Firmware Store Descriptor:
Number of Banks: 2
Number of Images: 1
Image Entry Size: 80
Bank Info Entry Size: 24

Images:
Image 0:
Image Type GUID: 65ae85ad-1fb3-0b46-8c5d-285543aa6eab
Location GUID: 51513491-da07-2a4f-9bea-375ea53b1b5c
Banks:
Bank 0:
Image GUID: cb2df442-f929-6a44-a374-672d92eb2aa7
Accepted: yes (1)
Bank 1:
Image GUID: a839a18f-395c-484f-83b8-0354077c8f9f
Accepted: yes (1)

Changes in v2:
- Fix a small offset mistake in last patch

---
Kory Maincent (6):
tools: gitignore: Add mkfwumdata to the git ignore file
tools: Reorganize mkfwumdata tool into fwumdata_src directory
tools: mkfwumdata: Improve error message specificity
tools: mkfwumdata: Add bank count validation for FWU metadata v2
tools: Add support for fwumdata tool
tools: mkfwumdata: Remove dependency on fwu_mdata.h header

 MAINTAINERS                           |   7 +-
 doc/develop/uefi/fwu_updates.rst      |   4 +-
 doc/fwumdata.1                        | 222 +++++++++
 tools/.gitignore                      |   2 +
 tools/Kconfig                         |   9 +-
 tools/Makefile                        |   4 +-
 tools/fwumdata_src/Kconfig            |  19 +
 tools/fwumdata_src/fwumdata.c         | 854 ++++++++++++++++++++++++++++++++++
 tools/fwumdata_src/fwumdata.config    |  33 ++
 tools/fwumdata_src/fwumdata.h         | 138 ++++++
 tools/fwumdata_src/fwumdata.mk        |  10 +
 tools/{ => fwumdata_src}/mkfwumdata.c | 106 ++---
 12 files changed, 1315 insertions(+), 93 deletions(-)

---
base-commit: 31bf4a1c308773895a8e7ea047b3cea037e4c922
change-id: 20251107-feature_fwumdata-58508d61e1d3

Best regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#1 lore raw

PATCH v2 1/6 tools: gitignore: Add mkfwumdata to the git ignore file

mkfwumdata is a built image. Add it to .gitignore.

---
 tools/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tools/.gitignore +1 -0
index 6a5c613f772..e8daa24a52d 100644
@@ -24,6 +24,7 @@
 /mkeficapsule
 /mkenvimage
 /mkexynosspl
+/mkfwumdata
 /mkimage
 /mksunxiboot
 /mxsboot
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/6 tools: Reorganize mkfwumdata tool into fwumdata_src directory

In reply to Kory Maincent

Update FWU metadata-related tools by moving mkfwumdata.c into a new tools/fwumdata_src/ directory structure. This refactoring prepares for the addition of the fwumdata runtime tool, which will allow editing FWU metadata directly from the target.

The Kconfig and Makefile entries are also moved into separate files within the new directory (Kconfig and fwumdata.mk respectively) to keep all FWU metadata tool configurations together and improve maintainability.

---
 MAINTAINERS                           | 3 ++-
 tools/Kconfig                         | 9 +--------
 tools/Makefile                        | 4 +---
 tools/fwumdata_src/Kconfig            | 8 ++++++++
 tools/fwumdata_src/fwumdata.mk        | 7 +++++++
 tools/{ => fwumdata_src}/mkfwumdata.c | 0
 6 files changed, 19 insertions(+), 12 deletions(-)
MAINTAINERS +2 -1
index b43dae882b3..5f560f4a94e 100644
@@ -1250,9 +1250,10 @@ FWU Multi Bank Update
 M:	Sughosh Ganu <[email protected]>
 S:	Maintained
 T:	git https://source.denx.de/u-boot/custodians/u-boot-efi.git
+F:	doc/mkfwumdata.1
 F:	lib/fwu_updates/*
 F:	drivers/fwu-mdata/*
-F:	tools/mkfwumdata.c
+F:	tools/fwumdata_src/mkfwumdata.c
 
 GATEWORKS_SC
 M:	Tim Harvey <[email protected]>
tools/Kconfig +1 -8
index 652b0f22557..9fe8b0f87d8 100644
@@ -194,13 +194,6 @@ config LUT_SEQUENCE
 	help
 	  Look Up Table Sequence
 
-config TOOLS_MKFWUMDATA
-	bool "Build mkfwumdata command"
-	default y if FWU_MULTI_BANK_UPDATE
-	help
-	  This command allows users to create a raw image of the FWU
-	  metadata for initial installation of the FWU multi bank
-	  update on the board. The installation method depends on
-	  the platform.
+source tools/fwumdata_src/Kconfig
 
 endmenu
tools/Makefile +1 -3
index ae6a3052646..1c58bac3033 100644
@@ -271,9 +271,7 @@ mkeficapsule-objs := generated/lib/uuid.o \
 	mkeficapsule.o
 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
-mkfwumdata-objs := mkfwumdata.o generated/lib/crc32.o
-HOSTLDLIBS_mkfwumdata += -luuid
-hostprogs-$(CONFIG_TOOLS_MKFWUMDATA) += mkfwumdata
+include tools/fwumdata_src/fwumdata.mk
 
 # We build some files with extra pedantic flags to try to minimize things
 # that won't build on some weird host compiler -- though there are lots of
tools/fwumdata_src/Kconfig new file +8 -0
new file mode 100644
index 00000000000..c033c560e8d
@@ -0,0 +1,8 @@
+config TOOLS_MKFWUMDATA
+	bool "Build mkfwumdata command"
+	default y if FWU_MULTI_BANK_UPDATE
+	help
+	  This command allows users to create a raw image of the FWU
+	  metadata for initial installation of the FWU multi bank
+	  update on the board. The installation method depends on
+	  the platform.
tools/fwumdata_src/fwumdata.mk new file +7 -0
new file mode 100644
index 00000000000..2ce618ef2ed
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2025, Kory Maincent <[email protected]>
+
+mkfwumdata-objs := fwumdata_src/mkfwumdata.o generated/lib/crc32.o
+HOSTLDLIBS_mkfwumdata += -luuid
+hostprogs-$(CONFIG_TOOLS_MKFWUMDATA) += mkfwumdata
tools/fwumdata_src/mkfwumdata.c renamed from tools/mkfwumdata.c +0 -0
similarity index 100%
rename from tools/mkfwumdata.c
rename to tools/fwumdata_src/mkfwumdata.c
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/6 tools: mkfwumdata: Improve error message specificity

In reply to Kory Maincent

Replace the generic error message with a more informative one. This helps users quickly understand the correct command-line argument format when the tool reports an error.

---
 tools/fwumdata_src/mkfwumdata.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/fwumdata_src/mkfwumdata.c +3 -1
index fbc2067bc12..5ceec7a2980 100644
@@ -473,7 +473,9 @@ int main(int argc, char *argv[])
 
 	/* This command takes UUIDs * images and output file. */
 	if (optind + images + 1 != argc) {
-		fprintf(stderr, "Error: UUID list or output file is not specified or too much.\n");
+		fprintf(stderr,
+			"Error: Expected %ld UUID string(s) and 1 output file, got %d argument(s).\n",
+			images, argc - optind);
 		print_usage();
 		return -ERANGE;
 	}
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/6 tools: mkfwumdata: Add bank count validation for FWU metadata v2

In reply to Kory Maincent

The FWU metadata specification version 2 supports a maximum of 4 banks. Add validation to enforce this limit and prevent creation of non-compliant metadata structures when using version 2.

Without this check, users could inadvertently create invalid metadata by specifying more than 4 banks, leading to potential compatibility issues with FWU-compliant firmware update implementations.

---
 tools/fwumdata_src/mkfwumdata.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/fwumdata_src/mkfwumdata.c +6 -0
index 5ceec7a2980..8b25539fd57 100644
@@ -471,6 +471,12 @@ int main(int argc, char *argv[])
 		return -EINVAL;
 	}
 
+	if (version == 2 && banks > MAX_BANKS_V2) {
+		fprintf(stderr, "Error: Version 2 supports maximum %d banks, %ld requested.\n",
+			MAX_BANKS_V2, banks);
+		return -EINVAL;
+	}
+
 	/* This command takes UUIDs * images and output file. */
 	if (optind + images + 1 != argc) {
 		fprintf(stderr,
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/6 tools: Add support for fwumdata tool

In reply to Kory Maincent

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

---
 MAINTAINERS                        |   4 +
 doc/develop/uefi/fwu_updates.rst   |   4 +-
 doc/fwumdata.1                     | 222 ++++++++++
 tools/.gitignore                   |   1 +
 tools/fwumdata_src/Kconfig         |  11 +
 tools/fwumdata_src/fwumdata.c      | 854 +++++++++++++++++++++++++++++++++++++
 tools/fwumdata_src/fwumdata.config |  33 ++
 tools/fwumdata_src/fwumdata.h      | 138 ++++++
 tools/fwumdata_src/fwumdata.mk     |   3 +
 9 files changed, 1269 insertions(+), 1 deletion(-)
MAINTAINERS +4 -0
index 5f560f4a94e..0ee5f6ea26f 100644
@@ -1248,11 +1248,15 @@ F:	drivers/watchdog/sbsa_gwdt.c
 
 FWU Multi Bank Update
 M:	Sughosh Ganu <[email protected]>
+M:	Kory Maincent <[email protected]>
 S:	Maintained
 T:	git https://source.denx.de/u-boot/custodians/u-boot-efi.git
+F:	doc/fwumdata.1
 F:	doc/mkfwumdata.1
 F:	lib/fwu_updates/*
 F:	drivers/fwu-mdata/*
+F:	tools/fwumdata_src/fwumdata.c
+F:	tools/fwumdata_src/fwumdata.h
 F:	tools/fwumdata_src/mkfwumdata.c
 
 GATEWORKS_SC
doc/develop/uefi/fwu_updates.rst +3 -1
index 84713581459..c592106f8a8 100644
@@ -66,7 +66,9 @@ FWU Metadata
 U-Boot supports both versions(1 and 2) of the FWU metadata defined in
 the two revisions of the specification. Support can be enabled for
 either of the two versions through a config flag. The mkfwumdata tool
-can generate metadata for both the supported versions.
+can generate metadata for both the supported versions. On the target side,
+the fwumdata tool can read and update FWU metadata located in memory,
+similarly to how fw_printenv/fw_setenv works.
 
 Setting up the device for GPT partitioned storage
 -------------------------------------------------
doc/fwumdata.1 new file +222 -0

222 lines not on this page · raw message

tools/.gitignore +1 -0
index e8daa24a52d..49943d2cf3a 100644
@@ -11,6 +11,7 @@
 /file2include
 /fit_check_sign
 /fit_info
+/fwumdata
 /gdb/gdbcont
 /gdb/gdbsend
 /gen_eth_addr
tools/fwumdata_src/Kconfig +11 -0
index c033c560e8d..af1f3bb3f57 100644
@@ -6,3 +6,14 @@ config TOOLS_MKFWUMDATA
 	  metadata for initial installation of the FWU multi bank
 	  update on the board. The installation method depends on
 	  the platform.
+
+config TOOLS_FWUMDATA
+	bool "Build fwumdata command"
+	default y if FWU_MULTI_BANK_UPDATE
+	help
+	  This command allows users to read, display, and modify FWU
+	  (Firmware Update) metadata from Linux userspace. It provides
+	  functionality similar to fw_printenv/fw_setenv but for FWU
+	  metadata. Users can view metadata, change active/previous
+	  bank indices, modify bank states, and set image acceptance
+	  flags. Configuration is done via fwumdata.config file.
tools/fwumdata_src/fwumdata.c new file +854 -0

854 lines not on this page · raw message

tools/fwumdata_src/fwumdata.config new file +33 -0
new file mode 100644
index 00000000000..7e83f7a5909
@@ -0,0 +1,33 @@
+# FWU Metadata Configuration File
+#
+# Format: <device> <offset> <metadata_size> <erase_size>
+#
+# This file describes where the FWU metadata is stored. You can specify
+# up to two entries for redundant metadata copies.
+#
+# Device: MTD device (/dev/mtdX), block device (/dev/mmcblkX), or file path
+# Offset: Byte offset from start of device (hex with 0x prefix)
+# Metadata Size: Size of metadata structure in bytes (hex with 0x prefix)
+# Erase Size: Sector/erase block size (hex with 0x prefix, defaults to
+#	      metadata_size, required only for MTD device)
+#
+# Examples:
+#
+# MTD devices (NOR/NAND flash):
+# /dev/mtd0  0x0       0x1000  0x1000
+# /dev/mtd1  0x0       0x1000  0x1000
+#
+# Block device (eMMC/SD):
+# /dev/mmcblk0  0x100000  0x78
+# /dev/mmcblk0  0x101000  0x78
+#
+# or:
+# /dev/disk/by-partlabel/metadata1  0  0x78
+# /dev/disk/by-partlabel/metadata2  0  0x78
+#
+# Regular file:
+# /boot/fwu-mdata.bin  0x0  0x78
+#
+# Default configuration (update for your platform):
+/dev/mtd0  0x0  0x78  0x1000
+/dev/mtd1  0x0  0x78  0x1000
tools/fwumdata_src/fwumdata.h new file +138 -0

138 lines not on this page · raw message

tools/fwumdata_src/fwumdata.mk +3 -0
index 2ce618ef2ed..2199e43b372 100644
@@ -5,3 +5,6 @@
 mkfwumdata-objs := fwumdata_src/mkfwumdata.o generated/lib/crc32.o
 HOSTLDLIBS_mkfwumdata += -luuid
 hostprogs-$(CONFIG_TOOLS_MKFWUMDATA) += mkfwumdata
+
+fwumdata-objs := fwumdata_src/fwumdata.o generated/lib/crc32.o
+hostprogs-$(CONFIG_TOOLS_FWUMDATA) += fwumdata
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 6/6 tools: mkfwumdata: Remove dependency on fwu_mdata.h header

In reply to Kory Maincent

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.

---

Change in v2:
- Fix mdata->desc_offset value.

---
 tools/fwumdata_src/mkfwumdata.c | 96 ++++++++---------------------------------
 1 file changed, 17 insertions(+), 79 deletions(-)
tools/fwumdata_src/mkfwumdata.c +17 -79
index 8b25539fd57..b8b60473b91 100644
@@ -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]);
Signature · 1 line
2.43.0
#7 lore raw
In reply to Kory Maincent

Hi Kory,

I haven't lost track of this, I'll try to have a look as soon as I can. For the record, I still don't think this is a great idea. I'd rather have people follow the design docs.
I understand the acceptance capsule feels 'weird', but there was a good reason for it. There's a PR with an update to the spec, which makes the acceptance substantially easier now that all the ecosystem parts are in place [0[

[0] https://github.com/ARM-software/edge-iot-arch-guide/pull/21

Cheers
/Ilias

Quoted 77 lines · Kory Maincent

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Made a few change to mkfwumdata tool along the way.

Here is an output example

$ ./fwumdata -l
FWU Metadata:
        Version:            2
        Active Index:       0
        Previous Index:     1
        CRC32:              0x1f21ff7b
        Metadata Size:      120 bytes
        Descriptor Offset:  32
        Bank States:
                Bank 0: accepted (0xfc)
                Bank 1: accepted (0xfc)

Firmware Store Descriptor:
Number of Banks: 2
Number of Images: 1
Image Entry Size: 80
Bank Info Entry Size: 24

Images:
Image 0:
Image Type GUID: 65ae85ad-1fb3-0b46-8c5d-285543aa6eab
Location GUID: 51513491-da07-2a4f-9bea-375ea53b1b5c
Banks:
Bank 0:
Image GUID: cb2df442-f929-6a44-a374-672d92eb2aa7
Accepted: yes (1)
Bank 1:
Image GUID: a839a18f-395c-484f-83b8-0354077c8f9f
Accepted: yes (1)

Changes in v2:
- Fix a small offset mistake in last patch

---
Kory Maincent (6):
tools: gitignore: Add mkfwumdata to the git ignore file
tools: Reorganize mkfwumdata tool into fwumdata_src directory
tools: mkfwumdata: Improve error message specificity
tools: mkfwumdata: Add bank count validation for FWU metadata v2
tools: Add support for fwumdata tool
tools: mkfwumdata: Remove dependency on fwu_mdata.h header

 MAINTAINERS                           |   7 +-
 doc/develop/uefi/fwu_updates.rst      |   4 +-
 doc/fwumdata.1                        | 222 +++++++++
 tools/.gitignore                      |   2 +
 tools/Kconfig                         |   9 +-
 tools/Makefile                        |   4 +-
 tools/fwumdata_src/Kconfig            |  19 +
 tools/fwumdata_src/fwumdata.c         | 854 ++++++++++++++++++++++++++++++++++
 tools/fwumdata_src/fwumdata.config    |  33 ++
 tools/fwumdata_src/fwumdata.h         | 138 ++++++
 tools/fwumdata_src/fwumdata.mk        |  10 +
 tools/{ => fwumdata_src}/mkfwumdata.c | 106 ++---
 12 files changed, 1315 insertions(+), 93 deletions(-)

---
base-commit: 31bf4a1c308773895a8e7ea047b3cea037e4c922
change-id: 20251107-feature_fwumdata-58508d61e1d3

Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

#8 lore raw

Hello Ilias,

Quoted 5 lines · On Thu, 18 Dec 2025 14:04:12 +0200 Ilias Apalodimas…

Hi Kory,

I haven't lost track of this, I'll try to have a look as soon as I can. For the record, I still don't think this is a great idea. I'd rather have people follow the design docs.

I don't get it. What are your arguments against this tool? It is a simple way to change the content of the FWU metadata from Linux.

Quoted 6 lines

I understand the acceptance capsule feels 'weird', but there was a good reason for it. There's a PR with an update to the spec, which makes the acceptance substantially easier now that all the ecosystem parts are in place [0[

[0] https://github.com/ARM-software/edge-iot-arch-guide/pull/21

This design guideline is for one use case of FWU Metadata. It needs UEFI and capsule update.

FWU Metadata is an update standard for ARM architecture, it is not dependent on the implementation. UEFI with capsule update is one implementation, but we could have others.
https://documentation-service.arm.com/static/660be6391bc22b03bca92702

On my case (ST board) there is no UEFI, I have TF-A (FSBL) that reads the FWU metadata to know the location of the FIP Image (SSBL which contain U-boot and OPTEE).
During the OTA process, Linux is updating the FWU metadata to change the active bank and the bank state with this new fwumdata tool.

Note that the previous development of FWU support in U-boot as not been developed in a generic way but bound to the UEFI capsule framework which is not ideal. On my case if I want to read FWU metadata in U-boot I have to enable the UEFI capsule config for nothing.

Regards,

Quoted 82 lines

Cheers
/Ilias

Quoted 77 lines · Kory Maincent

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Made a few change to mkfwumdata tool along the way.

Here is an output example

$ ./fwumdata -l
FWU Metadata:
        Version:            2
        Active Index:       0
        Previous Index:     1
        CRC32:              0x1f21ff7b
        Metadata Size:      120 bytes
        Descriptor Offset:  32
        Bank States:
                Bank 0: accepted (0xfc)
                Bank 1: accepted (0xfc)

Firmware Store Descriptor:
Number of Banks: 2
Number of Images: 1
Image Entry Size: 80
Bank Info Entry Size: 24

Images:
Image 0:
Image Type GUID:
65ae85ad-1fb3-0b46-8c5d-285543aa6eab Location GUID:
51513491-da07-2a4f-9bea-375ea53b1b5c Banks:

                                Bank 0:
                                        Image GUID:
cb2df442-f929-6a44-a374-672d92eb2aa7 Accepted:    yes (1)
                                Bank 1:
                                        Image GUID:

a839a18f-395c-484f-83b8-0354077c8f9f Accepted: yes (1)

Changes in v2:
- Fix a small offset mistake in last patch

---
Kory Maincent (6):
tools: gitignore: Add mkfwumdata to the git ignore file
tools: Reorganize mkfwumdata tool into fwumdata_src directory
tools: mkfwumdata: Improve error message specificity
tools: mkfwumdata: Add bank count validation for FWU metadata v2
tools: Add support for fwumdata tool
tools: mkfwumdata: Remove dependency on fwu_mdata.h header

 MAINTAINERS                           |   7 +-
 doc/develop/uefi/fwu_updates.rst      |   4 +-
 doc/fwumdata.1                        | 222 +++++++++
 tools/.gitignore                      |   2 +
 tools/Kconfig                         |   9 +-
 tools/Makefile                        |   4 +-
 tools/fwumdata_src/Kconfig            |  19 +
 tools/fwumdata_src/fwumdata.c         | 854
++++++++++++++++++++++++++++++++++ tools/fwumdata_src/fwumdata.config    |
33 ++ tools/fwumdata_src/fwumdata.h         | 138 ++++++
 tools/fwumdata_src/fwumdata.mk        |  10 +
 tools/{ => fwumdata_src}/mkfwumdata.c | 106 ++---
 12 files changed, 1315 insertions(+), 93 deletions(-)

---
base-commit: 31bf4a1c308773895a8e7ea047b3cea037e4c922
change-id: 20251107-feature_fwumdata-58508d61e1d3

Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#9 lore raw

Hi Kory,

+CC Jose who maintains the spec from Arm

Quoted 6 lines · Kory Maincent

Hello Ilias,

On Thu, 18 Dec 2025 14:04:12 +0200
Ilias Apalodimas <[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

Hi Kory,

I haven't lost track of this, I'll try to have a look as soon as I can. For the record, I still don't think this is a great idea. I'd rather have people follow the design docs.

I don't get it. What are your arguments against this tool? It is a simple way to change the content of the FWU metadata from Linux.

DEN0118 doesn't explicitly require UEFI. However, the Arm architecture is officially supporting the EFI spec. Even from a Linux kernel perspective, booting with EFI is encouraged. There is certain functionality you don't get without EFI. On top, there are manufacturers that keep the metadata in the secure world. I understand that the tool is a handy way to change that from Linux.

Quoted 8 lines
Quoted 7 lines

I understand the acceptance capsule feels 'weird', but there was a good reason for it. There's a PR with an update to the spec, which makes the acceptance substantially easier now that all the ecosystem parts are in place [0[

[0] https://github.com/ARM-software/edge-iot-arch-guide/pull/21

Quoted 7 lines

This design guideline is for one use case of FWU Metadata. It needs UEFI and capsule update.

FWU Metadata is an update standard for ARM architecture, it is not dependent on the implementation. UEFI with capsule update is one implementation, but we could have others.
https://documentation-service.arm.com/static/660be6391bc22b03bca92702

I've been involved in the document design since the beginning and the primary goal was to consume this via EFI & capsules. That's why that second document(MBFW) I pointed to exists.

Quoted 10 lines

On my case (ST board) there is no UEFI, I have TF-A (FSBL) that reads the FWU metadata to know the location of the FIP Image (SSBL which contain U-boot and OPTEE).
During the OTA process, Linux is updating the FWU metadata to change the active bank and the bank state with this new fwumdata tool.

Note that the previous development of FWU support in U-boot as not been developed in a generic way but bound to the UEFI capsule framework which is not ideal.

Yes, that was on purpose, I reviewed and helped in most of that.

Quoted 2 lines

On my case if I want to read FWU metadata in U-boot I have to enable the UEFI capsule config for nothing.

That's ok. That's an ST call, but I am merely trying to explain the reasoning behind the two specs

Regards
/Ilias

Quoted 92 lines

Regards,

Quoted 82 lines

Cheers
/Ilias

Quoted 77 lines · Kory Maincent

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Made a few change to mkfwumdata tool along the way.

Here is an output example

$ ./fwumdata -l
FWU Metadata:
        Version:            2
        Active Index:       0
        Previous Index:     1
        CRC32:              0x1f21ff7b
        Metadata Size:      120 bytes
        Descriptor Offset:  32
        Bank States:
                Bank 0: accepted (0xfc)
                Bank 1: accepted (0xfc)

Firmware Store Descriptor:
Number of Banks: 2
Number of Images: 1
Image Entry Size: 80
Bank Info Entry Size: 24

Images:
Image 0:
Image Type GUID:
65ae85ad-1fb3-0b46-8c5d-285543aa6eab Location GUID:
51513491-da07-2a4f-9bea-375ea53b1b5c Banks:

                                Bank 0:
                                        Image GUID:
cb2df442-f929-6a44-a374-672d92eb2aa7 Accepted:    yes (1)
                                Bank 1:
                                        Image GUID:

a839a18f-395c-484f-83b8-0354077c8f9f Accepted: yes (1)

Changes in v2:
- Fix a small offset mistake in last patch

---
Kory Maincent (6):
tools: gitignore: Add mkfwumdata to the git ignore file
tools: Reorganize mkfwumdata tool into fwumdata_src directory
tools: mkfwumdata: Improve error message specificity
tools: mkfwumdata: Add bank count validation for FWU metadata v2
tools: Add support for fwumdata tool
tools: mkfwumdata: Remove dependency on fwu_mdata.h header

 MAINTAINERS                           |   7 +-
 doc/develop/uefi/fwu_updates.rst      |   4 +-
 doc/fwumdata.1                        | 222 +++++++++
 tools/.gitignore                      |   2 +
 tools/Kconfig                         |   9 +-
 tools/Makefile                        |   4 +-
 tools/fwumdata_src/Kconfig            |  19 +
 tools/fwumdata_src/fwumdata.c         | 854
++++++++++++++++++++++++++++++++++ tools/fwumdata_src/fwumdata.config    |
33 ++ tools/fwumdata_src/fwumdata.h         | 138 ++++++
 tools/fwumdata_src/fwumdata.mk        |  10 +
 tools/{ => fwumdata_src}/mkfwumdata.c | 106 ++---
 12 files changed, 1315 insertions(+), 93 deletions(-)

---
base-commit: 31bf4a1c308773895a8e7ea047b3cea037e4c922
change-id: 20251107-feature_fwumdata-58508d61e1d3

Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

#10 lore raw
In reply to Kory Maincent
Quoted 7 lines · On Fri, 12 Dec 2025 17:23:25 +0100 Kory Maincent <[email protected]>…

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Made a few change to mkfwumdata tool along the way.

Hello, any news on this patch series.

It would be nice if someone could take a look at this and help me get this merged.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#11 lore raw
Quoted 9 lines · Kory Maincent
Quoted 6 lines · On Fri, 12 Dec 2025 17:23:25 +0100 Kory Maincent <[email protected]>…

Add a new fwumdata tool to allows users to read, display, and modify FWU (Firmware Update) metadata from Linux userspace. It provides functionality similar to fw_printenv/fw_setenv but for FWU metadata. Users can view metadata, change active/previous bank indices, modify bank states, and set image acceptance flags. Configuration is done via fwumdata.config file.

Quoted 6 lines
Quoted 1 line

Made a few change to mkfwumdata tool along the way.

Hello, any news on this patch series.

It would be nice if someone could take a look at this and help me get this merged.

Apologies for the late response. I recently moved to a different role, and missed getting these patches. A couple of these patches no longer apply, so it would be good to send a rebased series. Moreover, the patchset makes changes which affect the current mkfwumdata tool. I will test these changes on hardware early next week, and get back with my feedback. Thanks.

-sughosh