Skip to contentSkip to conversation

Add support for applications of overlays in SPL

PATCH Superseded Jean-Jacques Hiblot 4 participants 32 messages May 23, 2019 – Jul 30, 2019

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add support for applications of overlays in SPL

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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                                       | 10 +++
 Makefile                                      | 23 +++--
 arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
 arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
 board/sunxi/mksunxi_fit_atf.sh                |  7 ++
 .../lion_rk3368/fit_spl_atf.its               |  6 +-
 .../puma_rk3399/fit_spl_atf.its               |  8 +-
 common/spl/spl_fit.c                          | 90 +++++++++++++++++--
 include/spl.h                                 | 16 ++++
 scripts/Makefile.lib                          |  4 +
 10 files changed, 156 insertions(+), 31 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/12 spl: fit: Add support for applying DT overlay

From: Michal Simek <[email protected]>

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.

---

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

Changes in v2: None

 Kconfig              | 10 ++++++++++
 common/spl/spl_fit.c | 27 +++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)
Kconfig +10 -0
index 5f5c5ccfd6..8197c9066a 100644
@@ -398,6 +398,16 @@ 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
+	default n
+	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"
 	select SPL_FIT
common/spl/spl_fit.c +25 -2
index 87ecf0bb9e..3fbcb969f8 100644
@@ -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,31 @@ 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 defined(CONFIG_SPL_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));
+	}
+#endif
 	return ret;
 }
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/12 spl: fit: Add support for applying DT overlay

Quoted 94 lines · Jean-Jacques Hiblot

From: Michal Simek <[email protected]>

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.

---

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

Changes in v2: None

 Kconfig              | 10 ++++++++++
 common/spl/spl_fit.c | 27 +++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)
Kconfig +10 -0
index 5f5c5ccfd6..8197c9066a 100644
@@ -398,6 +398,16 @@ 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
+	default n
+	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"
 	select SPL_FIT
common/spl/spl_fit.c +18 -2
index 87ecf0bb9e..3fbcb969f8 100644
@@ -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,31 @@ 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 defined(CONFIG_SPL_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);

common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 333

Quoted 10 lines
common/spl/spl_fit.c +7 -0
+		if (ret)
+			return ret;
+
+		debug("%s: DT overlay %s applied\n", __func__,
+		      fit_get_name(fit, node, NULL));
+	}
+#endif
 	return ret;
 }
 

It looks like that something has been fixed in mainline that travis is passing now when this patch is applied.. Thanks for taking this forward.

I will look at the rest of patches next week.

Thanks,
Michal

#3 lore raw

PATCH v3 1/12 spl: fit: Add support for applying DT overlay

In reply to Jean-Jacques Hiblot
Quoted 28 lines · Jean-Jacques Hiblot

From: Michal Simek <[email protected]>

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.

---

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

Quoted 5 lines

Changes in v2: None

 Kconfig              | 10 ++++++++++
 common/spl/spl_fit.c | 27 +++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

nits below

Quoted 6 lines
Kconfig +0 -0
index 5f5c5ccfd6..8197c9066a 100644

Kconfig config SPL_LOAD_FIT · line 405

Quoted 8 lines
Kconfig +5 -0
@@ -398,6 +398,16 @@ 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
+       default n

this is the default anyway so you can omit this line

Kconfig config SPL_LOAD_FIT · line 409

Quoted 4 lines
Kconfig +4 -0
+       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.

Where are the instructions for this? At least add a pointer to a README somewhere else.

Quoted 22 lines
Kconfig +1 -0
+
 config SPL_LOAD_FIT_FULL
        bool "Enable SPL loading U-Boot as a FIT"
        select SPL_FIT
common/spl/spl_fit.c +2 -2
index 87ecf0bb9e..3fbcb969f8 100644
@@ -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;

common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 309

Quoted 7 lines
common/spl/spl_fit.c +3 -0
@@ -303,8 +303,31 @@ 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 defined(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY)

Can you use if (CONFIG_IS_ENABLED()) so that this builds with sandbox?

Actually we should really enable this with sandbox, too, so we can add a test.

Quoted 25 lines
common/spl/spl_fit.c +20 -1
+       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));
+       }
+#endif
        return ret;
 }
 
--
Quoted 2 lines

2.17.1

Regards,
Simon

#4 lore raw

PATCH v3 2/12 spl: fit: Make room in the FDT before applying overlays

In reply to Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
common/spl/spl_fit.c +11 -5
index 3fbcb969f8..c1c982f002 100644
@@ -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 defined(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY)
 	for (; ; index++) {
 		node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index);
@@ -319,6 +314,11 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		if (ret < 0)
 			return ret;
 
+		/* Make room in FDT for changes coming 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)
@@ -328,6 +328,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		      fit_get_name(fit, node, NULL));
 	}
 #endif
+	/* 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;
 }
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH v3 2/12 spl: fit: Make room in the FDT before applying overlays

Quoted 7 lines · Jean-Jacques Hiblot

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.

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
#6 lore raw

PATCH v3 3/12 spl: fit: allocate a temporary buffer to load the overlays

In reply to Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
common/spl/spl_fit.c +14 -0
index c1c982f002..b521ee68e6 100644
@@ -9,6 +9,7 @@
 #include <fpga.h>
 #include <image.h>
 #include <linux/libfdt.h>
+#include <malloc.h>
 #include <spl.h>
 
 #ifndef CONFIG_SYS_BOOTM_LEN
@@ -302,6 +303,16 @@ 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 defined(CONFIG_SPL_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.
+	 */
+	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) {
@@ -309,6 +320,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 			return 0;
 		}
 
+		image_info.load_addr = (ulong)tmpbuffer;
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
 		if (ret < 0)
@@ -327,6 +339,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		debug("%s: DT overlay %s applied\n", __func__,
 		      fit_get_name(fit, node, NULL));
 	}
+	if (tmpbuffer)
+		free(tmpbuffer);
 #endif
 	/* Try to make space, so we can inject details on the loadables */
 	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
Signature · 1 line
2.17.1
#7 lore raw

PATCH v3 3/12 spl: fit: allocate a temporary buffer to load the overlays

Hi Jean-Jacques,

Quoted 20 lines · Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
common/spl/spl_fit.c +0 -0
index c1c982f002..b521ee68e6 100644

common/spl/spl_fit.c line 11

Quoted 3 lines
common/spl/spl_fit.c +0 -0
@@ -9,6 +9,7 @@
 #include <fpga.h>
 #include <image.h>
 #include <linux/libfdt.h>

should go at end

common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 308

Quoted 11 lines
common/spl/spl_fit.c +4 -0
+#include <malloc.h>
 #include <spl.h>
 
 #ifndef CONFIG_SYS_BOOTM_LEN
@@ -302,6 +303,16 @@ 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 defined(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY)
+       void *tmpbuffer;
+       /*
+        * allocate 64kB of memory. This will be used to store the DT overlay

64KB

common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 314

Quoted 6 lines
common/spl/spl_fit.c +6 -0
+        * before it is applied. It may not be used depending on how the
+        * overlay is stored.
+        */
+       tmpbuffer = malloc(64 * 1024);
+       if (!tmpbuffer)
+               debug("%s: unable to allocate space for overlays\n", __func__);

Need to return an error here I think

Quoted 13 lines
common/spl/spl_fit.c +2 -0
+
        for (; ; index++) {
                node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index);
                if (node < 0) {
@@ -309,6 +320,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
                        return 0;
                }
 
+               image_info.load_addr = (ulong)tmpbuffer;
                ret = spl_load_fit_image(info, sector, fit, base_offset, node,
                                         &image_info);
                if (ret < 0)

common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 343

Quoted 5 lines
common/spl/spl_fit.c +2 -0
@@ -327,6 +339,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
                debug("%s: DT overlay %s applied\n", __func__,
                      fit_get_name(fit, node, NULL));
        }
+       if (tmpbuffer)
+               free(tmpbuffer);

Is this buffer freed if there is an error?

Quoted 6 lines
common/spl/spl_fit.c +0 -1
 #endif
        /* 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

Regards,
Simon

#8 lore raw

PATCH v3 4/12 spl: fit: Do not fail immediately if an overlay is not available

In reply to Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
common/spl/spl_fit.c +5 -1
index b521ee68e6..d5e3858ed0 100644
@@ -315,9 +315,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__);
 			return 0;
+		} else if (node < 0) {
+			debug("%s: unable to find FDT node %d\n", __func__,
+			      index);
+			continue;
 		}
 
 		image_info.load_addr = (ulong)tmpbuffer;
Signature · 1 line
2.17.1
#9 lore raw

PATCH v3 4/12 spl: fit: Do not fail immediately if an overlay is not available

Quoted 5 lines · Jean-Jacques Hiblot

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.

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

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

PATCH v3 5/12 spl: fit: be more verbose when an error occurs when applying the overlays

In reply to Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
common/spl/spl_fit.c +5 -2
index d5e3858ed0..d772f2db64 100644
@@ -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;
 	}
 
@@ -337,8 +337,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));
 			return ret;
+		}
 
 		debug("%s: DT overlay %s applied\n", __func__,
 		      fit_get_name(fit, node, NULL));
Signature · 1 line
2.17.1
#11 lore raw

PATCH v3 5/12 spl: fit: be more verbose when an error occurs when applying the overlays

Quoted 10 lines · Jean-Jacques Hiblot

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.

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

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

PATCH v3 6/12 Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled

In reply to Jean-Jacques Hiblot

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

---

Changes in v3: None
Changes in v2: None

 scripts/Makefile.lib | 4 ++++
 1 file changed, 4 insertions(+)
scripts/Makefile.lib +4 -0
index de67677f61..4b9f333d57 100644
@@ -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
Signature · 1 line
2.17.1
#13 lore raw

PATCH v3 6/12 Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled

Quoted 4 lines · Jean-Jacques Hiblot

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

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 scripts/Makefile.lib | 4 ++++
 1 file changed, 4 insertions(+)
#14 lore raw

PATCH v3 7/12 Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR

In reply to Jean-Jacques Hiblot

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

---

Changes in v3: None
Changes in v2: None

 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Makefile +7 -4
index 059978bfe6..b3ac1a9b8a 100644
@@ -1200,12 +1200,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
@@ -1214,7 +1217,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
Signature · 1 line
2.17.1
#15 lore raw

PATCH v3 7/12 Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR

Quoted 6 lines · Jean-Jacques Hiblot

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

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
#16 lore raw

PATCH v3 8/12 Makefile: Fix u-boot.itb generation when building outside the source tree

In reply to Jean-Jacques Hiblot

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.

---

Changes in v3: None
Changes in v2: None

 Makefile                                            | 5 +++--
 board/theobroma-systems/lion_rk3368/fit_spl_atf.its | 6 +++---
 board/theobroma-systems/puma_rk3399/fit_spl_atf.its | 8 ++++----
 3 files changed, 10 insertions(+), 9 deletions(-)
Makefile +3 -2
index b3ac1a9b8a..f0ee4a21e2 100644
@@ -900,7 +900,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     $@
@@ -1206,7 +1207,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
board/theobroma-systems/lion_rk3368/fit_spl_atf.its +3 -3
index 6b04fbc7da..69202a117b 100644
@@ -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";
 		};
board/theobroma-systems/puma_rk3399/fit_spl_atf.its +4 -4
index 530f059f3d..659183ecc1 100644
@@ -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-rk3399.bin");
+			data = /incbin/("bl31-rk3399.bin");
 			type = "firmware";
 			arch = "arm64";
 			os = "arm-trusted-firmware";
@@ -33,14 +33,14 @@
 		};
 		pmu {
 		        description = "Cortex-M0 firmware";
-			data = /incbin/("../../../rk3399m0.bin");
+			data = /incbin/("rk3399m0.bin");
 			type = "pmu-firmware";
 			compression = "none";
 			load = <0x180000>;
                 };
 		fdt {
 			description = "RK3399-Q7 (Puma) flat device-tree";
-			data = /incbin/("../../../u-boot.dtb");
+			data = /incbin/("u-boot.dtb");
 			type = "flat_dt";
 			compression = "none";
 		};
Signature · 1 line
2.17.1
#17 lore raw

PATCH v3 8/12 Makefile: Fix u-boot.itb generation when building outside the source tree

Quoted 10 lines · Jean-Jacques Hiblot

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.

---

Quoted 7 lines

Changes in v3: None
Changes in v2: None

 Makefile                                            | 5 +++--
 board/theobroma-systems/lion_rk3368/fit_spl_atf.its | 6 +++---
 board/theobroma-systems/puma_rk3399/fit_spl_atf.its | 8 ++++----
 3 files changed, 10 insertions(+), 9 deletions(-)
#18 lore raw

PATCH v3 9/12 Makefile: Pass the board name to the FIT generator scripts

In reply to Jean-Jacques Hiblot

Currently the FIT generator scripts are passed only a list of dtbs. However some platforms may also require information about the board itself.

---

Changes in v3: None
Changes in v2: None

 Makefile                               | 2 +-
 arch/arm/mach-imx/mkimage_fit_atf.sh   | 3 ++-
 arch/arm/mach-rockchip/make_fit_atf.py | 5 +++--
 board/sunxi/mksunxi_fit_atf.sh         | 2 ++
 4 files changed, 8 insertions(+), 4 deletions(-)
Makefile +1 -1
index f0ee4a21e2..048d12340b 100644
@@ -1218,7 +1218,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)/$(SPL_FIT_GENERATOR) \
+	$(srctree)/$(SPL_FIT_GENERATOR) $(BOARD) \
 	$(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@
 endif
 endif
arch/arm/mach-imx/mkimage_fit_atf.sh +2 -1
index 38c9858e84..45b325665e 100755
@@ -4,7 +4,7 @@
 # script to generate FIT image source for i.MX8MQ boards with
 # ARM Trusted Firmware and multiple device trees (given on the command line)
 #
-# usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
+# usage: $0 <board> <dt_name> [<dt_name> [<dt_name] ...]
 
 [ -z "$BL31" ] && BL31="bl31.bin"
 [ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0xfe000000"
@@ -39,6 +39,7 @@ else
 	ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2
 fi
 
+shift
 for dtname in $*
 do
 	echo "$dtname size: " >&2
arch/arm/mach-rockchip/make_fit_atf.py +3 -2
index d1faff1957..4138b04a37 100755
@@ -4,7 +4,7 @@ A script to generate FIT image source for rockchip boards
 with ARM Trusted Firmware
 and multiple device trees (given on the command line)
 
-usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
+usage: $0 <board> <dt_name> [<dt_name> [<dt_name] ...]
 """
 
 import os
@@ -209,7 +209,8 @@ def main():
             print(__doc__)
             sys.exit(2)
 
-    dtbs = args
+    board = args[0]
+    dtbs = args[1:]
     #get_bl31_segments_info("u-boot")
     #get_bl31_segments_info("bl31.elf")
 
board/sunxi/mksunxi_fit_atf.sh +2 -0
index 88ad719747..0dc7ab4348 100755
@@ -46,6 +46,8 @@ cat << __HEADER_EOF
 		};
 __HEADER_EOF
 
+shift
+
 cnt=1
 for dtname in $*
 do
Signature · 1 line
2.17.1
#19 lore raw

PATCH v3 9/12 Makefile: Pass the board name to the FIT generator scripts

Hi,

Quoted 7 lines · Jean-Jacques Hiblot

Currently the FIT generator scripts are passed only a list of dtbs. However some platforms may also require information about the board itself.

---

Quoted 8 lines

Changes in v3: None
Changes in v2: None

 Makefile                               | 2 +-
 arch/arm/mach-imx/mkimage_fit_atf.sh   | 3 ++-
 arch/arm/mach-rockchip/make_fit_atf.py | 5 +++--
 board/sunxi/mksunxi_fit_atf.sh         | 2 ++
 4 files changed, 8 insertions(+), 4 deletions(-)

I wonder if these scripts should use binman?

Regards,
Simon

#20 lore raw

PATCH v3 10/12 Makefile: Query the SPL Fit Generator for its dependencies

In reply to Jean-Jacques Hiblot

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

---

Changes in v3: None
Changes in v2: None

 Makefile                               | 9 ++-------
 arch/arm/mach-imx/mkimage_fit_atf.sh   | 7 +++++++
 arch/arm/mach-rockchip/make_fit_atf.py | 8 ++++++++
 board/sunxi/mksunxi_fit_atf.sh         | 5 +++++
 4 files changed, 22 insertions(+), 7 deletions(-)
Makefile +2 -7
index 048d12340b..3f8899b91b 100644
@@ -1211,13 +1211,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) $(BOARD) \
 	$(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@
 endif
arch/arm/mach-imx/mkimage_fit_atf.sh +7 -0
index 45b325665e..45a81fbad3 100755
@@ -11,6 +11,13 @@
 [ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000"
 [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000"
 
+if [ x"$1" = x"--deps" ]; then
+	echo $BL31
+	echo "tee.bin"
+	echo "u-boot-nodtb.bin"
+	exit 0
+fi
+
 if [ ! -f $BL31 ]; then
 	echo "ERROR: BL31 file $BL31 NOT found" >&2
 	exit 0
arch/arm/mach-rockchip/make_fit_atf.py +8 -0
index 4138b04a37..afd734e736 100755
@@ -192,11 +192,19 @@ def get_bl31_segments_info(bl31_file_name):
             paddr = seg[ELF_SEG_P_PADDR]
             print('paddr: %08x' % paddr)
 
+def show_deps_and_exit():
+	print("u-boot")
+	print("bl31.elf")
+	sys.exit(0)
+
 def main():
     uboot_elf="./u-boot"
     bl31_elf="./bl31.elf"
     FIT_ITS=sys.stdout
 
+    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":
board/sunxi/mksunxi_fit_atf.sh +5 -0
index 0dc7ab4348..8f87514a6f 100755
@@ -5,6 +5,11 @@
 #
 # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
 
+if [ x"$1" = x"--deps" ]; then
+	echo "u-boot-nodtb.bin"
+	exit 0
+fi
+
 [ -z "$BL31" ] && BL31="bl31.bin"
 
 if [ ! -f $BL31 ]; then
Signature · 1 line
2.17.1
#21 lore raw

PATCH v3 10/12 Makefile: Query the SPL Fit Generator for its dependencies

Quoted 7 lines · Jean-Jacques Hiblot

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

---

Quoted 8 lines

Changes in v3: None
Changes in v2: None

 Makefile                               | 9 ++-------
 arch/arm/mach-imx/mkimage_fit_atf.sh   | 7 +++++++
 arch/arm/mach-rockchip/make_fit_atf.py | 8 ++++++++
 board/sunxi/mksunxi_fit_atf.sh         | 5 +++++
 4 files changed, 22 insertions(+), 7 deletions(-)
#22 lore raw

PATCH v3 11/12 spl: fit: constify the output parameter of spl_fit_get_image_name()

In reply to Jean-Jacques Hiblot

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

---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +3 -3
index d772f2db64..8c5d15c3c8 100644
@@ -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;
 
@@ -363,7 +363,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",
Signature · 1 line
2.17.1
#23 lore raw

PATCH v3 11/12 spl: fit: constify the output parameter of spl_fit_get_image_name()

Quoted 4 lines · Jean-Jacques Hiblot

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

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

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

PATCH v3 12/12 spl: fit: Allow the board to tell if more images must be loaded from FIT

In reply to Jean-Jacques Hiblot

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-level code the opportunity to add to the list of images. The images from the FIT property are loaded first, and then the board_fit_get_additionnal_images() is called to get more image names.

---

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 | 28 +++++++++++++++++++++++++---
 include/spl.h        | 16 ++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +25 -3
index 8c5d15c3c8..f1e0ad8d73 100644
@@ -25,6 +25,12 @@ __weak ulong board_spl_fit_size_align(ulong size)
 	return size;
 }
 
+__weak const char *board_fit_get_additionnal_images(int index,
+						    const char *type)
+{
+	return NULL;
+}
+
 /**
  * spl_fit_get_image_name(): By using the matching configuration subnode,
  * retrieve the name of an image, specified by a property name and an index
@@ -45,6 +51,7 @@ static int spl_fit_get_image_name(const void *fit, int images,
 	__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 +77,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) {
+		/*
+		 * no string in the property for this index. Check if the board
+		 * level code can supply one.
+		 */
+		str = board_fit_get_additionnal_images(index - i - 1, type);
+		if (str)
+			found = true;
+	}
+
+	if (!found) {
+		debug("no string for index %d\n", index);
+		return -E2BIG;
+	}
+
+	*outname = str;
 	return 0;
 }
 
include/spl.h +16 -0
index a9aaef345f..b7a5d6a995 100644
@@ -370,6 +370,22 @@ void board_spl_fit_post_load(ulong load_addr, size_t length);
  */
 ulong board_spl_fit_size_align(ulong size);
 
+/**
+ * board_fit_get_additionnal_images - Get additional image names from board-
+ *				      level code.
+ * 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.
+ *
+ * @param index	Index of the image. Starts at 0 and gets incremented after each
+ *		call to this function.
+ * @param 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_fit_get_additionnal_images(int index, const char *type);
+
 /**
  * spl_perform_fixups() - arch/board-specific callback before processing
  *                        the boot-payload
Signature · 1 line
2.17.1
#25 lore raw

PATCH v3 12/12 spl: fit: Allow the board to tell if more images must be loaded from FIT

Hi Jean-Jacques,

Quoted 38 lines · Jean-Jacques Hiblot

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-level code the opportunity to add to the list of images. The images from the FIT property are loaded first, and then the board_fit_get_additionnal_images() is called to get more image names.

---

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

Quoted 4 lines
 common/spl/spl_fit.c | 28 +++++++++++++++++++++++++---
 include/spl.h        | 16 ++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

Can we instead use driver mode for this? E.g. there is a board uclass which could have functionality added.

Regards,
Simon

#26 lore raw

v3 cover Add support for applications of overlays in SPL

In reply to Jean-Jacques Hiblot

Hi Jean-Jacques,

Quoted 78 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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

Quoted 11 lines
 Kconfig                                       | 10 +++
 Makefile                                      | 23 +++--
 arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
 arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
 board/sunxi/mksunxi_fit_atf.sh                |  7 ++
 .../lion_rk3368/fit_spl_atf.its               |  6 +-
 .../puma_rk3399/fit_spl_atf.its               |  8 +-
 common/spl/spl_fit.c                          | 90 +++++++++++++++++--
 include/spl.h                                 | 16 ++++
 scripts/Makefile.lib                          |  4 +
 10 files changed, 156 insertions(+), 31 deletions(-)

How about a test that uses sandbox to apply some overlays?

Regards,
Simon

#27 lore raw

v3 cover Add support for applications of overlays in SPL

Hi Simon,

Quoted 91 lines · Simon Glass

Hi Jean-Jacques,

Quoted 77 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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

Quoted 11 lines
  Kconfig                                       | 10 +++
  Makefile                                      | 23 +++--
  arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
  arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
  board/sunxi/mksunxi_fit_atf.sh                |  7 ++
  .../lion_rk3368/fit_spl_atf.its               |  6 +-
  .../puma_rk3399/fit_spl_atf.its               |  8 +-
  common/spl/spl_fit.c                          | 90 +++++++++++++++++--
  include/spl.h                                 | 16 ++++
  scripts/Makefile.lib                          |  4 +
  10 files changed, 156 insertions(+), 31 deletions(-)
Quoted 1 line

How about a test that uses sandbox to apply some overlays?

I had had a look  it but came to the conclusion that the SPL is not passing the FDT to u-boot. Were I mistaken ?

Thanks for the reviews, I'll take your comments in account for the next round.

JJ

Quoted 4 lines

Regards,
Simon

#28 lore raw

v3 cover Add support for applications of overlays in SPL

Hi Jean-Jacques,

Quoted 96 lines · Jean-Jacques Hiblot

Hi Simon,

Quoted 91 lines · Simon Glass

Hi Jean-Jacques,

Quoted 88 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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                                       | 10 +++
  Makefile                                      | 23 +++--
  arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
  arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
  board/sunxi/mksunxi_fit_atf.sh                |  7 ++
  .../lion_rk3368/fit_spl_atf.its               |  6 +-
  .../puma_rk3399/fit_spl_atf.its               |  8 +-
  common/spl/spl_fit.c                          | 90 +++++++++++++++++--
  include/spl.h                                 | 16 ++++
  scripts/Makefile.lib                          |  4 +
  10 files changed, 156 insertions(+), 31 deletions(-)
Quoted 4 lines
Quoted 1 line

How about a test that uses sandbox to apply some overlays?

I had had a look it but came to the conclusion that the SPL is not passing the FDT to u-boot. Were I mistaken ?

Well actually that is possible. I haven't dug into the details, but there is a feature where SPL can select a DT to pass to U-Boot proper.

Quoted 3 lines

Thanks for the reviews, I'll take your comments in account for the next round.

OK sounds good.

Regards,
Simon

#29 lore raw

v3 cover Add support for applications of overlays in SPL

In reply to Jean-Jacques Hiblot
Quoted 76 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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

Quoted 11 lines
 Kconfig                                       | 10 +++
 Makefile                                      | 23 +++--
 arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
 arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
 board/sunxi/mksunxi_fit_atf.sh                |  7 ++
 .../lion_rk3368/fit_spl_atf.its               |  6 +-
 .../puma_rk3399/fit_spl_atf.its               |  8 +-
 common/spl/spl_fit.c                          | 90 +++++++++++++++++--
 include/spl.h                                 | 16 ++++
 scripts/Makefile.lib                          |  4 +
 10 files changed, 156 insertions(+), 31 deletions(-)

So where are we at here? Simon Glass had a few nits on one patch and reviewed the rest. I don't see any review from Michal and I really would like to before applying this as xilinx is another SoC that would be making use of this feature, yes? Thanks folks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190726/e8de266f/attachment.sig>
#30 lore raw

v3 cover Add support for applications of overlays in SPL

Hi Tom,

Quoted 89 lines · Tom Rini
Quoted 76 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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

Quoted 11 lines
  Kconfig                                       | 10 +++
  Makefile                                      | 23 +++--
  arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
  arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
  board/sunxi/mksunxi_fit_atf.sh                |  7 ++
  .../lion_rk3368/fit_spl_atf.its               |  6 +-
  .../puma_rk3399/fit_spl_atf.its               |  8 +-
  common/spl/spl_fit.c                          | 90 +++++++++++++++++--
  include/spl.h                                 | 16 ++++
  scripts/Makefile.lib                          |  4 +
  10 files changed, 156 insertions(+), 31 deletions(-)
Quoted 4 lines

So where are we at here? Simon Glass had a few nits on one patch and reviewed the rest. I don't see any review from Michal and I really would like to before applying this as xilinx is another SoC that would be making use of this feature, yes? Thanks folks!

I did not take the time to correct all the nits but I'll do that shortly (tomorrow probably)

The only problematic part for me will be testing with the sandbox for which I have nothing in store.

JJ

Quoted 1 line
#31 lore raw

v3 cover Add support for applications of overlays in SPL

In reply to Tom Rini
Quoted 90 lines · Tom Rini
Quoted 76 lines · Jean-Jacques Hiblot

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 #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek.
Patch #2 to #5 amend Michal's patch.
Patch #6 to #8 are simple fixes for the Makefile
Patch #9 is not required but relates to this series and will be required later by the AM6x platform
Patch #10 is used to reduce the complexity of the Makefile by having FIT generator scripts provide their dependencies
Patch #12 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-level 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/535686392
For a strange reason, buildman on travis show errors for sun8i ans sun50i, but pass when I run it locally.

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 (11):
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: Pass the board name to the FIT generator scripts
Makefile: Query the SPL Fit Generator for its dependencies
spl: fit: constify the output parameter of spl_fit_get_image_name()
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

Quoted 11 lines
 Kconfig                                       | 10 +++
 Makefile                                      | 23 +++--
 arch/arm/mach-imx/mkimage_fit_atf.sh          | 10 ++-
 arch/arm/mach-rockchip/make_fit_atf.py        | 13 ++-
 board/sunxi/mksunxi_fit_atf.sh                |  7 ++
 .../lion_rk3368/fit_spl_atf.its               |  6 +-
 .../puma_rk3399/fit_spl_atf.its               |  8 +-
 common/spl/spl_fit.c                          | 90 +++++++++++++++++--
 include/spl.h                                 | 16 ++++
 scripts/Makefile.lib                          |  4 +
 10 files changed, 156 insertions(+), 31 deletions(-)
Quoted 4 lines

So where are we at here? Simon Glass had a few nits on one patch and reviewed the rest. I don't see any review from Michal and I really would like to before applying this as xilinx is another SoC that would be making use of this feature, yes? Thanks folks!

I took July off and trying to catch all emails that's why please give me some time to take a look at it again. I need to take a look how to improve that hw detection for applying to overlay.

M