All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: u-boot@lists.denx.de
Subject: [PATCH v4 3/9] spl: fit: Minimally parse OS properties with FIT_IMAGE_TINY
Date: Sat, 12 Sep 2020 16:35:39 -0500	[thread overview]
Message-ID: <20200912213545.64376-4-samuel@sholland.org> (raw)
In-Reply-To: <20200912213545.64376-1-samuel@sholland.org>

Some boards, specifically 64-bit Allwinner boards (sun50i), are
extremely limited on SPL size. One strategy that was used to make space
was to remove the FIT "os" property parsing code, because it uses a
rather large lookup table.

However, this forces the legacy FIT parsing code path, which requires
the "firmware" entry in the FIT to reference the U-Boot binary, even if
U-Boot is not the next binary in the boot sequence (for example, on
sun50i boards, ATF is run first).

This prevents the same FIT image from being used with a SPL with
CONFIG_SPL_FIT_IMAGE_TINY=n and CONFIG_SPL_ATF=y, because the boot
method selection code looks at `spl_image.os`, which is only set from
the "firmware" entry's "os" property.

To be able to use CONFIG_SPL_ATF=y, the "firmware" entry in the FIT
must be ATF, and U-Boot must be a loadable. For this to work, we need to
parse the "os" property just enough to tell U-Boot from other images, so
we can find it in the loadables list to append the FDT, and so we don't
try to append the FDT to ATF (which could clobber adjacent firmware).

So add the minimal code necessary to distinguish U-Boot/non-U-Boot
loadables with CONFIG_SPL_FIT_IMAGE_TINY=y. This adds about 300 bytes,
much less than the 7400 bytes added by CONFIG_SPL_FIT_IMAGE_TINY=n.

Acked-by: Patrick Wildt <patrick@blueri.se>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 common/spl/Kconfig   |  4 +---
 common/spl/spl_fit.c | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index af8255a8d6a..041b47244bd 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -465,9 +465,7 @@ config SPL_FIT_IMAGE_TINY
 	  Enable this to reduce the size of the FIT image loading code
 	  in SPL, if space for the SPL binary is very tight.
 
-	  This removes the detection of image types (which forces the
-	  first image to be treated as having a U-Boot style calling
-	  convention) and skips the recording of each loaded payload
+	  This skips the recording of each loaded payload
 	  (i.e. loadable) into the FDT (modifying the loaded FDT to
 	  ensure this information is available to the next image
 	  invoked).
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 365104fe028..a31ab6c5992 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -466,7 +466,22 @@ static int spl_fit_record_loadable(const void *fit, int images, int index,
 static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
 {
 #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT)
-	return -ENOTSUPP;
+	const char *name = fdt_getprop(fit, noffset, FIT_OS_PROP, NULL);
+
+	if (!name)
+		return -ENOENT;
+
+	/*
+	 * We don't care what the type of the image actually is,
+	 * only whether or not it is U-Boot. This saves some
+	 * space by omitting the large table of OS types.
+	 */
+	if (!strcmp(name, "u-boot"))
+		*os = IH_OS_U_BOOT;
+	else
+		*os = IH_OS_INVALID;
+
+	return 0;
 #else
 	return fit_image_get_os(fit, noffset, os);
 #endif
-- 
2.26.2

  parent reply	other threads:[~2020-09-12 21:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 21:35 [PATCH v4 0/9] sunxi: binman fixes and SCP firmware support Samuel Holland
2020-09-12 21:35 ` [PATCH v4 1/9] Makefile: Only define u-boot.itb rule when applicable Samuel Holland
2020-09-12 21:35 ` [PATCH v4 2/9] binman: Only write FDT once per node Samuel Holland
2020-09-12 21:35 ` Samuel Holland [this message]
2020-09-12 21:35 ` [PATCH v4 4/9] sunxi: binman: Fix spacing between nodes Samuel Holland
2020-09-12 21:35 ` [PATCH v4 5/9] sunxi: binman: Provide a default BL31 filename Samuel Holland
2020-10-21 18:49   ` Jagan Teki
2020-10-22  1:53     ` Samuel Holland
2020-09-12 21:35 ` [PATCH v4 6/9] sunxi: binman: Use a macro for the BL31 load address Samuel Holland
2020-09-12 21:35 ` [PATCH v4 7/9] sunxi: binman: Update FIT component descriptions Samuel Holland
2020-09-12 21:35 ` [PATCH v4 8/9] binman: Add support for SCP firmware Samuel Holland
2020-09-28  4:24   ` Simon Glass
2020-09-12 21:35 ` [PATCH v4 9/9] sunxi: binman: Add support for including " Samuel Holland

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=20200912213545.64376-4-samuel@sholland.org \
    --to=samuel@sholland.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.