From 634dcda25924567d000396542948fc33c7e8bc1a Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Wed, 3 Dec 2025 17:19:32 +0100 Subject: [PATCH 1/4] boot/fit: use constants for property strings Some properties have their string represented in include/image.h via constants, so let's use those constants instead of using a hardcoded string. Signed-off-by: Quentin Schulz --- boot/common_fit.c | 4 ++-- boot/image-fit.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/common_fit.c b/boot/common_fit.c index a2f9b8d83c3..fd434fe28e1 100644 --- a/boot/common_fit.c +++ b/boot/common_fit.c @@ -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", diff --git a/boot/image-fit.c b/boot/image-fit.c index cccaa48f683..0205637ed16 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -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; From 883359e152d5000943411ef7d2daaec6c137f47d Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Wed, 3 Dec 2025 17:19:33 +0100 Subject: [PATCH 2/4] lib: rsa: use FIT_ALGO_PROP constant instead of "algo" in FIT 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. Signed-off-by: Quentin Schulz --- lib/rsa/rsa-verify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index e7e612a4688..3169c3a6dd1 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -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; From 3059eb0c27dd1b4a40a06bda4a47e10246185aca Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Wed, 3 Dec 2025 17:19:34 +0100 Subject: [PATCH 3/4] boot/fit: declare (and use) new constant for conf's compatible prop 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 Signed-off-by: Quentin Schulz --- boot/image-fit.c | 2 +- include/image.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/image-fit.c b/boot/image-fit.c index 0205637ed16..c42b22ab02b 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -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. */ diff --git a/include/image.h b/include/image.h index 9a1c828416d..8dcf0cea25f 100644 --- a/include/image.h +++ b/include/image.h @@ -1105,6 +1105,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, #define FIT_SCRIPT_PROP "script" #define FIT_PHASE_PROP "phase" #define FIT_TFA_BL31_PROP "tfa-bl31" +#define FIT_COMPAT_PROP "compatible" #define FIT_MAX_HASH_LEN HASH_MAX_DIGEST_SIZE From 6c7d3ba292c648c9075eb0b82278a844bb1ff953 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Wed, 3 Dec 2025 17:19:35 +0100 Subject: [PATCH 4/4] boot/fit: print all configuration node compatibles 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 Signed-off-by: Quentin Schulz --- boot/image-fit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/boot/image-fit.c b/boot/image-fit.c index c42b22ab02b..cc7a4bb44dc 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -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);