All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
@ 2019-08-05  9:43 Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
                   ` (16 more replies)
  0 siblings, 17 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:43 UTC (permalink / raw)
  To: u-boot


The purpose of this series is to provide the SPL with ability to apply
overlays for u-boot. this is only a RFC so far, to get a feedback on the
approach.

Our use-case is the support of the daughter boards of the AM65x EVM. In
Linux, each board is supported by a unique overlay. The presence of the
boards is detected at runtime, and some useful features (like USB) are
implemented on those daughter boards. Instead of providing multiple dtbs
and fall in a combinatorial pit, we propose to use DT overlays.

Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
a few weeks ago by Michal Simek.
Patch #3 to #6 amend Michal's patch.
Patch #7 to #9 are simple fixes for the Makefile
Patch #10 is used to reduce the complexity of the Makefile by having FIT
generator scripts provide their dependencies
Patch #12-#13 allow to use the board driver in SPL
Patch #14-#15 adds a way to dynamically select the DT overlays. That is
were we would use HW detection to select the required overlays. In that
case, the board driver code tells what overlay it needs (it gives the
name of the node).

On arm, if overlay are supported, this series increases the size of the SPL
by 3.2 kB.

Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404

Changes in v4:
- use CONFIG_IS_ENABLED() instead of #idef
- make sure that the temp buffer is freed in all cases
- Use the board driver infrastructure to get the image names from the
board code.
- Remove a patch that passed the board name to the FIT generator. If needed
the generator can get it from elsewhere
- Add a fix to not load the firmware twice (once as a firmware and once as
a loadable)

Changes in v3:
- Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
not selected.
- removed the RFC prefix. This work will be needed soon by TI's AM65x
platform. and can probably benefit other modular platforms
- removed the last patch that provided an example of how to use this with
on a DRA76.
- removed the patch that made u-boot.img a symlink to u-boot.itb because
it breaks the build of many platforms (because files required to build the
ITB are missing)
- removed the patch to reduce the footprint of the am335x SPL. (already
merged)
- Made the boot flow more permissive (don't fail immediately if an overlay
is not present) and more verbose when an error occures
- handle the dependencies of the FIT generation in a more generic way
- use a dedicated kconfig option to enable the application of the overlays
by the SPL.

Changes in v2:
- reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
- removed dtbo generation from dtso files and use .dts extension for the
  overlays
- add dynamic allocation usage in a separate patch
- defconfig change for the am335x_evm

Jean-Jacques Hiblot (14):
  spl: fit: don't load the firmware twice
  spl: fit: Make room in the FDT before applying overlays
  spl: fit: allocate a temporary buffer to load the overlays
  spl: fit: Do not fail immediately if an overlay is not available
  spl: fit: be more verbose when an error occurs when applying the
    overlays
  Makefile.lib: include /__symbols__ in dtb if
    SPL_LOAD_FIT_APPLY_OVERLAY is enabled
  Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
    CONFIG_SPL_FIT_GENERATOR
  Makefile: Fix u-boot.itb generation when building outside the source
    tree
  Makefile: Query the SPL Fit Generator for its dependencies
  spl: fit: constify the output parameter of spl_fit_get_image_name()
  drivers: board: Make the board drivers available in SPL
  drivers: board: Add get_fit_loadable()
  include: board: provide empty stubs when the BOARD option is not
    selected
  spl: fit: Allow the board to tell if more images must be loaded from
    FIT

Michal Simek (1):
  spl: fit: Add support for applying DT overlay

 Kconfig                                       |   9 ++
 Makefile                                      |  23 ++--
 arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
 arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
 board/sunxi/mksunxi_fit_atf.sh                |   4 +
 .../lion_rk3368/fit_spl_atf.its               |   6 +-
 .../puma_rk3399/fit_spl_atf.sh                |   6 +
 common/spl/spl_fit.c                          | 104 ++++++++++++++++--
 drivers/Makefile                              |   2 +-
 drivers/board/Kconfig                         |   2 +
 drivers/board/Makefile                        |   2 +-
 drivers/board/board-uclass.c                  |  11 ++
 include/board.h                               |  72 ++++++++++++
 scripts/Makefile.lib                          |   4 +
 14 files changed, 230 insertions(+), 27 deletions(-)

-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
@ 2019-08-05  9:43 ` Jean-Jacques Hiblot
  2019-08-13  9:33   ` Simon Glass
  2019-08-13 20:56   ` Andreas Dannenberg
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 02/15] spl: fit: Add support for applying DT overlay Jean-Jacques Hiblot
                   ` (15 subsequent siblings)
  16 siblings, 2 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:43 UTC (permalink / raw)
  To: u-boot

When u-boot.img is a FIT image generated automatically by mkimage, the
configuration node has the following structure:
conf-1 {
   description = "k3-am654-base-board";
   firmware = "firmware-1";
   loadables = "firmware-1";
   fdt = "fdt-1";
};

The firmware is referenced twice. Once by the 'firmware' property and
once by the 'loadables' property. Currently this result in the firmware
being loaded twice. This is not a big problem but has an impact on the
boot time.
Fixing it by not loading a loadable image if it is also the firmware image.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v4: New

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

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 969f7775c1..0de18e3975 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -361,6 +361,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	int images, ret;
 	int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
 	int index = 0;
+	int firmware_node;
 
 	/*
 	 * For FIT with external data, figure out where the external images
@@ -490,6 +491,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 		spl_fit_append_fdt(spl_image, info, sector, fit,
 				   images, base_offset);
 
+	firmware_node = node;
 	/* Now check if there are more images for us to load */
 	for (; ; index++) {
 		uint8_t os_type = IH_OS_INVALID;
@@ -498,6 +500,14 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 		if (node < 0)
 			break;
 
+		/*
+		 * if the firmware is also a loadable, skip it because
+		 * it already has been loaded. This is typically the case with
+		 * u-boot.img generated by mkimage.
+		 */
+		if (firmware_node == node)
+			continue;
+
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
 		if (ret < 0)
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 02/15] spl: fit: Add support for applying DT overlay
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
@ 2019-08-05  9:43 ` Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 03/15] spl: fit: Make room in the FDT before applying overlays Jean-Jacques Hiblot
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:43 UTC (permalink / raw)
  To: u-boot

From: Michal Simek <michal.simek@xilinx.com>

doc/uImage.FIT/overlay-fdt-boot.txt is describing how to create FIT
image with DT overlays in it.
Add support for this feature to SPL.

Here is the ZynqMP fragment where dtb points to full DT and dtbo is
overlay which should be applied on the top of dtb.
config {
        description = "ATF with full u-boot overlay";
        firmware = "atf";
        loadables = "uboot";
        fdt = "dtb", "dtbo";
};

The whole feature depends on OF_LIBFDT_OVERLAY which is adding +4kB code
and 0 for platforms which are not enabling this feature.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v4:
- use CONFIG_IS_ENABLED() instead of #idef

Changes in v3:
- Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
not selected.

Changes in v2: None

 Kconfig              |  9 +++++++++
 common/spl/spl_fit.c | 30 +++++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/Kconfig b/Kconfig
index d2eb744e70..3d6477af9b 100644
--- a/Kconfig
+++ b/Kconfig
@@ -425,6 +425,15 @@ config SPL_LOAD_FIT
 	  particular it can handle selecting from multiple device tree
 	  and passing the correct one to U-Boot.
 
+config SPL_LOAD_FIT_APPLY_OVERLAY
+	bool "Enable SPL applying DT overlays from FIT"
+	depends on SPL_LOAD_FIT
+	select OF_LIBFDT_OVERLAY
+	help
+	  The device tree is loaded from the FIT image. Allow the SPL is to
+	  also load device-tree overlays from the FIT image an apply them
+	  over the device tree.
+
 config SPL_LOAD_FIT_FULL
 	bool "Enable SPL loading U-Boot as a FIT (full fitImage features)"
 	select SPL_FIT
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 0de18e3975..057f708837 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -278,10 +278,10 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 			      void *fit, int images, ulong base_offset)
 {
 	struct spl_image_info image_info;
-	int node, ret;
+	int node, ret, index = 0;
 
 	/* Figure out which device tree the board wants to use */
-	node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
+	node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++);
 	if (node < 0) {
 		debug("%s: cannot find FDT node\n", __func__);
 		return node;
@@ -303,8 +303,32 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
 	/* Try to make space, so we can inject details on the loadables */
 	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+	if (ret < 0)
+		return ret;
 #endif
-
+	if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
+		for (; ; index++) {
+			node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
+						      index);
+			if (node < 0) {
+				debug("%s: No additional FDT node\n", __func__);
+				return 0;
+			}
+
+			ret = spl_load_fit_image(info, sector, fit, base_offset,
+						 node, &image_info);
+			if (ret < 0)
+				return ret;
+
+			ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
+							(void *)image_info.load_addr);
+			if (ret)
+				return ret;
+
+			debug("%s: DT overlay %s applied\n", __func__,
+			      fit_get_name(fit, node, NULL));
+		}
+	}
 	return ret;
 }
 
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 03/15] spl: fit: Make room in the FDT before applying overlays
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 02/15] spl: fit: Add support for applying DT overlay Jean-Jacques Hiblot
@ 2019-08-05  9:43 ` Jean-Jacques Hiblot
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays Jean-Jacques Hiblot
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:43 UTC (permalink / raw)
  To: u-boot

Make room in the FDT before applying the overlay, otherwise it may fail if
the overlay is big. As the exact added size is not known in advance, just
add the size of the overlay.
Move after the end of the application of the overlays, the resize  of the
FDT for the injection of the details on the loadables.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 057f708837..ab47da5094 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -301,11 +301,6 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 	/* Make the load-address of the FDT available for the SPL framework */
 	spl_image->fdt_addr = (void *)image_info.load_addr;
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
-	/* Try to make space, so we can inject details on the loadables */
-	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
-	if (ret < 0)
-		return ret;
-#endif
 	if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
 		for (; ; index++) {
 			node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
@@ -320,6 +315,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 			if (ret < 0)
 				return ret;
 
+			/* Make room in FDT for changes from the overlay */
+			ret = fdt_increase_size(spl_image->fdt_addr,
+						image_info.size);
+			if (ret < 0)
+				return ret;
+
 			ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
 							(void *)image_info.load_addr);
 			if (ret)
@@ -329,6 +330,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 			      fit_get_name(fit, node, NULL));
 		}
 	}
+	/* Try to make space, so we can inject details on the loadables */
+	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+	if (ret < 0)
+		return ret;
+#endif
+
 	return ret;
 }
 
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (2 preceding siblings ...)
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 03/15] spl: fit: Make room in the FDT before applying overlays Jean-Jacques Hiblot
@ 2019-08-05  9:43 ` Jean-Jacques Hiblot
  2019-08-13  9:33   ` Simon Glass
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 05/15] spl: fit: Do not fail immediately if an overlay is not available Jean-Jacques Hiblot
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:43 UTC (permalink / raw)
  To: u-boot

If the node describing an overlay does not specify a load address, it will
be loaded at the address previously used.
Fixing it by allocating a temporary 64kB region that will be used as a
default load address.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

---

Changes in v4:
- make sure that the temp buffer is freed in all cases

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index ab47da5094..977074cd99 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -8,8 +8,9 @@
 #include <errno.h>
 #include <fpga.h>
 #include <image.h>
-#include <linux/libfdt.h>
+#include <malloc.h>
 #include <spl.h>
+#include <linux/libfdt.h>
 
 #ifndef CONFIG_SYS_BOOTM_LEN
 #define CONFIG_SYS_BOOTM_LEN	(64 << 20)
@@ -302,33 +303,50 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 	spl_image->fdt_addr = (void *)image_info.load_addr;
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
 	if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
+		void *tmpbuffer;
+		/*
+		 * allocate 64KB of memory. This will be used to store the DT
+		 * overlay before it is applied. It may not be used depending on
+		 * how the overlay is stored, so don't fail yet if the
+		 * allocation failed.
+		 */
+		tmpbuffer = malloc(64 * 1024);
+		if (!tmpbuffer)
+			debug("%s: unable to allocate space for overlays\n",
+			      __func__);
+
 		for (; ; index++) {
 			node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
 						      index);
 			if (node < 0) {
 				debug("%s: No additional FDT node\n", __func__);
-				return 0;
+				break;
 			}
 
+			image_info.load_addr = (ulong)tmpbuffer;
 			ret = spl_load_fit_image(info, sector, fit, base_offset,
 						 node, &image_info);
 			if (ret < 0)
-				return ret;
+				break;
 
 			/* Make room in FDT for changes from the overlay */
 			ret = fdt_increase_size(spl_image->fdt_addr,
 						image_info.size);
 			if (ret < 0)
-				return ret;
+				break;
 
 			ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
 							(void *)image_info.load_addr);
 			if (ret)
-				return ret;
+				break;
 
 			debug("%s: DT overlay %s applied\n", __func__,
 			      fit_get_name(fit, node, NULL));
 		}
+		if (tmpbuffer)
+			free(tmpbuffer);
+		if (ret)
+			return ret;
 	}
 	/* Try to make space, so we can inject details on the loadables */
 	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 05/15] spl: fit: Do not fail immediately if an overlay is not available
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (3 preceding siblings ...)
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 06/15] spl: fit: be more verbose when an error occurs when applying the overlays Jean-Jacques Hiblot
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

If one overlay that must be applied cannot be found in the FIT, the current
implementation stops applying the overlays. Let's make it skip only the
failing overlay instead.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

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

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 977074cd99..c4aa09a6b7 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -318,9 +318,13 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		for (; ; index++) {
 			node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
 						      index);
-			if (node < 0) {
+			if (node == -E2BIG) {
 				debug("%s: No additional FDT node\n", __func__);
 				break;
+			} else if (node < 0) {
+				debug("%s: unable to find FDT node %d\n",
+				      __func__, index);
+				continue;
 			}
 
 			image_info.load_addr = (ulong)tmpbuffer;
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 06/15] spl: fit: be more verbose when an error occurs when applying the overlays
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (4 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 05/15] spl: fit: Do not fail immediately if an overlay is not available Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 07/15] Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled Jean-Jacques Hiblot
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

There are many ways the overlay application can fail.
2 of them are probably the most common:
- the application itself failed. Usually this is comes from an unresolved
  reference
- DTBO not available in FIT (could be because of a typo)

In both case it is good to be more explicit about the error and at least
show which overlay is failing.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index c4aa09a6b7..f991c0ef8c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -106,7 +106,7 @@ static int spl_fit_get_image_node(const void *fit, int images,
 
 	node = fdt_subnode_offset(fit, images, str);
 	if (node < 0) {
-		debug("cannot find image node '%s': %d\n", str, node);
+		pr_err("cannot find image node '%s': %d\n", str, node);
 		return -EINVAL;
 	}
 
@@ -341,8 +341,11 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 
 			ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
 							(void *)image_info.load_addr);
-			if (ret)
+			if (ret) {
+				pr_err("failed to apply DT overlay %s\n",
+				       fit_get_name(fit, node, NULL));
 				break;
+			}
 
 			debug("%s: DT overlay %s applied\n", __func__,
 			      fit_get_name(fit, node, NULL));
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 07/15] Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (5 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 06/15] spl: fit: be more verbose when an error occurs when applying the overlays Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 08/15] Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR Jean-Jacques Hiblot
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

In order to apply an overlay to a DTB. The DTB must have been generated
with the option '-@'.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 scripts/Makefile.lib | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index de67677f61..4b9f333d57 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -292,6 +292,10 @@ cmd_dt_S_dtb=						\
 $(obj)/%.dtb.S: $(obj)/%.dtb
 	$(call cmd,dt_S_dtb)
 
+ifeq ($(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY),y)
+DTC_FLAGS += -@
+endif
+
 quiet_cmd_dtc = DTC     $@
 # Modified for U-Boot
 # Bring in any U-Boot-specific include at the end of the file
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 08/15] Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (6 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 07/15] Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 09/15] Makefile: Fix u-boot.itb generation when building outside the source tree Jean-Jacques Hiblot
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

The current tests do to handle well the cases where those variables are not
defined. When CONFIG_SPL_LOAD_FIT is not defined, U_BOOT_ITS gets defined
as an empty string.
Fixing it by using intermediate variables with the quotes removed

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 8513db94e3..648e02bbdc 100644
--- a/Makefile
+++ b/Makefile
@@ -1209,12 +1209,15 @@ ifndef CONFIG_SYS_UBOOT_START
 CONFIG_SYS_UBOOT_START := 0
 endif
 
+
 # Boards with more complex image requirments can provide an .its source file
 # or a generator script
-ifneq ($(CONFIG_SPL_FIT_SOURCE),"")
-U_BOOT_ITS = $(subst ",,$(CONFIG_SPL_FIT_SOURCE))
+SPL_FIT_SOURCE := $(subst ",,$(CONFIG_SPL_FIT_SOURCE))
+SPL_FIT_GENERATOR := $(subst ",,$(CONFIG_SPL_FIT_GENERATOR))
+ifneq ($(SPL_FIT_SOURCE),)
+U_BOOT_ITS = $(SPL_FIT_SOURCE)
 else
-ifneq ($(CONFIG_SPL_FIT_GENERATOR),"")
+ifneq ($(SPL_FIT_GENERATOR),)
 U_BOOT_ITS := u-boot.its
 ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-imx/mkimage_fit_atf.sh")
 U_BOOT_ITS_DEPS += u-boot-nodtb.bin
@@ -1223,7 +1226,7 @@ ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-rockchip/make_fit_atf.py")
 U_BOOT_ITS_DEPS += u-boot
 endif
 $(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE
-	$(srctree)/$(CONFIG_SPL_FIT_GENERATOR) \
+	$(srctree)/$(SPL_FIT_GENERATOR) \
 	$(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@
 endif
 endif
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 09/15] Makefile: Fix u-boot.itb generation when building outside the source tree
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (7 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 08/15] Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 10/15] Makefile: Query the SPL Fit Generator for its dependencies Jean-Jacques Hiblot
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

Include the object tree and the source tree in the search path of the
FIT compîler (dtc). This allows to use paths relative to the root of the
source or object trees in the ITS instead of working backward from the
actual location of the ITS.
It also allows to use a build directory different of the source directory.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                                            | 5 +++--
 board/theobroma-systems/lion_rk3368/fit_spl_atf.its | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 648e02bbdc..d0f69854ee 100644
--- a/Makefile
+++ b/Makefile
@@ -910,7 +910,8 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
 	>$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
 
 quiet_cmd_mkfitimage = MKIMAGE $@
-cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -f $(U_BOOT_ITS) -p $(CONFIG_FIT_EXTERNAL_OFFSET) $@\
+cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -D "-i $(obj) -i $(src)"\
+	-f $(U_BOOT_ITS) $@ -p $(CONFIG_FIT_EXTERNAL_OFFSET)\
 	>$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
 
 quiet_cmd_cat = CAT     $@
@@ -1215,7 +1216,7 @@ endif
 SPL_FIT_SOURCE := $(subst ",,$(CONFIG_SPL_FIT_SOURCE))
 SPL_FIT_GENERATOR := $(subst ",,$(CONFIG_SPL_FIT_GENERATOR))
 ifneq ($(SPL_FIT_SOURCE),)
-U_BOOT_ITS = $(SPL_FIT_SOURCE)
+U_BOOT_ITS = $(src)/$(SPL_FIT_SOURCE)
 else
 ifneq ($(SPL_FIT_GENERATOR),)
 U_BOOT_ITS := u-boot.its
diff --git a/board/theobroma-systems/lion_rk3368/fit_spl_atf.its b/board/theobroma-systems/lion_rk3368/fit_spl_atf.its
index 6b04fbc7da..69202a117b 100644
--- a/board/theobroma-systems/lion_rk3368/fit_spl_atf.its
+++ b/board/theobroma-systems/lion_rk3368/fit_spl_atf.its
@@ -14,7 +14,7 @@
 	images {
 		uboot {
 			description = "U-Boot (64-bit)";
-			data = /incbin/("../../../u-boot-nodtb.bin");
+			data = /incbin/("u-boot-nodtb.bin");
 			type = "standalone";
 			os = "U-Boot";
 			arch = "arm64";
@@ -23,7 +23,7 @@
 		};
 		atf {
 			description = "ARM Trusted Firmware";
-			data = /incbin/("../../../bl31-rk3368.bin");
+			data = /incbin/("bl31-rk3368.bin");
 			type = "firmware";
 			os = "arm-trusted-firmware";
 			arch = "arm64";
@@ -34,7 +34,7 @@
 
 		fdt {
 			description = "RK3368-uQ7 (Lion) flat device-tree";
-			data = /incbin/("../../../u-boot.dtb");
+			data = /incbin/("u-boot.dtb");
 			type = "flat_dt";
 			compression = "none";
 		};
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 10/15] Makefile: Query the SPL Fit Generator for its dependencies
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (8 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 09/15] Makefile: Fix u-boot.itb generation when building outside the source tree Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 11/15] spl: fit: constify the output parameter of spl_fit_get_image_name() Jean-Jacques Hiblot
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

To reduce the complexity of the Makefile, let the generator tell what its
dependencies are. For this purpose use the "--deps" option.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                                           | 9 ++-------
 arch/arm/mach-imx/mkimage_fit_atf.sh               | 5 +++++
 arch/arm/mach-rockchip/make_fit_atf.py             | 7 +++++++
 board/sunxi/mksunxi_fit_atf.sh                     | 4 ++++
 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh | 6 ++++++
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index d0f69854ee..0354f7c182 100644
--- a/Makefile
+++ b/Makefile
@@ -1220,13 +1220,8 @@ U_BOOT_ITS = $(src)/$(SPL_FIT_SOURCE)
 else
 ifneq ($(SPL_FIT_GENERATOR),)
 U_BOOT_ITS := u-boot.its
-ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-imx/mkimage_fit_atf.sh")
-U_BOOT_ITS_DEPS += u-boot-nodtb.bin
-endif
-ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-rockchip/make_fit_atf.py")
-U_BOOT_ITS_DEPS += u-boot
-endif
-$(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE
+U_BOOT_ITS_DEPS += $(shell $(srctree)/$(SPL_FIT_GENERATOR) --deps $(BOARD))
+$(U_BOOT_ITS): u-boot-nodtb.bin $(U_BOOT_ITS_DEPS) FORCE
 	$(srctree)/$(SPL_FIT_GENERATOR) \
 	$(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@
 endif
diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh b/arch/arm/mach-imx/mkimage_fit_atf.sh
index 38c9858e84..4da7531954 100755
--- a/arch/arm/mach-imx/mkimage_fit_atf.sh
+++ b/arch/arm/mach-imx/mkimage_fit_atf.sh
@@ -11,6 +11,11 @@
 [ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000"
 [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000"
 
+
+if [ x"$1" = x"--deps" ]; then
+	exit 0
+fi
+
 if [ ! -f $BL31 ]; then
 	echo "ERROR: BL31 file $BL31 NOT found" >&2
 	exit 0
diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py
index b9a1988298..56fab4e330 100755
--- a/arch/arm/mach-rockchip/make_fit_atf.py
+++ b/arch/arm/mach-rockchip/make_fit_atf.py
@@ -163,6 +163,10 @@ def unpack_elf(filename):
             segments.append((index, e_entry, p_paddr, p_data))
     return segments
 
+def show_deps_and_exit():
+	print("u-boot")
+	sys.exit(0)
+
 def main():
     uboot_elf = "./u-boot"
     fit_its = sys.stdout
@@ -178,6 +182,9 @@ def main():
         logging.warning(' BL31 file bl31.elf NOT found, resulting binary is non-functional')
         logging.warning(' Please read Building section in doc/README.rockchip')
 
+    if sys.argv[1] == "--deps":
+	    show_deps_and_exit()
+
     opts, args = getopt.getopt(sys.argv[1:], "o:u:b:h")
     for opt, val in opts:
         if opt == "-o":
diff --git a/board/sunxi/mksunxi_fit_atf.sh b/board/sunxi/mksunxi_fit_atf.sh
index 88ad719747..c0ce4394e2 100755
--- a/board/sunxi/mksunxi_fit_atf.sh
+++ b/board/sunxi/mksunxi_fit_atf.sh
@@ -5,6 +5,10 @@
 #
 # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
 
+if [ x"$1" = x"--deps" ]; then
+	exit 0
+fi
+
 [ -z "$BL31" ] && BL31="bl31.bin"
 
 if [ ! -f $BL31 ]; then
diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh
index 420e7daf4c..a7bada193a 100755
--- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh
+++ b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh
@@ -11,6 +11,12 @@
 #
 # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
 
+
+if [ x"$1" = x"--deps" ]; then
+	echo "u-boot.dtb"
+	exit 0
+fi
+
 [ -z "$BL31" ] && BL31="bl31.bin"
 
 if [ ! -f $BL31 ]; then
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 11/15] spl: fit: constify the output parameter of spl_fit_get_image_name()
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (9 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 10/15] Makefile: Query the SPL Fit Generator for its dependencies Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL Jean-Jacques Hiblot
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

There is no need for it to be non-constant. Making it constant, allows to
return constant string without warning.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index f991c0ef8c..2f555a2f13 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -39,7 +39,7 @@ __weak ulong board_spl_fit_size_align(ulong size)
  */
 static int spl_fit_get_image_name(const void *fit, int images,
 				  const char *type, int index,
-				  char **outname)
+				  const char **outname)
 {
 	const char *name, *str;
 	__maybe_unused int node;
@@ -94,7 +94,7 @@ static int spl_fit_get_image_name(const void *fit, int images,
 static int spl_fit_get_image_node(const void *fit, int images,
 				  const char *type, int index)
 {
-	char *str;
+	const char *str;
 	int err;
 	int node;
 
@@ -369,7 +369,7 @@ static int spl_fit_record_loadable(const void *fit, int images, int index,
 {
 	int ret = 0;
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
-	char *name;
+	const char *name;
 	int node;
 
 	ret = spl_fit_get_image_name(fit, images, "loadables",
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (10 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 11/15] spl: fit: constify the output parameter of spl_fit_get_image_name() Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-13  9:33   ` Simon Glass
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable() Jean-Jacques Hiblot
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v4: New

 drivers/Makefile       | 2 +-
 drivers/board/Kconfig  | 2 ++
 drivers/board/Makefile | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 41933605ce..30ead18b06 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
 obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
+obj-$(CONFIG_$(SPL_)BOARD) += board/
 
 ifndef CONFIG_TPL_BUILD
 ifdef CONFIG_SPL_BUILD
@@ -77,7 +78,6 @@ obj-y += ata/
 obj-$(CONFIG_DM_DEMO) += demo/
 obj-$(CONFIG_BIOSEMU) += bios_emulator/
 obj-y += block/
-obj-y += board/
 obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
 obj-y += cache/
 obj-$(CONFIG_CPU) += cpu/
diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig
index 2a3fc9c049..a94c4fb368 100644
--- a/drivers/board/Kconfig
+++ b/drivers/board/Kconfig
@@ -8,6 +8,8 @@ menuconfig BOARD
 
 if BOARD
 
+config SPL_BOARD
+	bool "Enable board driver support in SPL"
 
 config BOARD_GAZERBEAM
 	bool "Enable board driver for the Gazerbeam board"
diff --git a/drivers/board/Makefile b/drivers/board/Makefile
index c8dab4fa0b..cc16361755 100644
--- a/drivers/board/Makefile
+++ b/drivers/board/Makefile
@@ -2,6 +2,6 @@
 #
 # (C) Copyright 2017
 # Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
-obj-$(CONFIG_BOARD) += board-uclass.o
+obj-y += board-uclass.o
 obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o
 obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable()
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (11 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-13  9:34   ` Simon Glass
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected Jean-Jacques Hiblot
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

This function will be used by the SPL to get the names of images to load
from the FIT. This allows to load different images based on runtime HW
detection.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v4: New

 drivers/board/board-uclass.c | 11 +++++++++++
 include/board.h              | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
index a516ba4962..4af991e176 100644
--- a/drivers/board/board-uclass.c
+++ b/drivers/board/board-uclass.c
@@ -23,6 +23,17 @@ int board_detect(struct udevice *dev)
 	return ops->detect(dev);
 }
 
+const char *board_get_fit_loadable(struct udevice *dev, int index,
+				   const char *type)
+{
+	struct board_ops *ops = board_get_ops(dev);
+
+	if (!ops->get_fit_loadable)
+		return NULL;
+
+	return ops->get_fit_loadable(dev, index, type);
+}
+
 int board_get_bool(struct udevice *dev, int id, bool *val)
 {
 	struct board_ops *ops = board_get_ops(dev);
diff --git a/include/board.h b/include/board.h
index 9dc78684f8..0f4f1aadeb 100644
--- a/include/board.h
+++ b/include/board.h
@@ -79,6 +79,24 @@ struct board_ops {
 	 * Return: 0 if OK, -ve on error.
 	 */
 	int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
+
+	/**
+	 * get_fit_loadable - Get the name of an image to load from FIT
+	 * This function can be used to provide the image names based on runtime
+	 * detection. A classic use-case would when DTBOs are used to describe
+	 * additionnal daughter cards.
+	 *
+	 * @dev:	The board instance to gather the data.
+	 * @index:	Index of the image. Starts at 0 and gets incremented
+	 *		after each call to this function.
+	 * @type:	The type of image. For example, "fdt" for DTBs
+	 *
+	 * return:	The name of the node describing the image. NULL
+	 *		indicates that there no more image to get from this
+	 *		function.
+	 */
+	const char *(*get_fit_loadable)(struct udevice *dev, int index,
+					const char *type);
 };
 
 #define board_get_ops(dev)	((struct board_ops *)(dev)->driver->ops)
@@ -137,3 +155,20 @@ int board_get_str(struct udevice *dev, int id, size_t size, char *val);
  * Return: 0 if OK, -ve on error.
  */
 int board_get(struct udevice **devp);
+
+/**
+ * board_get_fit_loadable - Get the name of an image to load from FIT
+ * This function can be used to provide the image names based on runtime
+ * detection. A classic use-case would when DTBOs are used to describe
+ * additionnal daughter cards.
+ *
+ * @dev:	The board instance to gather the data.
+ * @index:	Index of the image. Starts at 0 and gets incremented
+ *		after each call to this function.
+ * @type:	The type of image. For example, "fdt" for DTBs
+ *
+ * return:	The name of the node describing the image. NULL indicates
+ *		that there no more images to get from this function.
+ */
+const char *board_get_fit_loadable(struct udevice *dev, int index,
+				   const char *type);
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (12 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable() Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-13  9:34   ` Simon Glass
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT Jean-Jacques Hiblot
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

Useful to avoid #ifdef throughout the code that uses the board driver API.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v4: New

 include/board.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/include/board.h b/include/board.h
index 0f4f1aadeb..96e8ca77bd 100644
--- a/include/board.h
+++ b/include/board.h
@@ -31,6 +31,7 @@
  * to read the serial number.
  */
 
+#if CONFIG_IS_ENABLED(BOARD)
 struct board_ops {
 	/**
 	 * detect() - Run the hardware info detection procedure for this
@@ -172,3 +173,39 @@ int board_get(struct udevice **devp);
  */
 const char *board_get_fit_loadable(struct udevice *dev, int index,
 				   const char *type);
+
+#else
+
+static inline int board_detect(struct udevice *dev)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_bool(struct udevice *dev, int id, bool *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_int(struct udevice *dev, int id, int *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_str(struct udevice *dev, int id, size_t size,
+				char *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get(struct udevice **devp)
+{
+	return -ENOSYS;
+}
+
+static inline const char *board_get_fit_loadable(struct udevice *dev,
+						 int index, const char *type)
+{
+	return NULL;
+}
+
+#endif
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (13 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected Jean-Jacques Hiblot
@ 2019-08-05  9:44 ` Jean-Jacques Hiblot
  2019-08-13  9:34   ` Simon Glass
  2019-08-05 10:28 ` [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Simon Goldschmidt
  2019-08-13  9:33 ` Simon Glass
  16 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05  9:44 UTC (permalink / raw)
  To: u-boot

spl_fit_get_image_name() is used to get the names of the images that the
SPL must load from the FIT. It relies on the content of a property present
in the FIT. The list of images is thus statically defined in the FIT.
With this scheme, it becomes quickly hard to manage combinations of more
than a hand few of images.
To address this problem, give the board driver code the opportunity to
add to the list of images. The images from the FIT property are loaded
first, and then the board_get_fit_loadable() is called to get more image
names.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

---

Changes in v4:
- Use the board driver infrastructure to get the image names from the
board code.

Changes in v3:
- removed the RFC prefix. This work will be needed soon by TI's AM65x
platform. and can probably benefit other modular platforms
- removed the last patch that provided an example of how to use this with
on a DRA76.
- removed the patch that made u-boot.img a symlink to u-boot.itb because
it breaks the build of many platforms (because files required to build the
ITB are missing)
- removed the patch to reduce the footprint of the am335x SPL. (already
merged)
- Made the boot flow more permissive (don't fail immediately if an overlay
is not present) and more verbose when an error occures
- handle the dependencies of the FIT generation in a more generic way
- use a dedicated kconfig option to enable the application of the overlays
by the SPL.

Changes in v2:
- reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
- removed dtbo generation from dtso files and use .dts extension for the
  overlays
- add dynamic allocation usage in a separate patch
- defconfig change for the am335x_evm

 common/spl/spl_fit.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 2f555a2f13..2879b76578 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <errno.h>
+#include <board.h>
 #include <fpga.h>
 #include <image.h>
 #include <malloc.h>
@@ -41,10 +42,12 @@ static int spl_fit_get_image_name(const void *fit, int images,
 				  const char *type, int index,
 				  const char **outname)
 {
+	struct udevice *board;
 	const char *name, *str;
 	__maybe_unused int node;
 	int conf_node;
 	int len, i;
+	bool found = true;
 
 	conf_node = fit_find_config_node(fit);
 	if (conf_node < 0) {
@@ -70,12 +73,27 @@ static int spl_fit_get_image_name(const void *fit, int images,
 	for (i = 0; i < index; i++) {
 		str = strchr(str, '\0') + 1;
 		if (!str || (str - name >= len)) {
-			debug("no string for index %d\n", index);
-			return -E2BIG;
+			found = false;
+			break;
 		}
 	}
 
-	*outname = (char *)str;
+	if (!found && !board_get(&board)) {
+		/*
+		 * no string in the property for this index. Check if the board
+		 * level code can supply one.
+		 */
+		str = board_get_fit_loadable(board, index - i - 1, type);
+		if (str)
+			found = true;
+	}
+
+	if (!found) {
+		debug("no string for index %d\n", index);
+		return -E2BIG;
+	}
+
+	*outname = str;
 	return 0;
 }
 
-- 
2.17.1

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

* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (14 preceding siblings ...)
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT Jean-Jacques Hiblot
@ 2019-08-05 10:28 ` Simon Goldschmidt
  2019-08-05 10:36   ` Jean-Jacques Hiblot
  2019-08-13  9:33 ` Simon Glass
  16 siblings, 1 reply; 32+ messages in thread
From: Simon Goldschmidt @ 2019-08-05 10:28 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 5, 2019 at 11:44 AM Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
>
> The purpose of this series is to provide the SPL with ability to apply
> overlays for u-boot. this is only a RFC so far, to get a feedback on the
> approach.

If it's RFC, shouldn't that be noted in the subject line?

Regards,
Simon

>
> Our use-case is the support of the daughter boards of the AM65x EVM. In
> Linux, each board is supported by a unique overlay. The presence of the
> boards is detected at runtime, and some useful features (like USB) are
> implemented on those daughter boards. Instead of providing multiple dtbs
> and fall in a combinatorial pit, we propose to use DT overlays.
>
> Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
> a few weeks ago by Michal Simek.
> Patch #3 to #6 amend Michal's patch.
> Patch #7 to #9 are simple fixes for the Makefile
> Patch #10 is used to reduce the complexity of the Makefile by having FIT
> generator scripts provide their dependencies
> Patch #12-#13 allow to use the board driver in SPL
> Patch #14-#15 adds a way to dynamically select the DT overlays. That is
> were we would use HW detection to select the required overlays. In that
> case, the board driver code tells what overlay it needs (it gives the
> name of the node).
>
> On arm, if overlay are supported, this series increases the size of the SPL
> by 3.2 kB.
>
> Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404
>
> Changes in v4:
> - use CONFIG_IS_ENABLED() instead of #idef
> - make sure that the temp buffer is freed in all cases
> - Use the board driver infrastructure to get the image names from the
> board code.
> - Remove a patch that passed the board name to the FIT generator. If needed
> the generator can get it from elsewhere
> - Add a fix to not load the firmware twice (once as a firmware and once as
> a loadable)
>
> Changes in v3:
> - Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
> not selected.
> - removed the RFC prefix. This work will be needed soon by TI's AM65x
> platform. and can probably benefit other modular platforms
> - removed the last patch that provided an example of how to use this with
> on a DRA76.
> - removed the patch that made u-boot.img a symlink to u-boot.itb because
> it breaks the build of many platforms (because files required to build the
> ITB are missing)
> - removed the patch to reduce the footprint of the am335x SPL. (already
> merged)
> - Made the boot flow more permissive (don't fail immediately if an overlay
> is not present) and more verbose when an error occures
> - handle the dependencies of the FIT generation in a more generic way
> - use a dedicated kconfig option to enable the application of the overlays
> by the SPL.
>
> Changes in v2:
> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
> - removed dtbo generation from dtso files and use .dts extension for the
>   overlays
> - add dynamic allocation usage in a separate patch
> - defconfig change for the am335x_evm
>
> Jean-Jacques Hiblot (14):
>   spl: fit: don't load the firmware twice
>   spl: fit: Make room in the FDT before applying overlays
>   spl: fit: allocate a temporary buffer to load the overlays
>   spl: fit: Do not fail immediately if an overlay is not available
>   spl: fit: be more verbose when an error occurs when applying the
>     overlays
>   Makefile.lib: include /__symbols__ in dtb if
>     SPL_LOAD_FIT_APPLY_OVERLAY is enabled
>   Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
>     CONFIG_SPL_FIT_GENERATOR
>   Makefile: Fix u-boot.itb generation when building outside the source
>     tree
>   Makefile: Query the SPL Fit Generator for its dependencies
>   spl: fit: constify the output parameter of spl_fit_get_image_name()
>   drivers: board: Make the board drivers available in SPL
>   drivers: board: Add get_fit_loadable()
>   include: board: provide empty stubs when the BOARD option is not
>     selected
>   spl: fit: Allow the board to tell if more images must be loaded from
>     FIT
>
> Michal Simek (1):
>   spl: fit: Add support for applying DT overlay
>
>  Kconfig                                       |   9 ++
>  Makefile                                      |  23 ++--
>  arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
>  arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
>  board/sunxi/mksunxi_fit_atf.sh                |   4 +
>  .../lion_rk3368/fit_spl_atf.its               |   6 +-
>  .../puma_rk3399/fit_spl_atf.sh                |   6 +
>  common/spl/spl_fit.c                          | 104 ++++++++++++++++--
>  drivers/Makefile                              |   2 +-
>  drivers/board/Kconfig                         |   2 +
>  drivers/board/Makefile                        |   2 +-
>  drivers/board/board-uclass.c                  |  11 ++
>  include/board.h                               |  72 ++++++++++++
>  scripts/Makefile.lib                          |   4 +
>  14 files changed, 230 insertions(+), 27 deletions(-)
>
> --
> 2.17.1
>

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

* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
  2019-08-05 10:28 ` [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Simon Goldschmidt
@ 2019-08-05 10:36   ` Jean-Jacques Hiblot
  2019-08-05 10:38     ` Simon Goldschmidt
  0 siblings, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-08-05 10:36 UTC (permalink / raw)
  To: u-boot


On 05/08/2019 12:28, Simon Goldschmidt wrote:
> On Mon, Aug 5, 2019 at 11:44 AM Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>>
>> The purpose of this series is to provide the SPL with ability to apply
>> overlays for u-boot. this is only a RFC so far, to get a feedback on the
>> approach.
> If it's RFC, shouldn't that be noted in the subject line?

Sorry I forgot to change that line in the cover letter. It is not a RFC 
anymore.

After the initial feedback was received I removed this from the subject 
line.

Thanks,

JJ

>
> Regards,
> Simon
>
>> Our use-case is the support of the daughter boards of the AM65x EVM. In
>> Linux, each board is supported by a unique overlay. The presence of the
>> boards is detected at runtime, and some useful features (like USB) are
>> implemented on those daughter boards. Instead of providing multiple dtbs
>> and fall in a combinatorial pit, we propose to use DT overlays.
>>
>> Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
>> a few weeks ago by Michal Simek.
>> Patch #3 to #6 amend Michal's patch.
>> Patch #7 to #9 are simple fixes for the Makefile
>> Patch #10 is used to reduce the complexity of the Makefile by having FIT
>> generator scripts provide their dependencies
>> Patch #12-#13 allow to use the board driver in SPL
>> Patch #14-#15 adds a way to dynamically select the DT overlays. That is
>> were we would use HW detection to select the required overlays. In that
>> case, the board driver code tells what overlay it needs (it gives the
>> name of the node).
>>
>> On arm, if overlay are supported, this series increases the size of the SPL
>> by 3.2 kB.
>>
>> Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404
>>
>> Changes in v4:
>> - use CONFIG_IS_ENABLED() instead of #idef
>> - make sure that the temp buffer is freed in all cases
>> - Use the board driver infrastructure to get the image names from the
>> board code.
>> - Remove a patch that passed the board name to the FIT generator. If needed
>> the generator can get it from elsewhere
>> - Add a fix to not load the firmware twice (once as a firmware and once as
>> a loadable)
>>
>> Changes in v3:
>> - Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
>> not selected.
>> - removed the RFC prefix. This work will be needed soon by TI's AM65x
>> platform. and can probably benefit other modular platforms
>> - removed the last patch that provided an example of how to use this with
>> on a DRA76.
>> - removed the patch that made u-boot.img a symlink to u-boot.itb because
>> it breaks the build of many platforms (because files required to build the
>> ITB are missing)
>> - removed the patch to reduce the footprint of the am335x SPL. (already
>> merged)
>> - Made the boot flow more permissive (don't fail immediately if an overlay
>> is not present) and more verbose when an error occures
>> - handle the dependencies of the FIT generation in a more generic way
>> - use a dedicated kconfig option to enable the application of the overlays
>> by the SPL.
>>
>> Changes in v2:
>> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
>> - removed dtbo generation from dtso files and use .dts extension for the
>>    overlays
>> - add dynamic allocation usage in a separate patch
>> - defconfig change for the am335x_evm
>>
>> Jean-Jacques Hiblot (14):
>>    spl: fit: don't load the firmware twice
>>    spl: fit: Make room in the FDT before applying overlays
>>    spl: fit: allocate a temporary buffer to load the overlays
>>    spl: fit: Do not fail immediately if an overlay is not available
>>    spl: fit: be more verbose when an error occurs when applying the
>>      overlays
>>    Makefile.lib: include /__symbols__ in dtb if
>>      SPL_LOAD_FIT_APPLY_OVERLAY is enabled
>>    Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
>>      CONFIG_SPL_FIT_GENERATOR
>>    Makefile: Fix u-boot.itb generation when building outside the source
>>      tree
>>    Makefile: Query the SPL Fit Generator for its dependencies
>>    spl: fit: constify the output parameter of spl_fit_get_image_name()
>>    drivers: board: Make the board drivers available in SPL
>>    drivers: board: Add get_fit_loadable()
>>    include: board: provide empty stubs when the BOARD option is not
>>      selected
>>    spl: fit: Allow the board to tell if more images must be loaded from
>>      FIT
>>
>> Michal Simek (1):
>>    spl: fit: Add support for applying DT overlay
>>
>>   Kconfig                                       |   9 ++
>>   Makefile                                      |  23 ++--
>>   arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
>>   arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
>>   board/sunxi/mksunxi_fit_atf.sh                |   4 +
>>   .../lion_rk3368/fit_spl_atf.its               |   6 +-
>>   .../puma_rk3399/fit_spl_atf.sh                |   6 +
>>   common/spl/spl_fit.c                          | 104 ++++++++++++++++--
>>   drivers/Makefile                              |   2 +-
>>   drivers/board/Kconfig                         |   2 +
>>   drivers/board/Makefile                        |   2 +-
>>   drivers/board/board-uclass.c                  |  11 ++
>>   include/board.h                               |  72 ++++++++++++
>>   scripts/Makefile.lib                          |   4 +
>>   14 files changed, 230 insertions(+), 27 deletions(-)
>>
>> --
>> 2.17.1
>>

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

* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
  2019-08-05 10:36   ` Jean-Jacques Hiblot
@ 2019-08-05 10:38     ` Simon Goldschmidt
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Goldschmidt @ 2019-08-05 10:38 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 5, 2019 at 12:36 PM Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
>
> On 05/08/2019 12:28, Simon Goldschmidt wrote:
> > On Mon, Aug 5, 2019 at 11:44 AM Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> >>
> >> The purpose of this series is to provide the SPL with ability to apply
> >> overlays for u-boot. this is only a RFC so far, to get a feedback on the
> >> approach.
> > If it's RFC, shouldn't that be noted in the subject line?
>
> Sorry I forgot to change that line in the cover letter. It is not a RFC
> anymore.
>
> After the initial feedback was received I removed this from the subject
> line.

Ah, ok. I was just wandering because of the double "PATCH PATCH"
in the subject line...

Regards,
Simon

>
> Thanks,
>
> JJ
>
> >
> > Regards,
> > Simon
> >
> >> Our use-case is the support of the daughter boards of the AM65x EVM. In
> >> Linux, each board is supported by a unique overlay. The presence of the
> >> boards is detected at runtime, and some useful features (like USB) are
> >> implemented on those daughter boards. Instead of providing multiple dtbs
> >> and fall in a combinatorial pit, we propose to use DT overlays.
> >>
> >> Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
> >> a few weeks ago by Michal Simek.
> >> Patch #3 to #6 amend Michal's patch.
> >> Patch #7 to #9 are simple fixes for the Makefile
> >> Patch #10 is used to reduce the complexity of the Makefile by having FIT
> >> generator scripts provide their dependencies
> >> Patch #12-#13 allow to use the board driver in SPL
> >> Patch #14-#15 adds a way to dynamically select the DT overlays. That is
> >> were we would use HW detection to select the required overlays. In that
> >> case, the board driver code tells what overlay it needs (it gives the
> >> name of the node).
> >>
> >> On arm, if overlay are supported, this series increases the size of the SPL
> >> by 3.2 kB.
> >>
> >> Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404
> >>
> >> Changes in v4:
> >> - use CONFIG_IS_ENABLED() instead of #idef
> >> - make sure that the temp buffer is freed in all cases
> >> - Use the board driver infrastructure to get the image names from the
> >> board code.
> >> - Remove a patch that passed the board name to the FIT generator. If needed
> >> the generator can get it from elsewhere
> >> - Add a fix to not load the firmware twice (once as a firmware and once as
> >> a loadable)
> >>
> >> Changes in v3:
> >> - Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
> >> not selected.
> >> - removed the RFC prefix. This work will be needed soon by TI's AM65x
> >> platform. and can probably benefit other modular platforms
> >> - removed the last patch that provided an example of how to use this with
> >> on a DRA76.
> >> - removed the patch that made u-boot.img a symlink to u-boot.itb because
> >> it breaks the build of many platforms (because files required to build the
> >> ITB are missing)
> >> - removed the patch to reduce the footprint of the am335x SPL. (already
> >> merged)
> >> - Made the boot flow more permissive (don't fail immediately if an overlay
> >> is not present) and more verbose when an error occures
> >> - handle the dependencies of the FIT generation in a more generic way
> >> - use a dedicated kconfig option to enable the application of the overlays
> >> by the SPL.
> >>
> >> Changes in v2:
> >> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
> >> - removed dtbo generation from dtso files and use .dts extension for the
> >>    overlays
> >> - add dynamic allocation usage in a separate patch
> >> - defconfig change for the am335x_evm
> >>
> >> Jean-Jacques Hiblot (14):
> >>    spl: fit: don't load the firmware twice
> >>    spl: fit: Make room in the FDT before applying overlays
> >>    spl: fit: allocate a temporary buffer to load the overlays
> >>    spl: fit: Do not fail immediately if an overlay is not available
> >>    spl: fit: be more verbose when an error occurs when applying the
> >>      overlays
> >>    Makefile.lib: include /__symbols__ in dtb if
> >>      SPL_LOAD_FIT_APPLY_OVERLAY is enabled
> >>    Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
> >>      CONFIG_SPL_FIT_GENERATOR
> >>    Makefile: Fix u-boot.itb generation when building outside the source
> >>      tree
> >>    Makefile: Query the SPL Fit Generator for its dependencies
> >>    spl: fit: constify the output parameter of spl_fit_get_image_name()
> >>    drivers: board: Make the board drivers available in SPL
> >>    drivers: board: Add get_fit_loadable()
> >>    include: board: provide empty stubs when the BOARD option is not
> >>      selected
> >>    spl: fit: Allow the board to tell if more images must be loaded from
> >>      FIT
> >>
> >> Michal Simek (1):
> >>    spl: fit: Add support for applying DT overlay
> >>
> >>   Kconfig                                       |   9 ++
> >>   Makefile                                      |  23 ++--
> >>   arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
> >>   arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
> >>   board/sunxi/mksunxi_fit_atf.sh                |   4 +
> >>   .../lion_rk3368/fit_spl_atf.its               |   6 +-
> >>   .../puma_rk3399/fit_spl_atf.sh                |   6 +
> >>   common/spl/spl_fit.c                          | 104 ++++++++++++++++--
> >>   drivers/Makefile                              |   2 +-
> >>   drivers/board/Kconfig                         |   2 +
> >>   drivers/board/Makefile                        |   2 +-
> >>   drivers/board/board-uclass.c                  |  11 ++
> >>   include/board.h                               |  72 ++++++++++++
> >>   scripts/Makefile.lib                          |   4 +
> >>   14 files changed, 230 insertions(+), 27 deletions(-)
> >>
> >> --
> >> 2.17.1
> >>

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

* [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
@ 2019-08-13  9:33   ` Simon Glass
  2019-08-13 20:56   ` Andreas Dannenberg
  1 sibling, 0 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:33 UTC (permalink / raw)
  To: u-boot

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> When u-boot.img is a FIT image generated automatically by mkimage, the
> configuration node has the following structure:
> conf-1 {
>    description = "k3-am654-base-board";
>    firmware = "firmware-1";
>    loadables = "firmware-1";
>    fdt = "fdt-1";
> };
>
> The firmware is referenced twice. Once by the 'firmware' property and
> once by the 'loadables' property. Currently this result in the firmware
> being loaded twice. This is not a big problem but has an impact on the
> boot time.
> Fixing it by not loading a loadable image if it is also the firmware image.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> Changes in v4: New
>
>  common/spl/spl_fit.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

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

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

* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
  2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
                   ` (15 preceding siblings ...)
  2019-08-05 10:28 ` [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Simon Goldschmidt
@ 2019-08-13  9:33 ` Simon Glass
  2019-09-11 13:39   ` Jean-Jacques Hiblot
  16 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:33 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
>
> The purpose of this series is to provide the SPL with ability to apply
> overlays for u-boot. this is only a RFC so far, to get a feedback on the
> approach.
>
> Our use-case is the support of the daughter boards of the AM65x EVM. In
> Linux, each board is supported by a unique overlay. The presence of the
> boards is detected at runtime, and some useful features (like USB) are
> implemented on those daughter boards. Instead of providing multiple dtbs
> and fall in a combinatorial pit, we propose to use DT overlays.

But why do this in SPL? Is it so U-Boot can use the DT with overlays
itself for driver model?

>
> Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
> a few weeks ago by Michal Simek.
> Patch #3 to #6 amend Michal's patch.
> Patch #7 to #9 are simple fixes for the Makefile
> Patch #10 is used to reduce the complexity of the Makefile by having FIT
> generator scripts provide their dependencies
> Patch #12-#13 allow to use the board driver in SPL
> Patch #14-#15 adds a way to dynamically select the DT overlays. That is
> were we would use HW detection to select the required overlays. In that
> case, the board driver code tells what overlay it needs (it gives the
> name of the node).
>
> On arm, if overlay are supported, this series increases the size of the SPL
> by 3.2 kB.
>
> Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404
>
> Changes in v4:
> - use CONFIG_IS_ENABLED() instead of #idef
> - make sure that the temp buffer is freed in all cases
> - Use the board driver infrastructure to get the image names from the
> board code.
> - Remove a patch that passed the board name to the FIT generator. If needed
> the generator can get it from elsewhere
> - Add a fix to not load the firmware twice (once as a firmware and once as
> a loadable)
>
> Changes in v3:
> - Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
> not selected.
> - removed the RFC prefix. This work will be needed soon by TI's AM65x
> platform. and can probably benefit other modular platforms
> - removed the last patch that provided an example of how to use this with
> on a DRA76.
> - removed the patch that made u-boot.img a symlink to u-boot.itb because
> it breaks the build of many platforms (because files required to build the
> ITB are missing)
> - removed the patch to reduce the footprint of the am335x SPL. (already
> merged)
> - Made the boot flow more permissive (don't fail immediately if an overlay
> is not present) and more verbose when an error occures
> - handle the dependencies of the FIT generation in a more generic way
> - use a dedicated kconfig option to enable the application of the overlays
> by the SPL.
>
> Changes in v2:
> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
> - removed dtbo generation from dtso files and use .dts extension for the
>   overlays
> - add dynamic allocation usage in a separate patch
> - defconfig change for the am335x_evm
>
> Jean-Jacques Hiblot (14):
>   spl: fit: don't load the firmware twice
>   spl: fit: Make room in the FDT before applying overlays
>   spl: fit: allocate a temporary buffer to load the overlays
>   spl: fit: Do not fail immediately if an overlay is not available
>   spl: fit: be more verbose when an error occurs when applying the
>     overlays
>   Makefile.lib: include /__symbols__ in dtb if
>     SPL_LOAD_FIT_APPLY_OVERLAY is enabled
>   Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
>     CONFIG_SPL_FIT_GENERATOR
>   Makefile: Fix u-boot.itb generation when building outside the source
>     tree
>   Makefile: Query the SPL Fit Generator for its dependencies
>   spl: fit: constify the output parameter of spl_fit_get_image_name()
>   drivers: board: Make the board drivers available in SPL
>   drivers: board: Add get_fit_loadable()
>   include: board: provide empty stubs when the BOARD option is not
>     selected
>   spl: fit: Allow the board to tell if more images must be loaded from
>     FIT
>
> Michal Simek (1):
>   spl: fit: Add support for applying DT overlay
>
>  Kconfig                                       |   9 ++
>  Makefile                                      |  23 ++--
>  arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
>  arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
>  board/sunxi/mksunxi_fit_atf.sh                |   4 +
>  .../lion_rk3368/fit_spl_atf.its               |   6 +-
>  .../puma_rk3399/fit_spl_atf.sh                |   6 +
>  common/spl/spl_fit.c                          | 104 ++++++++++++++++--
>  drivers/Makefile                              |   2 +-
>  drivers/board/Kconfig                         |   2 +
>  drivers/board/Makefile                        |   2 +-
>  drivers/board/board-uclass.c                  |  11 ++
>  include/board.h                               |  72 ++++++++++++
>  scripts/Makefile.lib                          |   4 +
>  14 files changed, 230 insertions(+), 27 deletions(-)
>
> --
> 2.17.1
>

Please can we have a sandbox test for this?

Regards,
SImon

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays Jean-Jacques Hiblot
@ 2019-08-13  9:33   ` Simon Glass
  2019-09-11 13:32     ` Jean-Jacques Hiblot
  2019-09-12 15:34     ` Jean-Jacques Hiblot
  0 siblings, 2 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:33 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> If the node describing an overlay does not specify a load address, it will
> be loaded at the address previously used.
> Fixing it by allocating a temporary 64kB region that will be used as a
> default load address.

How did you come to decide on 64KB? Might this be too large or too small?

>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
>
> Changes in v4:
> - make sure that the temp buffer is freed in all cases
>
> Changes in v3: None
> Changes in v2: None
>
>  common/spl/spl_fit.c | 28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index ab47da5094..977074cd99 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -8,8 +8,9 @@
>  #include <errno.h>
>  #include <fpga.h>
>  #include <image.h>
> -#include <linux/libfdt.h>
> +#include <malloc.h>
>  #include <spl.h>
> +#include <linux/libfdt.h>
>
>  #ifndef CONFIG_SYS_BOOTM_LEN
>  #define CONFIG_SYS_BOOTM_LEN   (64 << 20)
> @@ -302,33 +303,50 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>         spl_image->fdt_addr = (void *)image_info.load_addr;
>  #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
>         if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
> +               void *tmpbuffer;
> +               /*
> +                * allocate 64KB of memory. This will be used to store the DT
> +                * overlay before it is applied. It may not be used depending on
> +                * how the overlay is stored, so don't fail yet if the
> +                * allocation failed.
> +                */
> +               tmpbuffer = malloc(64 * 1024);
> +               if (!tmpbuffer)
> +                       debug("%s: unable to allocate space for overlays\n",
> +                             __func__);

Can you adjust this to only allocate buf when you find it is needed?

> +
>                 for (; ; index++) {
>                         node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
>                                                       index);
>                         if (node < 0) {
>                                 debug("%s: No additional FDT node\n", __func__);
> -                               return 0;
> +                               break;
>                         }
>
> +                       image_info.load_addr = (ulong)tmpbuffer;

map_to_sysmem() or this won't work on sandbox.

>                         ret = spl_load_fit_image(info, sector, fit, base_offset,
>                                                  node, &image_info);
>                         if (ret < 0)
> -                               return ret;
> +                               break;
>
>                         /* Make room in FDT for changes from the overlay */
>                         ret = fdt_increase_size(spl_image->fdt_addr,
>                                                 image_info.size);
>                         if (ret < 0)
> -                               return ret;
> +                               break;
>
>                         ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
>                                                         (void *)image_info.load_addr);

map_sysmem()

>                         if (ret)
> -                               return ret;
> +                               break;
>
>                         debug("%s: DT overlay %s applied\n", __func__,
>                               fit_get_name(fit, node, NULL));
>                 }
> +               if (tmpbuffer)
> +                       free(tmpbuffer);
> +               if (ret)
> +                       return ret;
>         }
>         /* Try to make space, so we can inject details on the loadables */
>         ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
> --
> 2.17.1
>

Regads,
Simon

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

* [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL Jean-Jacques Hiblot
@ 2019-08-13  9:33   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:33 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

Missing commit message.

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> Changes in v4: New
>
>  drivers/Makefile       | 2 +-
>  drivers/board/Kconfig  | 2 ++
>  drivers/board/Makefile | 2 +-
>  3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 41933605ce..30ead18b06 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -26,6 +26,7 @@ obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
>  obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
>  obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
>  obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
> +obj-$(CONFIG_$(SPL_)BOARD) += board/
>
>  ifndef CONFIG_TPL_BUILD
>  ifdef CONFIG_SPL_BUILD
> @@ -77,7 +78,6 @@ obj-y += ata/
>  obj-$(CONFIG_DM_DEMO) += demo/
>  obj-$(CONFIG_BIOSEMU) += bios_emulator/
>  obj-y += block/
> -obj-y += board/
>  obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
>  obj-y += cache/
>  obj-$(CONFIG_CPU) += cpu/
> diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig
> index 2a3fc9c049..a94c4fb368 100644
> --- a/drivers/board/Kconfig
> +++ b/drivers/board/Kconfig
> @@ -8,6 +8,8 @@ menuconfig BOARD
>
>  if BOARD
>
> +config SPL_BOARD
> +       bool "Enable board driver support in SPL"

help

default y if SANDBOX_SPL ?

>
>  config BOARD_GAZERBEAM
>         bool "Enable board driver for the Gazerbeam board"
> diff --git a/drivers/board/Makefile b/drivers/board/Makefile
> index c8dab4fa0b..cc16361755 100644
> --- a/drivers/board/Makefile
> +++ b/drivers/board/Makefile
> @@ -2,6 +2,6 @@
>  #
>  # (C) Copyright 2017
>  # Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
> -obj-$(CONFIG_BOARD) += board-uclass.o
> +obj-y += board-uclass.o
>  obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o
>  obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o
> --
> 2.17.1
>

Regards,
Simon

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

* [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable()
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable() Jean-Jacques Hiblot
@ 2019-08-13  9:34   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:34 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> This function will be used by the SPL to get the names of images to load
> from the FIT. This allows to load different images based on runtime HW
> detection.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> Changes in v4: New
>
>  drivers/board/board-uclass.c | 11 +++++++++++
>  include/board.h              | 35 +++++++++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
>
> diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
> index a516ba4962..4af991e176 100644
> --- a/drivers/board/board-uclass.c
> +++ b/drivers/board/board-uclass.c
> @@ -23,6 +23,17 @@ int board_detect(struct udevice *dev)
>         return ops->detect(dev);
>  }
>
> +const char *board_get_fit_loadable(struct udevice *dev, int index,
> +                                  const char *type)
> +{
> +       struct board_ops *ops = board_get_ops(dev);
> +
> +       if (!ops->get_fit_loadable)
> +               return NULL;

Please make the function return an int error code - here it should be -ENOSYS.

> +
> +       return ops->get_fit_loadable(dev, index, type);
> +}
> +
>  int board_get_bool(struct udevice *dev, int id, bool *val)
>  {
>         struct board_ops *ops = board_get_ops(dev);
> diff --git a/include/board.h b/include/board.h
> index 9dc78684f8..0f4f1aadeb 100644
> --- a/include/board.h
> +++ b/include/board.h
> @@ -79,6 +79,24 @@ struct board_ops {
>          * Return: 0 if OK, -ve on error.
>          */
>         int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
> +
> +       /**
> +        * get_fit_loadable - Get the name of an image to load from FIT
> +        * This function can be used to provide the image names based on runtime
> +        * detection. A classic use-case would when DTBOs are used to describe
> +        * additionnal daughter cards.
> +        *
> +        * @dev:        The board instance to gather the data.
> +        * @index:      Index of the image. Starts at 0 and gets incremented
> +        *              after each call to this function.

You mean that the caller should do this? And then stop when it sees
-ENOENT for that index?

> +        * @type:       The type of image. For example, "fdt" for DTBs
> +        *
> +        * return:      The name of the node describing the image. NULL
> +        *              indicates that there no more image to get from this
> +        *              function.
> +        */
> +       const char *(*get_fit_loadable)(struct udevice *dev, int index,
> +                                       const char *type);

The return value should move to an argument so you can return an error.

-ENOENT - no loadable for this type for the given index

>  };
>
>  #define board_get_ops(dev)     ((struct board_ops *)(dev)->driver->ops)
> @@ -137,3 +155,20 @@ int board_get_str(struct udevice *dev, int id, size_t size, char *val);
>   * Return: 0 if OK, -ve on error.
>   */
>  int board_get(struct udevice **devp);
> +
> +/**
> + * board_get_fit_loadable - Get the name of an image to load from FIT
> + * This function can be used to provide the image names based on runtime
> + * detection. A classic use-case would when DTBOs are used to describe
> + * additionnal daughter cards.
> + *
> + * @dev:       The board instance to gather the data.
> + * @index:     Index of the image. Starts at 0 and gets incremented
> + *             after each call to this function.
> + * @type:      The type of image. For example, "fdt" for DTBs
> + *
> + * return:     The name of the node describing the image. NULL indicates
> + *             that there no more images to get from this function.
> + */
> +const char *board_get_fit_loadable(struct udevice *dev, int index,
> +                                  const char *type);
> --
> 2.17.1
>

Regards,
Simon

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

* [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected Jean-Jacques Hiblot
@ 2019-08-13  9:34   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:34 UTC (permalink / raw)
  To: u-boot

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> Useful to avoid #ifdef throughout the code that uses the board driver API.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> Changes in v4: New
>
>  include/board.h | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)

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

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

* [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT
  2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT Jean-Jacques Hiblot
@ 2019-08-13  9:34   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2019-08-13  9:34 UTC (permalink / raw)
  To: u-boot

On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> spl_fit_get_image_name() is used to get the names of the images that the
> SPL must load from the FIT. It relies on the content of a property present
> in the FIT. The list of images is thus statically defined in the FIT.
> With this scheme, it becomes quickly hard to manage combinations of more

quickly becomes

> than a hand few of images.

handful of images

> To address this problem, give the board driver code the opportunity to
> add to the list of images. The images from the FIT property are loaded
> first, and then the board_get_fit_loadable() is called to get more image
> names.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
>
> Changes in v4:
> - Use the board driver infrastructure to get the image names from the
> board code.
>
> Changes in v3:
> - removed the RFC prefix. This work will be needed soon by TI's AM65x
> platform. and can probably benefit other modular platforms
> - removed the last patch that provided an example of how to use this with
> on a DRA76.
> - removed the patch that made u-boot.img a symlink to u-boot.itb because
> it breaks the build of many platforms (because files required to build the
> ITB are missing)
> - removed the patch to reduce the footprint of the am335x SPL. (already
> merged)
> - Made the boot flow more permissive (don't fail immediately if an overlay
> is not present) and more verbose when an error occures
> - handle the dependencies of the FIT generation in a more generic way
> - use a dedicated kconfig option to enable the application of the overlays
> by the SPL.
>
> Changes in v2:
> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
> - removed dtbo generation from dtso files and use .dts extension for the
>   overlays
> - add dynamic allocation usage in a separate patch
> - defconfig change for the am335x_evm
>
>  common/spl/spl_fit.c | 24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)

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


>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 2f555a2f13..2879b76578 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -6,6 +6,7 @@
>
>  #include <common.h>
>  #include <errno.h>
> +#include <board.h>
>  #include <fpga.h>
>  #include <image.h>
>  #include <malloc.h>
> @@ -41,10 +42,12 @@ static int spl_fit_get_image_name(const void *fit, int images,
>                                   const char *type, int index,
>                                   const char **outname)
>  {
> +       struct udevice *board;
>         const char *name, *str;
>         __maybe_unused int node;
>         int conf_node;
>         int len, i;
> +       bool found = true;
>
>         conf_node = fit_find_config_node(fit);
>         if (conf_node < 0) {
> @@ -70,12 +73,27 @@ static int spl_fit_get_image_name(const void *fit, int images,
>         for (i = 0; i < index; i++) {
>                 str = strchr(str, '\0') + 1;
>                 if (!str || (str - name >= len)) {
> -                       debug("no string for index %d\n", index);
> -                       return -E2BIG;
> +                       found = false;
> +                       break;
>                 }
>         }
>
> -       *outname = (char *)str;
> +       if (!found && !board_get(&board)) {
> +               /*
> +                * no string in the property for this index. Check if the board
> +                * level code can supply one.

board-level


> +                */
> +               str = board_get_fit_loadable(board, index - i - 1, type);
> +               if (str)
> +                       found = true;
> +       }
> +
> +       if (!found) {
> +               debug("no string for index %d\n", index);
> +               return -E2BIG;
> +       }
> +
> +       *outname = str;
>         return 0;
>  }
>
> --
> 2.17.1
>

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

* [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice
  2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
  2019-08-13  9:33   ` Simon Glass
@ 2019-08-13 20:56   ` Andreas Dannenberg
  1 sibling, 0 replies; 32+ messages in thread
From: Andreas Dannenberg @ 2019-08-13 20:56 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 05, 2019 at 11:43:56AM +0200, Jean-Jacques Hiblot wrote:
> When u-boot.img is a FIT image generated automatically by mkimage, the
> configuration node has the following structure:
> conf-1 {
>    description = "k3-am654-base-board";
>    firmware = "firmware-1";
>    loadables = "firmware-1";
>    fdt = "fdt-1";
> };
> 
> The firmware is referenced twice. Once by the 'firmware' property and
> once by the 'loadables' property. Currently this result in the firmware
> being loaded twice. This is not a big problem but has an impact on the
> boot time.
> Fixing it by not loading a loadable image if it is also the firmware image.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---


Tested-by: Andreas Dannenberg <dannenberg@ti.com>


I was working on getting UART boot to work on TI's AM654x devices and
just ran into this very issue (took a while to root cause). Unlike when
booting from MMC it's not just redundant to load the same image (U-Boot
proper in my case) twice -- it simply won't work.

--
Andreas Dannenberg
Texas Instruments Inc



> 
> Changes in v4: New
> 
>  common/spl/spl_fit.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 969f7775c1..0de18e3975 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -361,6 +361,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
>  	int images, ret;
>  	int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
>  	int index = 0;
> +	int firmware_node;
>  
>  	/*
>  	 * For FIT with external data, figure out where the external images
> @@ -490,6 +491,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
>  		spl_fit_append_fdt(spl_image, info, sector, fit,
>  				   images, base_offset);
>  
> +	firmware_node = node;
>  	/* Now check if there are more images for us to load */
>  	for (; ; index++) {
>  		uint8_t os_type = IH_OS_INVALID;
> @@ -498,6 +500,14 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
>  		if (node < 0)
>  			break;
>  
> +		/*
> +		 * if the firmware is also a loadable, skip it because
> +		 * it already has been loaded. This is typically the case with
> +		 * u-boot.img generated by mkimage.
> +		 */
> +		if (firmware_node == node)
> +			continue;
> +
>  		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
>  					 &image_info);
>  		if (ret < 0)
> -- 
> 2.17.1
> 

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-08-13  9:33   ` Simon Glass
@ 2019-09-11 13:32     ` Jean-Jacques Hiblot
  2019-09-17  5:48       ` Simon Glass
  2019-09-12 15:34     ` Jean-Jacques Hiblot
  1 sibling, 1 reply; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-09-11 13:32 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 13/08/2019 11:33, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>> If the node describing an overlay does not specify a load address, it will
>> be loaded at the address previously used.
>> Fixing it by allocating a temporary 64kB region that will be used as a
>> default load address.
> How did you come to decide on 64KB? Might this be too large or too small?

It seemed big enough to me to accommodate a DTB overlay.

There is no easy way to know how big the buffer must be without reading 
it first because it can be compressed.

>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>>
>> ---
>>
>> Changes in v4:
>> - make sure that the temp buffer is freed in all cases
>>
>> Changes in v3: None
>> Changes in v2: None
>>
>>   common/spl/spl_fit.c | 28 +++++++++++++++++++++++-----
>>   1 file changed, 23 insertions(+), 5 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index ab47da5094..977074cd99 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -8,8 +8,9 @@
>>   #include <errno.h>
>>   #include <fpga.h>
>>   #include <image.h>
>> -#include <linux/libfdt.h>
>> +#include <malloc.h>
>>   #include <spl.h>
>> +#include <linux/libfdt.h>
>>
>>   #ifndef CONFIG_SYS_BOOTM_LEN
>>   #define CONFIG_SYS_BOOTM_LEN   (64 << 20)
>> @@ -302,33 +303,50 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>>          spl_image->fdt_addr = (void *)image_info.load_addr;
>>   #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
>>          if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
>> +               void *tmpbuffer;
>> +               /*
>> +                * allocate 64KB of memory. This will be used to store the DT
>> +                * overlay before it is applied. It may not be used depending on
>> +                * how the overlay is stored, so don't fail yet if the
>> +                * allocation failed.
>> +                */
>> +               tmpbuffer = malloc(64 * 1024);
>> +               if (!tmpbuffer)
>> +                       debug("%s: unable to allocate space for overlays\n",
>> +                             __func__);
> Can you adjust this to only allocate buf when you find it is needed?
could be done.
>
>> +
>>                  for (; ; index++) {
>>                          node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
>>                                                        index);
>>                          if (node < 0) {
>>                                  debug("%s: No additional FDT node\n", __func__);
>> -                               return 0;
>> +                               break;
>>                          }
>>
>> +                       image_info.load_addr = (ulong)tmpbuffer;
> map_to_sysmem() or this won't work on sandbox.
ok
>
>>                          ret = spl_load_fit_image(info, sector, fit, base_offset,
>>                                                   node, &image_info);
>>                          if (ret < 0)
>> -                               return ret;
>> +                               break;
>>
>>                          /* Make room in FDT for changes from the overlay */
>>                          ret = fdt_increase_size(spl_image->fdt_addr,
>>                                                  image_info.size);
>>                          if (ret < 0)
>> -                               return ret;
>> +                               break;
>>
>>                          ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
>>                                                          (void *)image_info.load_addr);
> map_sysmem()
>
>>                          if (ret)
>> -                               return ret;
>> +                               break;
>>
>>                          debug("%s: DT overlay %s applied\n", __func__,
>>                                fit_get_name(fit, node, NULL));
>>                  }
>> +               if (tmpbuffer)
>> +                       free(tmpbuffer);
>> +               if (ret)
>> +                       return ret;
>>          }
>>          /* Try to make space, so we can inject details on the loadables */
>>          ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
>> --
>> 2.17.1
>>
> Regads,
> Simon
>

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

* [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL
  2019-08-13  9:33 ` Simon Glass
@ 2019-09-11 13:39   ` Jean-Jacques Hiblot
  0 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-09-11 13:39 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 13/08/2019 11:33, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>>
>> The purpose of this series is to provide the SPL with ability to apply
>> overlays for u-boot. this is only a RFC so far, to get a feedback on the
>> approach.
>>
>> Our use-case is the support of the daughter boards of the AM65x EVM. In
>> Linux, each board is supported by a unique overlay. The presence of the
>> boards is detected at runtime, and some useful features (like USB) are
>> implemented on those daughter boards. Instead of providing multiple dtbs
>> and fall in a combinatorial pit, we propose to use DT overlays.
> But why do this in SPL? Is it so U-Boot can use the DT with overlays
> itself for driver model?

Sorry for the long delay.

You are right, the goal is to be able to apply DTB overlays in the SPL 
so that u-boot the DTB+ overlays for its driver model.

Our platform for example has optional daughter cards with various 
combination of PCIe, USB and Ethernet.

At the kernel level the hardware is described in separate overlays. 
U-boot is responsible to detect the HW and load/apply the needed overlays.

We want to do the same in u-boot and the SPL will load/apply the right 
overlays.

JJ

>
>> Patch #2 "spl: fit: Add support for applying DT overlay" has been posted
>> a few weeks ago by Michal Simek.
>> Patch #3 to #6 amend Michal's patch.
>> Patch #7 to #9 are simple fixes for the Makefile
>> Patch #10 is used to reduce the complexity of the Makefile by having FIT
>> generator scripts provide their dependencies
>> Patch #12-#13 allow to use the board driver in SPL
>> Patch #14-#15 adds a way to dynamically select the DT overlays. That is
>> were we would use HW detection to select the required overlays. In that
>> case, the board driver code tells what overlay it needs (it gives the
>> name of the node).
>>
>> On arm, if overlay are supported, this series increases the size of the SPL
>> by 3.2 kB.
>>
>> Travis build : https://travis-ci.org/jjhiblot/u-boot/builds/567779404
>>
>> Changes in v4:
>> - use CONFIG_IS_ENABLED() instead of #idef
>> - make sure that the temp buffer is freed in all cases
>> - Use the board driver infrastructure to get the image names from the
>> board code.
>> - Remove a patch that passed the board name to the FIT generator. If needed
>> the generator can get it from elsewhere
>> - Add a fix to not load the firmware twice (once as a firmware and once as
>> a loadable)
>>
>> Changes in v3:
>> - Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
>> not selected.
>> - removed the RFC prefix. This work will be needed soon by TI's AM65x
>> platform. and can probably benefit other modular platforms
>> - removed the last patch that provided an example of how to use this with
>> on a DRA76.
>> - removed the patch that made u-boot.img a symlink to u-boot.itb because
>> it breaks the build of many platforms (because files required to build the
>> ITB are missing)
>> - removed the patch to reduce the footprint of the am335x SPL. (already
>> merged)
>> - Made the boot flow more permissive (don't fail immediately if an overlay
>> is not present) and more verbose when an error occures
>> - handle the dependencies of the FIT generation in a more generic way
>> - use a dedicated kconfig option to enable the application of the overlays
>> by the SPL.
>>
>> Changes in v2:
>> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
>> - removed dtbo generation from dtso files and use .dts extension for the
>>    overlays
>> - add dynamic allocation usage in a separate patch
>> - defconfig change for the am335x_evm
>>
>> Jean-Jacques Hiblot (14):
>>    spl: fit: don't load the firmware twice
>>    spl: fit: Make room in the FDT before applying overlays
>>    spl: fit: allocate a temporary buffer to load the overlays
>>    spl: fit: Do not fail immediately if an overlay is not available
>>    spl: fit: be more verbose when an error occurs when applying the
>>      overlays
>>    Makefile.lib: include /__symbols__ in dtb if
>>      SPL_LOAD_FIT_APPLY_OVERLAY is enabled
>>    Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and
>>      CONFIG_SPL_FIT_GENERATOR
>>    Makefile: Fix u-boot.itb generation when building outside the source
>>      tree
>>    Makefile: Query the SPL Fit Generator for its dependencies
>>    spl: fit: constify the output parameter of spl_fit_get_image_name()
>>    drivers: board: Make the board drivers available in SPL
>>    drivers: board: Add get_fit_loadable()
>>    include: board: provide empty stubs when the BOARD option is not
>>      selected
>>    spl: fit: Allow the board to tell if more images must be loaded from
>>      FIT
>>
>> Michal Simek (1):
>>    spl: fit: Add support for applying DT overlay
>>
>>   Kconfig                                       |   9 ++
>>   Makefile                                      |  23 ++--
>>   arch/arm/mach-imx/mkimage_fit_atf.sh          |   5 +
>>   arch/arm/mach-rockchip/make_fit_atf.py        |   7 ++
>>   board/sunxi/mksunxi_fit_atf.sh                |   4 +
>>   .../lion_rk3368/fit_spl_atf.its               |   6 +-
>>   .../puma_rk3399/fit_spl_atf.sh                |   6 +
>>   common/spl/spl_fit.c                          | 104 ++++++++++++++++--
>>   drivers/Makefile                              |   2 +-
>>   drivers/board/Kconfig                         |   2 +
>>   drivers/board/Makefile                        |   2 +-
>>   drivers/board/board-uclass.c                  |  11 ++
>>   include/board.h                               |  72 ++++++++++++
>>   scripts/Makefile.lib                          |   4 +
>>   14 files changed, 230 insertions(+), 27 deletions(-)
>>
>> --
>> 2.17.1
>>
> Please can we have a sandbox test for this?
>
> Regards,
> SImon
>

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-08-13  9:33   ` Simon Glass
  2019-09-11 13:32     ` Jean-Jacques Hiblot
@ 2019-09-12 15:34     ` Jean-Jacques Hiblot
  1 sibling, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-09-12 15:34 UTC (permalink / raw)
  To: u-boot


On 13/08/2019 11:33, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>> If the node describing an overlay does not specify a load address, it will
>> be loaded at the address previously used.
>> Fixing it by allocating a temporary 64kB region that will be used as a
>> default load address.
> How did you come to decide on 64KB? Might this be too large or too small?
>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>>
>> ---
>>
>> Changes in v4:
>> - make sure that the temp buffer is freed in all cases
>>
>> Changes in v3: None
>> Changes in v2: None
>>
>>   common/spl/spl_fit.c | 28 +++++++++++++++++++++++-----
>>   1 file changed, 23 insertions(+), 5 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index ab47da5094..977074cd99 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -8,8 +8,9 @@
>>   #include <errno.h>
>>   #include <fpga.h>
>>   #include <image.h>
>> -#include <linux/libfdt.h>
>> +#include <malloc.h>
>>   #include <spl.h>
>> +#include <linux/libfdt.h>
>>
>>   #ifndef CONFIG_SYS_BOOTM_LEN
>>   #define CONFIG_SYS_BOOTM_LEN   (64 << 20)
>> @@ -302,33 +303,50 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>>          spl_image->fdt_addr = (void *)image_info.load_addr;
>>   #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
>>          if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
>> +               void *tmpbuffer;
>> +               /*
>> +                * allocate 64KB of memory. This will be used to store the DT
>> +                * overlay before it is applied. It may not be used depending on
>> +                * how the overlay is stored, so don't fail yet if the
>> +                * allocation failed.
>> +                */
>> +               tmpbuffer = malloc(64 * 1024);
>> +               if (!tmpbuffer)
>> +                       debug("%s: unable to allocate space for overlays\n",
>> +                             __func__);
> Can you adjust this to only allocate buf when you find it is needed?
>
>> +
>>                  for (; ; index++) {
>>                          node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
>>                                                        index);
>>                          if (node < 0) {
>>                                  debug("%s: No additional FDT node\n", __func__);
>> -                               return 0;
>> +                               break;
>>                          }
>>
>> +                       image_info.load_addr = (ulong)tmpbuffer;
> map_to_sysmem() or this won't work on sandbox.

This makes me think that loading u-boot from a FIT image in SPL probably 
doesn't work on sandbox, otherwise there would be some call to 
map-sysmem() in spl_load_fit_image().

This seems like a big task and honestly I don't have time to work on it. 
So I'll forgo the map_system()/map_to_sysmem(); adding them will only 
trick people into thinking that this work on sandbox.

>>                          ret = spl_load_fit_image(info, sector, fit, base_offset,
>>                                                   node, &image_info);
>>                          if (ret < 0)
>> -                               return ret;
>> +                               break;
>>
>>                          /* Make room in FDT for changes from the overlay */
>>                          ret = fdt_increase_size(spl_image->fdt_addr,
>>                                                  image_info.size);
>>                          if (ret < 0)
>> -                               return ret;
>> +                               break;
>>
>>                          ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
>>                                                          (void *)image_info.load_addr);
> map_sysmem()
>
>>                          if (ret)
>> -                               return ret;
>> +                               break;
>>
>>                          debug("%s: DT overlay %s applied\n", __func__,
>>                                fit_get_name(fit, node, NULL));
>>                  }
>> +               if (tmpbuffer)
>> +                       free(tmpbuffer);
>> +               if (ret)
>> +                       return ret;
>>          }
>>          /* Try to make space, so we can inject details on the loadables */
>>          ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
>> --
>> 2.17.1
>>
> Regads,
> Simon
>

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-09-11 13:32     ` Jean-Jacques Hiblot
@ 2019-09-17  5:48       ` Simon Glass
  2019-09-20 14:37         ` Jean-Jacques Hiblot
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2019-09-17  5:48 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Wed, 11 Sep 2019 at 06:32, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> Hi Simon,
>
> On 13/08/2019 11:33, Simon Glass wrote:
> > Hi Jean-Jacques,
> >
> > On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> >> If the node describing an overlay does not specify a load address, it will
> >> be loaded at the address previously used.
> >> Fixing it by allocating a temporary 64kB region that will be used as a
> >> default load address.
> > How did you come to decide on 64KB? Might this be too large or too small?
>
> It seemed big enough to me to accommodate a DTB overlay.
>
> There is no easy way to know how big the buffer must be without reading
> it first because it can be compressed.

You should be able to check the header to see the uncompressed size.

Regards,
Simon

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

* [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays
  2019-09-17  5:48       ` Simon Glass
@ 2019-09-20 14:37         ` Jean-Jacques Hiblot
  0 siblings, 0 replies; 32+ messages in thread
From: Jean-Jacques Hiblot @ 2019-09-20 14:37 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 17/09/2019 07:48, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On Wed, 11 Sep 2019 at 06:32, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>> Hi Simon,
>>
>> On 13/08/2019 11:33, Simon Glass wrote:
>>> Hi Jean-Jacques,
>>>
>>> On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>>>> If the node describing an overlay does not specify a load address, it will
>>>> be loaded at the address previously used.
>>>> Fixing it by allocating a temporary 64kB region that will be used as a
>>>> default load address.
>>> How did you come to decide on 64KB? Might this be too large or too small?
>> It seemed big enough to me to accommodate a DTB overlay.
>>
>> There is no easy way to know how big the buffer must be without reading
>> it first because it can be compressed.
> You should be able to check the header to see the uncompressed size.

I looked into that, and there is no uncompressed size in the GZIP header.

We cannot know the size in advance.

JJ

>
> Regards,
> Simon
>

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

end of thread, other threads:[~2019-09-20 14:37 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05  9:43 [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Jean-Jacques Hiblot
2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 01/15] spl: fit: don't load the firmware twice Jean-Jacques Hiblot
2019-08-13  9:33   ` Simon Glass
2019-08-13 20:56   ` Andreas Dannenberg
2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 02/15] spl: fit: Add support for applying DT overlay Jean-Jacques Hiblot
2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 03/15] spl: fit: Make room in the FDT before applying overlays Jean-Jacques Hiblot
2019-08-05  9:43 ` [U-Boot] [PATCH PATCH v4 04/15] spl: fit: allocate a temporary buffer to load the overlays Jean-Jacques Hiblot
2019-08-13  9:33   ` Simon Glass
2019-09-11 13:32     ` Jean-Jacques Hiblot
2019-09-17  5:48       ` Simon Glass
2019-09-20 14:37         ` Jean-Jacques Hiblot
2019-09-12 15:34     ` Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 05/15] spl: fit: Do not fail immediately if an overlay is not available Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 06/15] spl: fit: be more verbose when an error occurs when applying the overlays Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 07/15] Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 08/15] Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 09/15] Makefile: Fix u-boot.itb generation when building outside the source tree Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 10/15] Makefile: Query the SPL Fit Generator for its dependencies Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 11/15] spl: fit: constify the output parameter of spl_fit_get_image_name() Jean-Jacques Hiblot
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 12/15] drivers: board: Make the board drivers available in SPL Jean-Jacques Hiblot
2019-08-13  9:33   ` Simon Glass
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable() Jean-Jacques Hiblot
2019-08-13  9:34   ` Simon Glass
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected Jean-Jacques Hiblot
2019-08-13  9:34   ` Simon Glass
2019-08-05  9:44 ` [U-Boot] [PATCH PATCH v4 15/15] spl: fit: Allow the board to tell if more images must be loaded from FIT Jean-Jacques Hiblot
2019-08-13  9:34   ` Simon Glass
2019-08-05 10:28 ` [U-Boot] [PATCH PATCH v4 00/15] Add support for applications of overlays in SPL Simon Goldschmidt
2019-08-05 10:36   ` Jean-Jacques Hiblot
2019-08-05 10:38     ` Simon Goldschmidt
2019-08-13  9:33 ` Simon Glass
2019-09-11 13:39   ` Jean-Jacques Hiblot

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.