U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/19] vbe: Series part E
@ 2024-12-19 18:28 Simon Glass
  2024-12-19 18:28 ` [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug Simon Glass
                   ` (19 more replies)
  0 siblings, 20 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alex Shumsky, Caleb Connolly, Devarsh Thakkar,
	Dragan Simic, Gary Bisson, Heinrich Schuchardt, Igor Opaniuk,
	Ilias Apalodimas, Jaehoon Chung, Jagan Teki, Jerome Forissier,
	Jiaxun Yang, Joe Hershberger, Joshua Watt, Julien Masson,
	Laurent Pinchart, Leo Yu-Chi Liang, Lukas Funke, Marek Vasut,
	Marek Vasut, Mathieu Othacehe, Mattijs Korpershoek,
	Maxim Moskalets, Michael Trimarchi, Michal Simek, Nam Cao,
	Patrick Rudolph, Paul-Erwan Rio, Peng Fan, Quentin Schulz,
	Raymond Mao, Roman Stratiienko, Sean Anderson, Stefan Roese,
	Sughosh Ganu, Thomas Weißschuh, Tim Harvey, Tom Rini


This includes various patches towards implementing the VBE abrec
bootmeth in U-Boot. It mostly focuses on SPL tweaks and adjusting what
fatures are available in VPL.

Changes in v4:
- Add an option to avoid code bloat with rcar3_salvator-x for example

Changes in v3:
- Add new patch to avoid size growth in spl_mmc_find_device() debug
- Use strlcpy() instead of strncpy()
- Rebase to master

Changes in v2:
- Add field names into the message
- Fix 'depends on SPL' to depend on TPL
- Depend on TPL/VPL as well
- Drop patch 'serial: ns16550: Allow clocks to be missing'

Simon Glass (19):
  spl: mmc: Avoid size growth in spl_mmc_find_device() debug
  image: Add a prototype for fit_image_get_phase()
  boot: Allow FIT to fall back from best-match option
  bootstd: Avoid sprintf() in SPL when creating bootdevs
  boot: Respect the load_op in fit_image_load()
  malloc: Show amount of used space when memory runs out
  malloc: Provide a simple malloc for VPL
  Support setting a maximum size for the VPL image
  spl: Report a loader failure
  spl: Allow serial to be disabled in any XPL phase
  spl: Support a relocated stack in any XPL phase
  spl: Drop use of uintptr_t
  spl: Drop a duplicate variable in boot_from_devices()
  spl: Add some more debugging to load_simple_fit()
  spl: lib: Allow for decompression in any SPL build
  boot: Allow use of FIT in TPL and VPL
  lib: Allow crc8 in TPL and VPL
  boot: Imply CRC8 with VBE
  hash: Plumb crc8 into the hash functions

 boot/Kconfig                  | 71 ++++++++++++++++++++++++++++++++++-
 boot/bootdev-uclass.c         | 10 ++++-
 boot/image-fit.c              | 29 ++++++++------
 common/Kconfig                |  8 ++++
 common/hash.c                 |  8 ++++
 common/malloc_simple.c        |  3 +-
 common/spl/Kconfig.vpl        | 17 +++++++++
 common/spl/spl.c              | 15 +++++---
 common/spl/spl_atf.c          | 36 +++++++++---------
 common/spl/spl_fit.c          | 12 +++++-
 common/spl/spl_legacy.c       |  8 ++--
 common/spl/spl_mmc.c          |  6 ++-
 configs/sandbox_vpl_defconfig |  2 +
 include/image.h               | 16 +++++++-
 include/spl.h                 | 28 +++++++-------
 include/u-boot/crc.h          |  3 ++
 lib/Kconfig                   | 53 ++++++++++++++++++++++++++
 lib/Makefile                  | 12 +++---
 lib/crc8.c                    |  6 +++
 19 files changed, 275 insertions(+), 68 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-22 23:47   ` Jaehoon Chung
  2024-12-19 18:28 ` [PATCH v4 02/19] image: Add a prototype for fit_image_get_phase() Simon Glass
                   ` (18 subsequent siblings)
  19 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Jaehoon Chung, Peng Fan, Quentin Schulz,
	Sean Anderson, Tim Harvey, Tom Rini

The for() loop ends up being in the code even if the log_debug() does
nothing. Add a condition to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v3)

Changes in v3:
- Add new patch to avoid size growth in spl_mmc_find_device() debug

 common/spl/spl_mmc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 1f696593216..fe4230170a0 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -81,8 +81,10 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)
 	struct uclass *uc;
 
 	log_debug("Selecting MMC dev %d; seqs:\n", mmc_dev);
-	uclass_id_foreach_dev(UCLASS_MMC, dev, uc)
-		log_debug("%d: %s\n", dev_seq(dev), dev->name);
+	if (_LOG_DEBUG) {
+		uclass_id_foreach_dev(UCLASS_MMC, dev, uc)
+			log_debug("%d: %s\n", dev_seq(dev), dev->name);
+	}
 	ret = mmc_init_device(mmc_dev);
 #else
 	ret = mmc_initialize(NULL);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 02/19] image: Add a prototype for fit_image_get_phase()
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
  2024-12-19 18:28 ` [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 03/19] boot: Allow FIT to fall back from best-match option Simon Glass
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Joe Hershberger, Julien Masson, Marek Vasut,
	Marek Vasut, Mattijs Korpershoek, Maxim Moskalets, Paul-Erwan Rio,
	Roman Stratiienko, Sughosh Ganu, Tom Rini

This function exists but is not exported. Add a prototype so it can be
used elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 include/image.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/image.h b/include/image.h
index 9be5acd8158..bb15ef69871 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1171,6 +1171,18 @@ int fit_image_get_data_size_unciphered(const void *fit, int noffset,
 int fit_image_get_data_and_size(const void *fit, int noffset,
 				const void **data, size_t *size);
 
+/**
+ * fit_image_get_phase() - Get the phase from a FIT image
+ *
+ * @fit: FIT to read from
+ * @offset: offset node to read
+ * @phasep: Returns phase, if any
+ * Return: 0 if read OK and *phasep is value, -ENOENT if there was no phase
+ * property in the node, other -ve value on other error
+ */
+int fit_image_get_phase(const void *fit, int offset,
+			enum image_phase_t *phasep);
+
 /**
  * fit_get_data_node() - Get verified image data for an image
  * @fit: Pointer to the FIT format image header
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 03/19] boot: Allow FIT to fall back from best-match option
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
  2024-12-19 18:28 ` [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug Simon Glass
  2024-12-19 18:28 ` [PATCH v4 02/19] image: Add a prototype for fit_image_get_phase() Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 04/19] bootstd: Avoid sprintf() in SPL when creating bootdevs Simon Glass
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Igor Opaniuk, Ilias Apalodimas, Julien Masson,
	Laurent Pinchart, Marek Vasut, Mattijs Korpershoek,
	Maxim Moskalets, Raymond Mao, Roman Stratiienko, Sughosh Ganu,
	Tom Rini

When the best-match feature fails to find something, use the provided
config name as a fallback. The allows SPL to select a suitable config
when best-match is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 boot/image-fit.c | 19 ++++++++++---------
 include/image.h  |  4 +++-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/boot/image-fit.c b/boot/image-fit.c
index 7d56f0b5e6e..439ff51edf6 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -1729,13 +1729,13 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
 	images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
 	if (confs_noffset < 0 || images_noffset < 0) {
 		debug("Can't find configurations or images nodes.\n");
-		return -1;
+		return -EINVAL;
 	}
 
 	fdt_compat = fdt_getprop(fdt, 0, "compatible", &fdt_compat_len);
 	if (!fdt_compat) {
 		debug("Fdt for comparison has no \"compatible\" property.\n");
-		return -1;
+		return -ENXIO;
 	}
 
 	/*
@@ -1812,7 +1812,7 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
 	}
 	if (!best_match_offset) {
 		debug("No match found.\n");
-		return -1;
+		return -ENOENT;
 	}
 
 	return best_match_offset;
@@ -2095,17 +2095,18 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
 		 * fit_conf_get_node() will try to find default config node
 		 */
 		bootstage_mark(bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME);
-		if (IS_ENABLED(CONFIG_FIT_BEST_MATCH) && !fit_uname_config) {
-			cfg_noffset = fit_conf_find_compat(fit, gd_fdt_blob());
-		} else {
-			cfg_noffset = fit_conf_get_node(fit, fit_uname_config);
-		}
-		if (cfg_noffset < 0) {
+		ret = -ENXIO;
+		if (IS_ENABLED(CONFIG_FIT_BEST_MATCH) && !fit_uname_config)
+			ret = fit_conf_find_compat(fit, gd_fdt_blob());
+		if (ret < 0 && ret != -EINVAL)
+			ret = fit_conf_get_node(fit, fit_uname_config);
+		if (ret < 0) {
 			puts("Could not find configuration node\n");
 			bootstage_error(bootstage_id +
 					BOOTSTAGE_SUB_NO_UNIT_NAME);
 			return -ENOENT;
 		}
+		cfg_noffset = ret;
 
 		fit_base_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
 		printf("   Using '%s' configuration\n", fit_base_uname_config);
diff --git a/include/image.h b/include/image.h
index bb15ef69871..ab96510f62c 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1411,7 +1411,9 @@ int fit_check_format(const void *fit, ulong size);
  * copied into the configuration node in the FIT image. This is required to
  * match configurations with compressed FDTs.
  *
- * Returns: offset to the configuration to use if one was found, -1 otherwise
+ * Returns: offset to the configuration to use if one was found, -EINVAL if
+ * there a /configurations or /images node is missing, -ENOENT if no match was
+ * found, -ENXIO if the FDT node has no compatible string
  */
 int fit_conf_find_compat(const void *fit, const void *fdt);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 04/19] bootstd: Avoid sprintf() in SPL when creating bootdevs
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (2 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 03/19] boot: Allow FIT to fall back from best-match option Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 05/19] boot: Respect the load_op in fit_image_load() Simon Glass
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Caleb Connolly, Dragan Simic, Nam Cao,
	Thomas Weißschuh, Tom Rini

The name of the bootdev device is not that important, particular in SPL.
Save a little code space by using a simpler name.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v3)

Changes in v3:
- Use strlcpy() instead of strncpy()

 boot/bootdev-uclass.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 64ec4fde493..2e61c853142 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <part.h>
 #include <sort.h>
+#include <spl.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
@@ -278,8 +279,13 @@ int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
 	int ret, len;
 
 	len = bootdev_get_suffix_start(blk, ".blk");
-	snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
-		 "bootdev");
+	if (xpl_phase() < PHASE_BOARD_R) {
+		strlcpy(dev_name, blk->name, sizeof(dev_name) - 5);
+		strcat(dev_name, ".sib");
+	} else {
+		snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
+			 "bootdev");
+	}
 
 	parent = dev_get_parent(blk);
 	ret = device_find_child_by_name(parent, dev_name, &dev);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 05/19] boot: Respect the load_op in fit_image_load()
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (3 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 04/19] bootstd: Avoid sprintf() in SPL when creating bootdevs Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 06/19] malloc: Show amount of used space when memory runs out Simon Glass
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Igor Opaniuk, Ilias Apalodimas, Maxim Moskalets,
	Raymond Mao, Tom Rini

Some code has crept in which ignores this parameter. Fix this and add a
little debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 boot/image-fit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/boot/image-fit.c b/boot/image-fit.c
index 439ff51edf6..db7fb61bca9 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2226,6 +2226,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
 	data = map_to_sysmem(buf);
 	load = data;
 	if (load_op == FIT_LOAD_IGNORED) {
+		log_debug("load_op: not loading\n");
 		/* Don't load */
 	} else if (fit_image_get_load(fit, noffset, &load)) {
 		if (load_op == FIT_LOAD_REQUIRED) {
@@ -2262,10 +2263,13 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
 	/* Kernel images get decompressed later in bootm_load_os(). */
 	if (!fit_image_get_comp(fit, noffset, &comp) &&
 	    comp != IH_COMP_NONE &&
+	    load_op != FIT_LOAD_IGNORED &&
 	    !(image_type == IH_TYPE_KERNEL ||
 	      image_type == IH_TYPE_KERNEL_NOLOAD ||
 	      image_type == IH_TYPE_RAMDISK)) {
 		ulong max_decomp_len = len * 20;
+
+		log_debug("decompressing image\n");
 		if (load == data) {
 			loadbuf = malloc(max_decomp_len);
 			load = map_to_sysmem(loadbuf);
@@ -2280,6 +2284,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
 		}
 		len = load_end - load;
 	} else if (load != data) {
+		log_debug("copying\n");
 		loadbuf = map_sysmem(load, len);
 		memcpy(loadbuf, buf, len);
 	}
@@ -2289,8 +2294,9 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
 		     " please fix your .its file!\n");
 
 	/* verify that image data is a proper FDT blob */
-	if (image_type == IH_TYPE_FLATDT && fdt_check_header(loadbuf)) {
-		puts("Subimage data is not a FDT");
+	if (load_op != FIT_LOAD_IGNORED && image_type == IH_TYPE_FLATDT &&
+	    fdt_check_header(loadbuf)) {
+		puts("Subimage data is not a FDT\n");
 		return -ENOEXEC;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 06/19] malloc: Show amount of used space when memory runs out
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (4 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 05/19] boot: Respect the load_op in fit_image_load() Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 07/19] malloc: Provide a simple malloc for VPL Simon Glass
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Tom Rini

Show a bit more information when malloc() space is exhausted and
debugging is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Add field names into the message

 common/malloc_simple.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 5a8ec538f8f..f0f90a095bd 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
 	log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
 		  gd->malloc_limit);
 	if (new_ptr > gd->malloc_limit) {
-		log_err("alloc space exhausted\n");
+		log_err("alloc space exhausted ptr %lx limit %x\n", new_ptr,
+			gd->malloc_limit);
 		return NULL;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 07/19] malloc: Provide a simple malloc for VPL
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (5 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 06/19] malloc: Show amount of used space when memory runs out Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 08/19] Support setting a maximum size for the VPL image Simon Glass
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Gary Bisson, Mathieu Othacehe, Peng Fan, Tom Rini

The VPL phase may want to use the smaller malloc() implementation, so
add an option for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/Kconfig.vpl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/common/spl/Kconfig.vpl b/common/spl/Kconfig.vpl
index d06f36d4ee4..3dc0e95e09f 100644
--- a/common/spl/Kconfig.vpl
+++ b/common/spl/Kconfig.vpl
@@ -222,6 +222,15 @@ config VPL_SPI_FLASH_SUPPORT
 	  lines). This enables the drivers in drivers/mtd/spi as part of a
 	  VPL build. This normally requires VPL_SPI_SUPPORT.
 
+config VPL_SYS_MALLOC_SIMPLE
+	bool "Only use malloc_simple functions in the VPL"
+	default y
+	help
+	  Say Y here to only use the *_simple malloc functions from
+	  malloc_simple.c, rather then using the versions from dlmalloc.c;
+	  this will make the VPL binary smaller at the cost of more heap
+	  usage as the *_simple malloc functions do not re-use free-ed mem.
+
 config VPL_TEXT_BASE
 	hex "VPL Text Base"
 	default 0x0
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 08/19] Support setting a maximum size for the VPL image
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (6 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 07/19] malloc: Provide a simple malloc for VPL Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 09/19] spl: Report a loader failure Simon Glass
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Gary Bisson, Mathieu Othacehe, Peng Fan, Tom Rini

Add a size limit for VPL, to match those for SPL and TPL

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/Kconfig.vpl | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/spl/Kconfig.vpl b/common/spl/Kconfig.vpl
index 3dc0e95e09f..eb57dfabea5 100644
--- a/common/spl/Kconfig.vpl
+++ b/common/spl/Kconfig.vpl
@@ -237,6 +237,14 @@ config VPL_TEXT_BASE
 	help
 	  The address in memory that VPL will be running from.
 
+config VPL_MAX_SIZE
+	hex "Maximum size (in bytes) for the VPL stage"
+	default 0x2e000 if ROCKCHIP_RK3399
+	default 0x0
+	help
+	  The maximum size (in bytes) of the TPL stage. This size is determined
+	  by the amount of internal SRAM memory.
+
 config VPL_BINMAN_SYMBOLS
 	bool "Declare binman symbols in VPL"
 	depends on VPL_FRAMEWORK && BINMAN
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 09/19] spl: Report a loader failure
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (7 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 08/19] Support setting a maximum size for the VPL image Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 10/19] spl: Allow serial to be disabled in any XPL phase Simon Glass
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Devarsh Thakkar, Ilias Apalodimas, Quentin Schulz,
	Sean Anderson, Sughosh Ganu, Tom Rini

If a loader returns an error code it is silently ignored. Show a message
to at least provide some feedback to the user.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/spl.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 1ceb63daf31..7c57eb8539b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -612,6 +612,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 	for (i = 0; i < count && spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
 		struct spl_image_loader *loader;
 		int bootdev = spl_boot_list[i];
+		int ret;
 
 		if (CONFIG_IS_ENABLED(SHOW_ERRORS))
 			ret = -ENXIO;
@@ -631,10 +632,13 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 					     "Unsupported Boot Device!\n");
 				}
 			}
-			if (loader &&
-				!spl_load_image(spl_image, loader)) {
-				spl_image->boot_device = bootdev;
-				return 0;
+			if (loader) {
+				ret = spl_load_image(spl_image, loader);
+				if (!ret) {
+					spl_image->boot_device = bootdev;
+					return 0;
+				}
+				printf("Error: %d\n", ret);
 			}
 		}
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 10/19] spl: Allow serial to be disabled in any XPL phase
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (8 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 09/19] spl: Report a loader failure Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:28 ` [PATCH v4 11/19] spl: Support a relocated stack " Simon Glass
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Devarsh Thakkar, Quentin Schulz, Sean Anderson,
	Sughosh Ganu, Tom Rini

The current check looks only at SPL, but TPL or VPL might have a
different setting. Update the condition.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7c57eb8539b..91ee07f7079 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -837,7 +837,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
  */
 void preloader_console_init(void)
 {
-#ifdef CONFIG_SPL_SERIAL
+#if CONFIG_IS_ENABLED(SERIAL)
 	gd->baudrate = CONFIG_BAUDRATE;
 
 	serial_init();		/* serial communications setup */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 11/19] spl: Support a relocated stack in any XPL phase
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (9 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 10/19] spl: Allow serial to be disabled in any XPL phase Simon Glass
@ 2024-12-19 18:28 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 12/19] spl: Drop use of uintptr_t Simon Glass
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:28 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Devarsh Thakkar, Ilias Apalodimas, Quentin Schulz,
	Sean Anderson, Sughosh Ganu, Tom Rini

The current check looks only at SPL, but TPL or VPL might have a
different setting. Update the condition.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 91ee07f7079..702920bd2f7 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -896,7 +896,7 @@ __weak void spl_relocate_stack_check(void)
  */
 ulong spl_relocate_stack_gd(void)
 {
-#ifdef CONFIG_SPL_STACK_R
+#if CONFIG_IS_ENABLED(STACK_R)
 	gd_t *new_gd;
 	ulong ptr = CONFIG_SPL_STACK_R_ADDR;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 12/19] spl: Drop use of uintptr_t
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (10 preceding siblings ...)
  2024-12-19 18:28 ` [PATCH v4 11/19] spl: Support a relocated stack " Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 13/19] spl: Drop a duplicate variable in boot_from_devices() Simon Glass
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Devarsh Thakkar, Heinrich Schuchardt,
	Leo Yu-Chi Liang, Lukas Funke, Marek Vasut, Michael Trimarchi,
	Quentin Schulz, Sean Anderson, Tom Rini

U-Boot uses ulong for addresses. It is confusing to use uintptr_t in a
few places, since it makes people wonder if the types are compatible.
Change the few occurences in SPL to use ulong

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/spl_atf.c    | 36 ++++++++++++++++++------------------
 common/spl/spl_fit.c    |  2 +-
 common/spl/spl_legacy.c |  8 ++++----
 include/spl.h           | 28 ++++++++++++++--------------
 4 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c
index 0397b86a33b..8bc5db77395 100644
--- a/common/spl/spl_atf.c
+++ b/common/spl/spl_atf.c
@@ -41,9 +41,9 @@ struct bl2_to_bl31_params_mem_v2 {
 	struct entry_point_info bl31_ep_info;
 };
 
-struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry,
-						     uintptr_t bl33_entry,
-						     uintptr_t fdt_addr)
+struct bl31_params *bl2_plat_get_bl31_params_default(ulong bl32_entry,
+						     ulong bl33_entry,
+						     ulong fdt_addr)
 {
 	static struct bl2_to_bl31_params_mem bl31_params_mem;
 	struct bl31_params *bl2_to_bl31_params;
@@ -100,17 +100,17 @@ struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry,
 	return bl2_to_bl31_params;
 }
 
-__weak struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
-						    uintptr_t bl33_entry,
-						    uintptr_t fdt_addr)
+__weak struct bl31_params *bl2_plat_get_bl31_params(ulong bl32_entry,
+						    ulong bl33_entry,
+						    ulong fdt_addr)
 {
 	return bl2_plat_get_bl31_params_default(bl32_entry, bl33_entry,
 						fdt_addr);
 }
 
-struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry,
-						      uintptr_t bl33_entry,
-						      uintptr_t fdt_addr)
+struct bl_params *bl2_plat_get_bl31_params_v2_default(ulong bl32_entry,
+						      ulong bl33_entry,
+						      ulong fdt_addr)
 {
 	static struct bl2_to_bl31_params_mem_v2 bl31_params_mem;
 	struct bl_params *bl_params;
@@ -173,9 +173,9 @@ struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry,
 	return bl_params;
 }
 
-__weak struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
-						     uintptr_t bl33_entry,
-						     uintptr_t fdt_addr)
+__weak struct bl_params *bl2_plat_get_bl31_params_v2(ulong bl32_entry,
+						     ulong bl33_entry,
+						     ulong fdt_addr)
 {
 	return bl2_plat_get_bl31_params_v2_default(bl32_entry, bl33_entry,
 						   fdt_addr);
@@ -188,8 +188,8 @@ static inline void raw_write_daif(unsigned int daif)
 
 typedef void __noreturn (*atf_entry_t)(struct bl31_params *params, void *plat_params);
 
-static void __noreturn bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
-				  uintptr_t bl33_entry, uintptr_t fdt_addr)
+static void __noreturn bl31_entry(ulong bl31_entry, ulong bl32_entry,
+				  ulong bl33_entry, ulong fdt_addr)
 {
 	atf_entry_t  atf_entry = (atf_entry_t)bl31_entry;
 	void *bl31_params;
@@ -238,7 +238,7 @@ static int spl_fit_images_find(void *blob, int os)
 	return -FDT_ERR_NOTFOUND;
 }
 
-uintptr_t spl_fit_images_get_entry(void *blob, int node)
+ulong spl_fit_images_get_entry(void *blob, int node)
 {
 	ulong  val;
 	int ret;
@@ -253,10 +253,10 @@ uintptr_t spl_fit_images_get_entry(void *blob, int node)
 
 void __noreturn spl_invoke_atf(struct spl_image_info *spl_image)
 {
-	uintptr_t  bl32_entry = 0;
-	uintptr_t  bl33_entry = CONFIG_TEXT_BASE;
+	ulong  bl32_entry = 0;
+	ulong  bl33_entry = CONFIG_TEXT_BASE;
 	void *blob = spl_image->fdt_addr;
-	uintptr_t platform_param = (uintptr_t)blob;
+	ulong platform_param = (ulong)blob;
 	int node;
 
 	/*
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 3160f573bfb..ef40a50082c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -862,7 +862,7 @@ int spl_load_fit_image(struct spl_image_info *spl_image,
 {
 	struct bootm_headers images;
 	const char *fit_uname_config = NULL;
-	uintptr_t fdt_hack;
+	ulong fdt_hack;
 	const char *uname;
 	ulong fw_data = 0, dt_data = 0, img_data = 0;
 	ulong fw_len = 0, dt_len = 0, img_len = 0;
diff --git a/common/spl/spl_legacy.c b/common/spl/spl_legacy.c
index 9252b3a3de0..b3efb3e630e 100644
--- a/common/spl/spl_legacy.c
+++ b/common/spl/spl_legacy.c
@@ -16,11 +16,11 @@
 
 #define LZMA_LEN	(1 << 20)
 
-static void spl_parse_legacy_validate(uintptr_t start, uintptr_t size)
+static void spl_parse_legacy_validate(ulong start, ulong size)
 {
-	uintptr_t spl_start = (uintptr_t)_start;
-	uintptr_t spl_end = (uintptr_t)&_image_binary_end;
-	uintptr_t end = start + size;
+	ulong spl_start = (ulong)_start;
+	ulong spl_end = (ulong)&_image_binary_end;
+	ulong end = start + size;
 
 	if ((start >= spl_start && start < spl_end) ||
 	    (end > spl_start && end <= spl_end) ||
diff --git a/include/spl.h b/include/spl.h
index 269e36bb441..43b344dbc55 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -268,8 +268,8 @@ enum spl_sandbox_flags {
 struct spl_image_info {
 	const char *name;
 	u8 os;
-	uintptr_t load_addr;
-	uintptr_t entry_point;
+	ulong load_addr;
+	ulong entry_point;
 #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
 	void *fdt_addr;
 #endif
@@ -951,9 +951,9 @@ void __noreturn spl_invoke_atf(struct spl_image_info *spl_image);
  *
  * Return: bl31 params structure pointer
  */
-struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
-					     uintptr_t bl33_entry,
-					     uintptr_t fdt_addr);
+struct bl31_params *bl2_plat_get_bl31_params(ulong bl32_entry,
+					     ulong bl33_entry,
+					     ulong fdt_addr);
 
 /**
  * bl2_plat_get_bl31_params_default() - prepare params for bl31.
@@ -972,9 +972,9 @@ struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
  *
  * Return: bl31 params structure pointer
  */
-struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry,
-						     uintptr_t bl33_entry,
-						     uintptr_t fdt_addr);
+struct bl31_params *bl2_plat_get_bl31_params_default(ulong bl32_entry,
+						     ulong bl33_entry,
+						     ulong fdt_addr);
 
 /**
  * bl2_plat_get_bl31_params_v2() - return params for bl31
@@ -988,9 +988,9 @@ struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry,
  *
  * Return: bl31 params structure pointer
  */
-struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
-					      uintptr_t bl33_entry,
-					      uintptr_t fdt_addr);
+struct bl_params *bl2_plat_get_bl31_params_v2(ulong bl32_entry,
+					      ulong bl33_entry,
+					      ulong fdt_addr);
 
 /**
  * bl2_plat_get_bl31_params_v2_default() - prepare params for bl31.
@@ -1007,9 +1007,9 @@ struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
  *
  * Return: bl31 params structure pointer
  */
-struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry,
-						      uintptr_t bl33_entry,
-						      uintptr_t fdt_addr);
+struct bl_params *bl2_plat_get_bl31_params_v2_default(ulong bl32_entry,
+						      ulong bl33_entry,
+						      ulong fdt_addr);
 /**
  * spl_optee_entry - entry function for optee
  *
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 13/19] spl: Drop a duplicate variable in boot_from_devices()
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (11 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 12/19] spl: Drop use of uintptr_t Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 14/19] spl: Add some more debugging to load_simple_fit() Simon Glass
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Devarsh Thakkar, Ilias Apalodimas, Quentin Schulz,
	Sean Anderson, Sughosh Ganu, Tom Rini

The variable 'ret' is defined twice, which is not intended. This may
have been a local merge error.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 2eefeb6d893 ("spl: Report a loader failure")
---

(no changes since v1)

 common/spl/spl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 702920bd2f7..ad31a2f8b6c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -612,7 +612,6 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 	for (i = 0; i < count && spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
 		struct spl_image_loader *loader;
 		int bootdev = spl_boot_list[i];
-		int ret;
 
 		if (CONFIG_IS_ENABLED(SHOW_ERRORS))
 			ret = -ENXIO;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 14/19] spl: Add some more debugging to load_simple_fit()
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (12 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 13/19] spl: Drop a duplicate variable in boot_from_devices() Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 15/19] spl: lib: Allow for decompression in any SPL build Simon Glass
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Leo Yu-Chi Liang, Tom Rini

Add debugging of image-loading progress. Fix a stale comment in the
function comment while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/spl_fit.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index ef40a50082c..ac8462577ff 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -190,7 +190,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 /**
  * load_simple_fit(): load the image described in a certain FIT node
  * @info:	points to information about the device to load data from
- * @sector:	the start sector of the FIT image on the device
+ * @fit_offset:	the offset of the FIT image on the device
  * @ctx:	points to the FIT context structure
  * @node:	offset of the DT node describing the image to load (relative
  *		to @fit)
@@ -243,11 +243,14 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 	if (!fit_image_get_data_position(fit, node, &offset)) {
 		external_data = true;
 	} else if (!fit_image_get_data_offset(fit, node, &offset)) {
+		log_debug("read offset %x = offset from fit %lx\n",
+			  offset, (ulong)offset + ctx->ext_data_offset);
 		offset += ctx->ext_data_offset;
 		external_data = true;
 	}
 
 	if (external_data) {
+		ulong read_offset;
 		void *src_ptr;
 
 		/* External data */
@@ -270,6 +273,10 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 
 		overhead = get_aligned_image_overhead(info, offset);
 		size = get_aligned_image_size(info, length, offset);
+		read_offset = fit_offset + get_aligned_image_offset(info,
+							    offset);
+		log_debug("reading from offset %x / %lx size %lx to %p: ",
+			  offset, read_offset, size, src_ptr);
 
 		if (info->read(info,
 			       fit_offset +
@@ -336,6 +343,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 		else
 			image_info->entry_point = FDT_ERROR;
 	}
+	log_debug("- done loading\n");
 
 	upl_add_image(fit, node, load_addr, length);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 15/19] spl: lib: Allow for decompression in any SPL build
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (13 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 14/19] spl: Add some more debugging to load_simple_fit() Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 16/19] boot: Allow use of FIT in TPL and VPL Simon Glass
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Michal Simek, Patrick Rudolph, Raymond Mao,
	Sughosh Ganu, Tom Rini

Add Kconfig symbols and update the Makefile rules so that decompression
can be used in TPL and VPL

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/Kconfig  | 35 +++++++++++++++++++++++++++++++++++
 lib/Makefile | 12 ++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 0b089814d14..203f40e2662 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -841,12 +841,36 @@ config SPL_LZ4
 	  fast compression and decompression speed. It belongs to the LZ77
 	  family of byte-oriented compression schemes.
 
+config TPL_LZ4
+	bool "Enable LZ4 decompression support in TPL"
+	depends on TPL
+	help
+	  This enables support for the LZ4 decompression algorithm in TPL. LZ4
+	  is a lossless data compression algorithm that is focused on
+	  fast compression and decompression speed. It belongs to the LZ77
+	  family of byte-oriented compression schemes.
+
+config VPL_LZ4
+	bool "Enable LZ4 decompression support in VPL"
+	depends on VPL
+	help
+	  This enables support for the LZ4 decompression algorithm in VPL. LZ4
+	  is a lossless data compression algorithm that is focused on
+	  fast compression and decompression speed. It belongs to the LZ77
+	  family of byte-oriented compression schemes.
+
 config SPL_LZMA
 	bool "Enable LZMA decompression support for SPL build"
 	depends on SPL
 	help
 	  This enables support for LZMA compression algorithm for SPL boot.
 
+config TPL_LZMA
+	bool "Enable LZMA decompression support for TPL build"
+	depends on TPL
+	help
+	  This enables support for LZMA compression algorithm for TPL boot.
+
 config VPL_LZMA
 	bool "Enable LZMA decompression support for VPL build"
 	default y if LZMA
@@ -865,11 +889,22 @@ config SPL_GZIP
 	help
 	  This enables support for the GZIP compression algorithm for SPL boot.
 
+config TPL_GZIP
+	bool "Enable gzip decompression support for SPL build"
+	select TPL_ZLIB
+	help
+	  This enables support for the GZIP compression algorithm for TPL
+
 config SPL_ZLIB
 	bool
 	help
 	  This enables compression lib for SPL boot.
 
+config TPL_ZLIB
+	bool
+	help
+	  This enables compression lib for TPL
+
 config SPL_ZSTD
 	bool "Enable Zstandard decompression support in SPL"
 	depends on SPL
diff --git a/lib/Makefile b/lib/Makefile
index d24ed629732..5cb3278d2ef 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -83,12 +83,12 @@ obj-$(CONFIG_$(XPL_)SHA512_LEGACY) += sha512.o
 obj-$(CONFIG_CRYPT_PW) += crypt/
 obj-$(CONFIG_$(XPL_)ASN1_DECODER_LEGACY) += asn1_decoder.o
 
-obj-$(CONFIG_$(XPL_)ZLIB) += zlib/
-obj-$(CONFIG_$(XPL_)ZSTD) += zstd/
-obj-$(CONFIG_$(XPL_)GZIP) += gunzip.o
-obj-$(CONFIG_$(XPL_)LZO) += lzo/
-obj-$(CONFIG_$(XPL_)LZMA) += lzma/
-obj-$(CONFIG_$(XPL_)LZ4) += lz4_wrapper.o
+obj-$(CONFIG_$(PHASE_)ZLIB) += zlib/
+obj-$(CONFIG_$(PHASE_)ZSTD) += zstd/
+obj-$(CONFIG_$(PHASE_)GZIP) += gunzip.o
+obj-$(CONFIG_$(PHASE_)LZO) += lzo/
+obj-$(CONFIG_$(PHASE_)LZMA) += lzma/
+obj-$(CONFIG_$(PHASE_)LZ4) += lz4_wrapper.o
 
 obj-$(CONFIG_$(XPL_)LIB_RATIONAL) += rational.o
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 16/19] boot: Allow use of FIT in TPL and VPL
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (14 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 15/19] spl: lib: Allow for decompression in any SPL build Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 17/19] lib: Allow crc8 " Simon Glass
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Ilias Apalodimas, Marek Vasut,
	Mattijs Korpershoek, Sughosh Ganu, Tom Rini

With VBE we want to use FIT in all phases of the boot. Add Kconfig
options to support this.

Disable the options for sandbox_vpl for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 boot/Kconfig                  | 69 ++++++++++++++++++++++++++++++++++-
 configs/sandbox_vpl_defconfig |  2 +
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 99dcedcc840..cdf787eb5c2 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -163,6 +163,18 @@ config SPL_FIT
 	select SPL_HASH
 	select SPL_OF_LIBFDT
 
+config VPL_FIT
+	bool "Support Flattened Image Tree within VPL"
+	depends on VPL
+	select VPL_HASH
+	select VPL_OF_LIBFDT
+
+config TPL_FIT
+	bool "Support Flattened Image Tree within TPL"
+	depends on TPL
+	select TPL_HASH
+	select TPL_OF_LIBFDT
+
 config SPL_FIT_PRINT
 	bool "Support FIT printing within SPL"
 	depends on SPL_FIT
@@ -268,6 +280,28 @@ config SPL_LOAD_FIT_FULL
 	  particular it can handle selecting from multiple device tree
 	  and passing the correct one to U-Boot.
 
+config TPL_LOAD_FIT
+	bool "Enable TPL loading U-Boot as a FIT (basic fitImage features)"
+	depends on TPL
+	select TPL_FIT
+	help
+	  Normally with the SPL framework a legacy image is generated as part
+	  of the build. This contains U-Boot along with information as to
+	  where it should be loaded. This option instead enables generation
+	  of a FIT (Flat Image Tree) which provides more flexibility. In
+	  particular it can handle selecting from multiple device tree
+	  and passing the correct one to U-Boot.
+
+	  This path has the following limitations:
+
+	  1. "loadables" images, other than FDTs, which do not have a "load"
+	     property will not be loaded. This limitation also applies to FPGA
+	     images with the correct "compatible" string.
+	  2. For FPGA images, the supported "compatible" list is in the
+	     doc/uImage.FIT/source_file_format.txt.
+	  3. FDTs are only loaded for images with an "os" property of "u-boot".
+	     "linux" images are also supported with Falcon boot mode.
+
 config SPL_FIT_IMAGE_POST_PROCESS
 	bool "Enable post-processing of FIT artifacts after loading by the SPL"
 	depends on SPL_LOAD_FIT
@@ -292,6 +326,22 @@ config VPL_FIT
 	select VPL_HASH
 	select VPL_OF_LIBFDT
 
+config VPL_LOAD_FIT
+	bool "Enable VPL loading U-Boot as a FIT (basic fitImage features)"
+	select VPL_FIT
+	default y
+
+config VPL_LOAD_FIT_FULL
+	bool "Enable SPL loading U-Boot as a FIT (full fitImage features)"
+	select VPL_FIT
+	help
+	  Normally with the SPL framework a legacy image is generated as part
+	  of the build. This contains U-Boot along with information as to
+	  where it should be loaded. This option instead enables generation
+	  of a FIT (Flat Image Tree) which provides more flexibility. In
+	  particular it can handle selecting from multiple device tree
+	  and passing the correct one to U-Boot.
+
 config VPL_FIT_PRINT
 	bool "Support FIT printing within VPL"
 	depends on VPL_FIT
@@ -620,6 +670,15 @@ config VPL_BOOTMETH_VBE
 	  supports selection of various firmware components, selection of an OS to
 	  boot as well as updating these using fwupd.
 
+config TPL_BOOTMETH_VBE
+	bool "Bootdev support for Verified Boot for Embedded (TPL)"
+	depends on TPL
+	default y
+	help
+	  Enables support for VBE boot. This is a standard boot method which
+	  supports selection of various firmware components, seleciton of an OS to
+	  boot as well as updating these using fwupd.
+
 if BOOTMETH_VBE
 
 config BOOTMETH_VBE_REQUEST
@@ -698,7 +757,15 @@ config VPL_BOOTMETH_VBE_SIMPLE_FW
 	  This option enabled for VPL, since it is the phase where the SPL
 	  decision is made.
 
-endif # BOOTMETH_VBE
+config TPL_BOOTMETH_VBE_SIMPLE_FW
+	bool "Bootdev support for VBE 'simple' method firmware phase (TPL)"
+	depends on VPL
+	default y
+	help
+	  Enables support for the firmware parts of VBE 'simple' boot, in TPL.
+	  TPL loads a FIT containing the VPL binary and a suitable devicetree.
+
+endif # BOOTMETH_VBE_SIMPLE
 
 config EXPO
 	bool "Support for expos - groups of scenes displaying a UI"
diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
index 84df2b85260..46329395ba5 100644
--- a/configs/sandbox_vpl_defconfig
+++ b/configs/sandbox_vpl_defconfig
@@ -27,6 +27,8 @@ CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_BEST_MATCH=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_TPL_BOOTMETH_VBE is not set
+# CONFIG_TPL_BOOTMETH_VBE_SIMPLE_FW is not set
 CONFIG_UPL=y
 CONFIG_UPL_IN=y
 CONFIG_BOOTSTAGE=y
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 17/19] lib: Allow crc8 in TPL and VPL
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (15 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 16/19] boot: Allow use of FIT in TPL and VPL Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 18/19] boot: Imply CRC8 with VBE Simon Glass
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Ilias Apalodimas, Michal Simek,
	Patrick Rudolph, Sughosh Ganu, Tom Rini

Provide options to enable the CRC8 feature in TPL and VPL builds.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Fix 'depends on SPL' to depend on TPL

 lib/Kconfig | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index 203f40e2662..8f1a96d98c4 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -728,6 +728,24 @@ config SPL_CRC8
 	  checksum with feedback to produce an 8-bit result. The code is small
 	  and it does not require a lookup table (unlike CRC32).
 
+config TPL_CRC8
+	bool "Support CRC8 in TPL"
+	depends on TPL
+	help
+	  Enables CRC8 support in TPL. This is not normally required. CRC8 is
+	  a simple and fast checksumming algorithm which does a bytewise
+	  checksum with feedback to produce an 8-bit result. The code is small
+	  and it does not require a lookup table (unlike CRC32).
+
+config VPL_CRC8
+	bool "Support CRC8 in VPL"
+	depends on VPL
+	help
+	  Enables CRC8 support in VPL. This is not normally required. CRC8 is
+	  a simple and fast checksumming algorithm which does a bytewise
+	  checksum with feedback to produce an 8-bit result. The code is small
+	  and it does not require a lookup table (unlike CRC32).
+
 config SPL_CRC16
 	bool "Support CRC16 in SPL"
 	depends on SPL
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 18/19] boot: Imply CRC8 with VBE
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (16 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 17/19] lib: Allow crc8 " Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-19 18:29 ` [PATCH v4 19/19] hash: Plumb crc8 into the hash functions Simon Glass
  2024-12-28  0:51 ` [PATCH v4 00/19] vbe: Series part E Tom Rini
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Ilias Apalodimas, Marek Vasut,
	Mattijs Korpershoek, Tom Rini

VBE uses a crc8 checksum to verify that the nvdata is valid, so make
sure it is available if VBE is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Depend on TPL/VPL as well

 boot/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index cdf787eb5c2..20935a269c6 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -704,6 +704,8 @@ config SPL_BOOTMETH_VBE_REQUEST
 config BOOTMETH_VBE_SIMPLE
 	bool "Bootdev support for VBE 'simple' method"
 	default y
+	imply SPL_CRC8 if SPL
+	imply VPL_CRC8 if VPL
 	help
 	  Enables support for VBE 'simple' boot. This allows updating a single
 	  firmware image in boot media such as MMC. It does not support any sort
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 19/19] hash: Plumb crc8 into the hash functions
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (17 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 18/19] boot: Imply CRC8 with VBE Simon Glass
@ 2024-12-19 18:29 ` Simon Glass
  2024-12-28  0:51 ` [PATCH v4 00/19] vbe: Series part E Tom Rini
  19 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2024-12-19 18:29 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Jaehoon Chung, Alex Shumsky, Igor Opaniuk,
	Jagan Teki, Jerome Forissier, Jiaxun Yang, Joe Hershberger,
	Joshua Watt, Mattijs Korpershoek, Stefan Roese, Tom Rini

Add an entry for crc8, with watchdog handling.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
---

Changes in v4:
- Add an option to avoid code bloat with rcar3_salvator-x for example

Changes in v3:
- Rebase to master

Changes in v2:
- Drop patch 'serial: ns16550: Allow clocks to be missing'

 common/Kconfig       | 8 ++++++++
 common/hash.c        | 8 ++++++++
 include/u-boot/crc.h | 3 +++
 lib/crc8.c           | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index e8d89bf6eb9..0e8c44f3f74 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -845,6 +845,14 @@ config HASH
 	  and the algorithms it supports are defined in common/hash.c. See
 	  also CMD_HASH for command-line access.
 
+config HASH_CRC8
+	bool "Make crc8 available via the hash API"
+	depends on HASH && CRC8
+	help
+	  Most times, the crc8() function is called directly. To make it also
+	  available via the hash API, e.g. in hash_block(), enable this
+	  option.
+
 config AVB_VERIFY
 	bool "Build Android Verified Boot operations"
 	depends on LIBAVB
diff --git a/common/hash.c b/common/hash.c
index db6925d6782..8dd9da85768 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -304,6 +304,14 @@ static struct hash_algo hash_algo[] = {
 		.hash_update	= hash_update_crc16_ccitt,
 		.hash_finish	= hash_finish_crc16_ccitt,
 	},
+#if CONFIG_IS_ENABLED(CRC8) && IS_ENABLED(CONFIG_HASH_CRC8)
+	{
+		.name		= "crc8",
+		.digest_size	= 1,
+		.chunk_size	= CHUNKSZ_CRC32,
+		.hash_func_ws	= crc8_wd_buf,
+	},
+#endif
 #if CONFIG_IS_ENABLED(CRC32)
 	{
 		.name		= "crc32",
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index 5174bd7ac41..b2badaf6a97 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -25,6 +25,9 @@
  */
 unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
 
+void crc8_wd_buf(const unsigned char *input, unsigned int len,
+		 unsigned char output[1], unsigned int chunk_sz);
+
 /* lib/crc16.c - 16 bit CRC with polynomial x^16 + x^15 + x^2 + 1 */
 uint16_t crc16(uint16_t crc, const unsigned char *buffer, size_t len);
 
diff --git a/lib/crc8.c b/lib/crc8.c
index 20d46d16147..811e19917b4 100644
--- a/lib/crc8.c
+++ b/lib/crc8.c
@@ -32,3 +32,9 @@ unsigned int crc8(unsigned int crc, const unsigned char *vptr, int len)
 
 	return crc;
 }
+
+void crc8_wd_buf(const unsigned char *input, unsigned int len,
+		 unsigned char output[1], unsigned int chunk_sz)
+{
+	*output = crc8(0, input, len);
+}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* RE: [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug
  2024-12-19 18:28 ` [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug Simon Glass
@ 2024-12-22 23:47   ` Jaehoon Chung
  0 siblings, 0 replies; 22+ messages in thread
From: Jaehoon Chung @ 2024-12-22 23:47 UTC (permalink / raw)
  To: 'Simon Glass', 'U-Boot Mailing List'
  Cc: 'Peng Fan', 'Quentin Schulz',
	'Sean	Anderson', 'Tim Harvey', 'Tom Rini'



> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Friday, December 20, 2024 3:29 AM
>
> The for() loop ends up being in the code even if the log_debug() does
> nothing. Add a condition to fix this.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Add new patch to avoid size growth in spl_mmc_find_device() debug
>
>  common/spl/spl_mmc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
> index 1f696593216..fe4230170a0 100644
> --- a/common/spl/spl_mmc.c
> +++ b/common/spl/spl_mmc.c
> @@ -81,8 +81,10 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)
>  	struct uclass *uc;
>
>  	log_debug("Selecting MMC dev %d; seqs:\n", mmc_dev);
> -	uclass_id_foreach_dev(UCLASS_MMC, dev, uc)
> -		log_debug("%d: %s\n", dev_seq(dev), dev->name);
> +	if (_LOG_DEBUG) {
> +		uclass_id_foreach_dev(UCLASS_MMC, dev, uc)
> +			log_debug("%d: %s\n", dev_seq(dev), dev->name);
> +	}
>  	ret = mmc_init_device(mmc_dev);
>  #else
>  	ret = mmc_initialize(NULL);
> --
> 2.34.1




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 00/19] vbe: Series part E
  2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
                   ` (18 preceding siblings ...)
  2024-12-19 18:29 ` [PATCH v4 19/19] hash: Plumb crc8 into the hash functions Simon Glass
@ 2024-12-28  0:51 ` Tom Rini
  19 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2024-12-28  0:51 UTC (permalink / raw)
  To: U-Boot Mailing List, Simon Glass
  Cc: Alex Shumsky, Caleb Connolly, Devarsh Thakkar, Dragan Simic,
	Gary Bisson, Heinrich Schuchardt, Igor Opaniuk, Ilias Apalodimas,
	Jaehoon Chung, Jagan Teki, Jerome Forissier, Jiaxun Yang,
	Joe Hershberger, Joshua Watt, Julien Masson, Laurent Pinchart,
	Leo Yu-Chi Liang, Lukas Funke, Marek Vasut, Marek Vasut,
	Mathieu Othacehe, Mattijs Korpershoek, Maxim Moskalets,
	Michael Trimarchi, Michal Simek, Nam Cao, Patrick Rudolph,
	Paul-Erwan Rio, Peng Fan, Quentin Schulz, Raymond Mao,
	Roman Stratiienko, Sean Anderson, Stefan Roese, Sughosh Ganu,
	Thomas Weißschuh, Tim Harvey

On Thu, 19 Dec 2024 11:28:48 -0700, Simon Glass wrote:

> This includes various patches towards implementing the VBE abrec
> bootmeth in U-Boot. It mostly focuses on SPL tweaks and adjusting what
> fatures are available in VPL.
> 
> Changes in v4:
> - Add an option to avoid code bloat with rcar3_salvator-x for example
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-12-28  0:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-19 18:28 [PATCH v4 00/19] vbe: Series part E Simon Glass
2024-12-19 18:28 ` [PATCH v4 01/19] spl: mmc: Avoid size growth in spl_mmc_find_device() debug Simon Glass
2024-12-22 23:47   ` Jaehoon Chung
2024-12-19 18:28 ` [PATCH v4 02/19] image: Add a prototype for fit_image_get_phase() Simon Glass
2024-12-19 18:28 ` [PATCH v4 03/19] boot: Allow FIT to fall back from best-match option Simon Glass
2024-12-19 18:28 ` [PATCH v4 04/19] bootstd: Avoid sprintf() in SPL when creating bootdevs Simon Glass
2024-12-19 18:28 ` [PATCH v4 05/19] boot: Respect the load_op in fit_image_load() Simon Glass
2024-12-19 18:28 ` [PATCH v4 06/19] malloc: Show amount of used space when memory runs out Simon Glass
2024-12-19 18:28 ` [PATCH v4 07/19] malloc: Provide a simple malloc for VPL Simon Glass
2024-12-19 18:28 ` [PATCH v4 08/19] Support setting a maximum size for the VPL image Simon Glass
2024-12-19 18:28 ` [PATCH v4 09/19] spl: Report a loader failure Simon Glass
2024-12-19 18:28 ` [PATCH v4 10/19] spl: Allow serial to be disabled in any XPL phase Simon Glass
2024-12-19 18:28 ` [PATCH v4 11/19] spl: Support a relocated stack " Simon Glass
2024-12-19 18:29 ` [PATCH v4 12/19] spl: Drop use of uintptr_t Simon Glass
2024-12-19 18:29 ` [PATCH v4 13/19] spl: Drop a duplicate variable in boot_from_devices() Simon Glass
2024-12-19 18:29 ` [PATCH v4 14/19] spl: Add some more debugging to load_simple_fit() Simon Glass
2024-12-19 18:29 ` [PATCH v4 15/19] spl: lib: Allow for decompression in any SPL build Simon Glass
2024-12-19 18:29 ` [PATCH v4 16/19] boot: Allow use of FIT in TPL and VPL Simon Glass
2024-12-19 18:29 ` [PATCH v4 17/19] lib: Allow crc8 " Simon Glass
2024-12-19 18:29 ` [PATCH v4 18/19] boot: Imply CRC8 with VBE Simon Glass
2024-12-19 18:29 ` [PATCH v4 19/19] hash: Plumb crc8 into the hash functions Simon Glass
2024-12-28  0:51 ` [PATCH v4 00/19] vbe: Series part E Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox