public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sven Schwermer <sven@svenschwermer.de>
To: u-boot@lists.denx.de
Cc: Sven Schwermer <sven@svenschwermer.de>,
	Alexandru Gagniuc <mr.nuke.me@gmail.com>,
	Artem Lapkin <email2tema@gmail.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 1/2] cmd: source: Use script from default config
Date: Sat,  1 Jan 2022 19:45:39 +0100	[thread overview]
Message-ID: <20220101184540.42491-1-sven@svenschwermer.de> (raw)

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@svenschwermer.de>
---

(no changes since v1)

 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..b78cac7d5c 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.
  *
- * Return: Pointer to value of default property (or NULL)
+ * The default configuration is used unless board_fit_config_name_match
+ * is overridden.
+ *
+ * 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


             reply	other threads:[~2022-01-01 18:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 18:45 Sven Schwermer [this message]
2022-01-01 18:45 ` [PATCH v2 2/2] f_sdp: Retry sourcing default FIT script Sven Schwermer
2022-01-18 13:29 ` [PATCH v2 1/2] cmd: source: Use script from default config Tom Rini
2022-01-22 20:36   ` Sven Schwermer
2022-01-24 18:08     ` Tom Rini
2022-01-24 20:31       ` Sven Schwermer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220101184540.42491-1-sven@svenschwermer.de \
    --to=sven@svenschwermer.de \
    --cc=email2tema@gmail.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox