Skip to contentSkip to conversation

fit: print conf node compatibles + use property string constants

RFC PATCH Superseded Quentin Schulz 3 participants 8 messages Apr 9, 2025 – Dec 3, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover fit: print conf node compatibles + use property string constants

This does a bit of "cleanup" by reusing constants for some FIT properties instead of having the same string in multiple places.

Additionally, this adds a new constant for the compatible property in FIT configuration nodes[1] which is useful for FIT images with multiple FIT configuration nodes to support multiple devices in the same blob. U-Boot will try to figure out which node to select based on that compatible[2].

However, if this property is missing (and the first blob in the fdt property of the configuration node is uncompressed), the compatible from the root node of the associated kernel FDT will be used for the autoselection mechanism. For now, I only print the property if it exists, but maybe it'd make sense to expose the fallback one if it's missing, hence the RFC state for this series.

[1] https://fitspec.osfw.foundation/#optional-properties compatible paragraph
[2] https://fitspec.osfw.foundation/#select-a-configuration-to-boot

---
Quentin Schulz (4):
boot/fit: use constants for property strings
lib: rsa: use FIT_ALGO_PROP constant instead of "algo" in FIT boot/fit: declare (and use) new constant for conf's compatible prop boot/fit: print all configuration node compatibles

 boot/common_fit.c    |  4 ++--
 boot/image-fit.c     | 15 +++++++++++++--
 include/image.h      |  1 +
 lib/rsa/rsa-verify.c |  2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

---
base-commit: 341cafc31e4c6941a1b05feb18d18c99ffaebcc1
change-id: 20250409-fit-compat-ebe94f690b08

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>
#1 lore raw

RFC PATCH 1/4 boot/fit: use constants for property strings

From: Quentin Schulz <[email protected]>

Some properties have their string represented in include/image.h via constants, so let's use those constants instead of using a hardcoded string.

---
 boot/common_fit.c | 4 ++--
 boot/image-fit.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
boot/common_fit.c +2 -2
index a2f9b8d83c3b66a39ae0e172445d162f5146578a..fd434fe28e1908596365c9d31892a73ec97c36e3 100644
@@ -46,12 +46,12 @@ int fit_find_config_node(const void *fdt)
 		return -EINVAL;
 	}
 
-	dflt_conf_name = fdt_getprop(fdt, conf, "default", &len);
+	dflt_conf_name = fdt_getprop(fdt, conf, FIT_DEFAULT_PROP, &len);
 
 	for (node = fdt_first_subnode(fdt, conf);
 	     node >= 0;
 	     node = fdt_next_subnode(fdt, node)) {
-		name = fdt_getprop(fdt, node, "description", &len);
+		name = fdt_getprop(fdt, node, FIT_DESC_PROP, &len);
 		if (!name) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 			printf("%s: Missing FDT description in DTB\n",
boot/image-fit.c +1 -1
index 41ab1f552b04d6a5731625ce8c03e17730f8d0cd..7c822a39fd85554a716d9cada54cbaf91b3ec24a 100644
@@ -1760,7 +1760,7 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
 			fdt = fit;		  /* search in FIT image */
 			compat_noffset = noffset; /* search under config node */
 		} else {	/* Otherwise extract it from the kernel FDT. */
-			kfdt_name = fdt_getprop(fit, noffset, "fdt", &len);
+			kfdt_name = fdt_getprop(fit, noffset, FIT_FDT_PROP, &len);
 			if (!kfdt_name) {
 				debug("No fdt property found.\n");
 				continue;
Signature · 1 line
2.49.0
#2 lore raw

RFC PATCH 2/4 lib: rsa: use FIT_ALGO_PROP constant instead of "algo" in FIT

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

Some FIT image properties have their string represented in include/image.h via constants. FIT_ALGO_PROP does exist and would fit the bill so let's use it instead of using a hardcoded string.

---
 lib/rsa/rsa-verify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rsa/rsa-verify.c +1 -1
index 4a0418a75f18e21e80612240aa626c0a240bc38c..e92767baae9bdac8bcaad41202f28e1fa6c23cf9 100644
@@ -448,7 +448,7 @@ static int rsa_verify_with_keynode(struct image_sign_info *info,
 		return -EBADF;
 	}
 
-	algo = fdt_getprop(blob, node, "algo", NULL);
+	algo = fdt_getprop(blob, node, FIT_ALGO_PROP, NULL);
 	if (!algo) {
 		debug("%s: Missing 'algo' property\n", __func__);
 		return -EFAULT;
Signature · 1 line
2.49.0
#3 lore raw

RFC PATCH 3/4 boot/fit: declare (and use) new constant for conf's compatible prop

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

Fit conf node may have a compatible property[1] which stores the root compatible of the first blob in the fdt property of the node. This can be used to automatically select the proper conf node based on the compatible from the running U-Boot (matching the former's compatible with the latter)[2].

This adds (and uses) this constant for FIT node parsing.

Note that this property may also appear in fpga image nodes[3] but that isn't done in this commit.

[1] https://fitspec.osfw.foundation/#optional-properties compatible paragraph
[2] https://fitspec.osfw.foundation/#select-a-configuration-to-boot
[3] https://fitspec.osfw.foundation/#images-node 2.3.2 Conditionally mandatory property

---
 boot/image-fit.c | 2 +-
 include/image.h  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
boot/image-fit.c +1 -1
index 7c822a39fd85554a716d9cada54cbaf91b3ec24a..52dbd7e96180da306da7f1516e8a3ab18a51ea33 100644
@@ -1756,7 +1756,7 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
 			continue;
 
 		/* If there's a compat property in the config node, use that. */
-		if (fdt_getprop(fit, noffset, "compatible", NULL)) {
+		if (fdt_getprop(fit, noffset, FIT_COMPAT_PROP, NULL)) {
 			fdt = fit;		  /* search in FIT image */
 			compat_noffset = noffset; /* search under config node */
 		} else {	/* Otherwise extract it from the kernel FDT. */
include/image.h +1 -0
index c1db8383459c9d7ce1ecc318ccccb4627a7066e5..c8286f2ffd32ed312f25d5d8cdc0a601f8e02f2f 100644
@@ -1103,6 +1103,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
 #define FIT_STANDALONE_PROP	"standalone"
 #define FIT_SCRIPT_PROP		"script"
 #define FIT_PHASE_PROP		"phase"
+#define FIT_COMPAT_PROP		"compatible"
 
 #define FIT_MAX_HASH_LEN	HASH_MAX_DIGEST_SIZE
 
Signature · 1 line
2.49.0
#4 lore raw

RFC PATCH 4/4 boot/fit: print all configuration node compatibles

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

Fit conf node may have a compatible property[1] which stores the compatible of the first blob in the fdt property of the node. This can be used to automatically select the proper conf node based on the compatible from the running U-Boot (matching the former's compatible with the latter)[2].

This brings the ability to mkimage/dumpimage to print the compatibles of the configuration node(s). U-Boot CLI commands such as iminfo also see this addition to their output.

[1] https://fitspec.osfw.foundation/#optional-properties compatible paragraph
[2] https://fitspec.osfw.foundation/#select-a-configuration-to-boot

---
 boot/image-fit.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
boot/image-fit.c +11 -0
index 52dbd7e96180da306da7f1516e8a3ab18a51ea33..4a3656c97a2c4ef8ca85177b08e3447baeed1877 100644
@@ -323,6 +323,17 @@ static void fit_conf_print(const void *fit, int noffset, const char *p)
 		printf("%s\n", uname);
 	}
 
+	for (fdt_index = 0;
+	     uname = fdt_stringlist_get(fit, noffset, FIT_COMPAT_PROP,
+					fdt_index, NULL), uname;
+	     fdt_index++) {
+		if (fdt_index == 0)
+			printf("%s  Compatible:   ", p);
+		else
+			printf("%s                ", p);
+		printf("%s\n", uname);
+	}
+
 	uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL);
 	if (uname)
 		printf("%s  FPGA:         %s\n", p, uname);
Signature · 1 line
2.49.0
#5 lore raw
In reply to Quentin Schulz

Hi all,

Quoted 9 lines · Quentin Schulz

This does a bit of "cleanup" by reusing constants for some FIT properties instead of having the same string in multiple places.

Additionally, this adds a new constant for the compatible property in FIT configuration nodes[1] which is useful for FIT images with multiple FIT configuration nodes to support multiple devices in the same blob. U-Boot will try to figure out which node to select based on that compatible[2].

Quoted 7 lines

However, if this property is missing (and the first blob in the fdt property of the configuration node is uncompressed), the compatible from the root node of the associated kernel FDT will be used for the autoselection mechanism. For now, I only print the property if it exists, but maybe it'd make sense to expose the fallback one if it's missing, hence the RFC state for this series.

Gentle ping. Any feedback on the series?

Cheers,
Quentin

#6 lore raw
In reply to Quentin Schulz

Hi all,

Quoted 9 lines · Quentin Schulz

This does a bit of "cleanup" by reusing constants for some FIT properties instead of having the same string in multiple places.

Additionally, this adds a new constant for the compatible property in FIT configuration nodes[1] which is useful for FIT images with multiple FIT configuration nodes to support multiple devices in the same blob. U-Boot will try to figure out which node to select based on that compatible[2].

Quoted 7 lines

However, if this property is missing (and the first blob in the fdt property of the configuration node is uncompressed), the compatible from the root node of the associated kernel FDT will be used for the autoselection mechanism. For now, I only print the property if it exists, but maybe it'd make sense to expose the fallback one if it's missing, hence the RFC state for this series.

Any feedback on this series?

It doesn't apply cleanly anymore but the conflict resolution is straightforward.

Cheers,
Quentin

#7 lore raw
Quoted 20 lines · Quentin Schulz

Hi all,

Quoted 9 lines · Quentin Schulz

This does a bit of "cleanup" by reusing constants for some FIT properties instead of having the same string in multiple places.

Additionally, this adds a new constant for the compatible property in FIT configuration nodes[1] which is useful for FIT images with multiple FIT configuration nodes to support multiple devices in the same blob. U-Boot will try to figure out which node to select based on that compatible[2].

Quoted 7 lines

However, if this property is missing (and the first blob in the fdt property of the configuration node is uncompressed), the compatible from the root node of the associated kernel FDT will be used for the autoselection mechanism. For now, I only print the property if it exists, but maybe it'd make sense to expose the fallback one if it's missing, hence the RFC state for this series.

Quoted 4 lines

Any feedback on this series?

It doesn't apply cleanly anymore but the conflict resolution is straightforward.

I probably marked it as RFC in patchwork. So, how about v1 non-RFC rebased on top of next? Thanks!

Signature · 1 line
Tom