[PATCH 1/2] cmd: source: Use script from default config

Sven Schwermer sven at svenschwermer.de
Fri Dec 31 15:11:38 CET 2021


When sourcing FIT images, source the script node from the "bootscr"
property within the default configuration. If
board_fit_config_name_match is overridden, this will determine the
selected configuration rather than the default one.

The old behaviour is inconsistent with the FIT image specification which
does not mention a "default" property in the "/images" node.

Signed-off-by: Sven Schwermer <sven at svenschwermer.de>
---
 boot/Makefile   |  8 ++------
 cmd/source.c    | 22 +++++++++++++---------
 include/image.h |  1 +
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/boot/Makefile b/boot/Makefile
index 2938c3f145..51181b10fc 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -24,14 +24,10 @@ obj-$(CONFIG_ANDROID_AB) += android_ab.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
-obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
-obj-$(CONFIG_$(SPL_)MULTI_DTB_FIT) += boot_fit.o common_fit.o
+obj-$(CONFIG_$(SPL_TPL_)FIT) += common_fit.o image-fit.o
+obj-$(CONFIG_$(SPL_)MULTI_DTB_FIT) += boot_fit.o
 obj-$(CONFIG_$(SPL_TPL_)IMAGE_SIGN_INFO) += image-sig.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += image-fit-sig.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_CIPHER) += image-cipher.o
 
 obj-$(CONFIG_CMD_ADTIMG) += image-android-dt.o
-
-ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
-endif
diff --git a/cmd/source.c b/cmd/source.c
index 81e015b64e..a7d65ce377 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -26,19 +26,23 @@
 
 #if defined(CONFIG_FIT)
 /**
- * get_default_image() - Return default property from /images
+ * get_default_bootscr() - Return default boot script unit name.
+ * 
+ * The default configuration is used unless board_fit_config_name_match
+ * is overridden.
  *
- * Return: Pointer to value of default property (or NULL)
+ * Return: Pointer to value of bootscr property (or NULL)
  */
-static const char *get_default_image(const void *fit)
+static const char *get_default_bootscr(const void *fit)
 {
-	int images_noffset;
+	int noffset;
 
-	images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
-	if (images_noffset < 0)
+	/* get default or board-specific configuration node */
+	noffset = fit_find_config_node(fit);
+	if (noffset < 0)
 		return NULL;
 
-	return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL);
+	return fdt_getprop(fit, noffset, FIT_BOOTSCR_PROP, NULL);
 }
 #endif
 
@@ -113,7 +117,7 @@ int image_source_script(ulong addr, const char *fit_uname)
 		}
 
 		if (!fit_uname)
-			fit_uname = get_default_image(fit_hdr);
+			fit_uname = get_default_bootscr(fit_hdr);
 
 		if (!fit_uname) {
 			puts("No FIT subimage unit name\n");
@@ -128,7 +132,7 @@ int image_source_script(ulong addr, const char *fit_uname)
 		}
 
 		if (!fit_image_check_type (fit_hdr, noffset, IH_TYPE_SCRIPT)) {
-			puts ("Not a image image\n");
+			puts ("Not a script image\n");
 			return 1;
 		}
 
diff --git a/include/image.h b/include/image.h
index fd662e74b4..67c70952bd 100644
--- a/include/image.h
+++ b/include/image.h
@@ -936,6 +936,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
 #define FIT_KERNEL_PROP		"kernel"
 #define FIT_RAMDISK_PROP	"ramdisk"
 #define FIT_FDT_PROP		"fdt"
+#define FIT_BOOTSCR_PROP	"bootscr"
 #define FIT_LOADABLE_PROP	"loadables"
 #define FIT_DEFAULT_PROP	"default"
 #define FIT_SETUP_PROP		"setup"
-- 
2.34.1



More information about the U-Boot mailing list