[U-Boot] [PATCH PATCH v6 00/13] 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.
Our use-case is the support of the daughter boards of the AM65x and J721e EVMs. 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.
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/600742163
Changes in v6: - Instead of matching a overlay by the name of it's node. Try to match it first with the description, and then with the node's name. This allows to use makeimg to add the overlays to u-boot.img and not use a custom SPL_FIT_GENERATOR script
Changes in v5: - Do not allocate the buffer if not needed (no overlay). - Add a Kconfig option for the buffer size - board_get_fit_loadable() returns an error code instead of a NULL string in case of failure -reword commit log
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: - depend on SPL_DM - update the commit log - 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 (12): 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 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 dts: Add support for adding DT overlays in u-boot.img 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 | 18 +++++ Makefile | 3 +- common/spl/spl_fit.c | 151 ++++++++++++++++++++++++++++++++--- drivers/Makefile | 2 +- drivers/board/Kconfig | 3 + drivers/board/Makefile | 2 +- drivers/board/board-uclass.c | 11 +++ dts/Kconfig | 8 ++ include/board.h | 74 +++++++++++++++++ scripts/Makefile.lib | 4 + 10 files changed, 263 insertions(+), 13 deletions(-)

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 Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Andreas Dannenberg dannenberg@ti.com ---
Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
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 cbc00a4e7c..346f9edaa5 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -373,6 +373,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 @@ -502,6 +503,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; @@ -510,6 +512,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)

On Tue, Oct 22, 2019 at 04:39:10PM +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 Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Andreas Dannenberg dannenberg@ti.com
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 66b059f749..518ce7e0d6 100644 --- a/Kconfig +++ b/Kconfig @@ -429,6 +429,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 346f9edaa5..39e406b237 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -281,7 +281,7 @@ 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 = 0; + int node, ret = 0, index = 0;
/* * Use the address following the image as target address for the @@ -290,7 +290,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, image_info.load_addr = spl_image->load_addr + spl_image->size;
/* 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__);
@@ -315,8 +315,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; }

On Tue, Oct 22, 2019 at 04:39:11PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 39e406b237..65dd835ecc 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -313,11 +313,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, @@ -332,6 +327,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) @@ -341,6 +342,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; }

On Tue, Oct 22, 2019 at 04:39:12PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

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 buffer that will be used as a default load address. By default, the size of the buffer is 64kB which should be plenty for most use cases.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
---
Changes in v6: None Changes in v5: - Do not allocate the buffer if not needed (no overlay). - Add a Kconfig option for the buffer size
Changes in v4: - make sure that the temp buffer is freed in all cases
Changes in v3: None Changes in v2: None
Kconfig | 9 +++++++++ common/spl/spl_fit.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/Kconfig b/Kconfig index 518ce7e0d6..417799a700 100644 --- a/Kconfig +++ b/Kconfig @@ -438,6 +438,15 @@ config SPL_LOAD_FIT_APPLY_OVERLAY also load device-tree overlays from the FIT image an apply them over the device tree.
+config SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ + depends on SPL_LOAD_FIT_APPLY_OVERLAY + default 0x10000 + hex "size of temporary buffer used to load the overlays" + help + The size of the area where the overlays will be loaded and + uncompress. Must be at least as large as biggest overlay + (uncompressed) + 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 65dd835ecc..e6935c16b7 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -9,11 +9,16 @@ #include <fpga.h> #include <gzip.h> #include <image.h> -#include <linux/libfdt.h> +#include <malloc.h> #include <spl.h> +#include <linux/libfdt.h>
DECLARE_GLOBAL_DATA_PTR;
+#ifndef CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ +#define CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ (64 * 1024) +#endif + #ifndef CONFIG_SYS_BOOTM_LEN #define CONFIG_SYS_BOOTM_LEN (64 << 20) #endif @@ -314,33 +319,52 @@ 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 = NULL; + 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; }
+ if (!tmpbuffer) { + /* + * allocate memory 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(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ); + if (!tmpbuffer) + debug("%s: unable to allocate space for overlays\n", + __func__); + } + 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);

On Tue, 22 Oct 2019 at 08:40, 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 buffer that will be used as a default load address. By default, the size of the buffer is 64kB which should be plenty for most use cases.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Changes in v6: None Changes in v5:
- Do not allocate the buffer if not needed (no overlay).
- Add a Kconfig option for the buffer size
Changes in v4:
- make sure that the temp buffer is freed in all cases
Changes in v3: None Changes in v2: None
Kconfig | 9 +++++++++ common/spl/spl_fit.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, Oct 22, 2019 at 04:39:13PM +0200, Jean-Jacques Hiblot 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 buffer that will be used as a default load address. By default, the size of the buffer is 64kB which should be plenty for most use cases.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 e6935c16b7..0245dcadb4 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -324,9 +324,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; }
if (!tmpbuffer) {

On Tue, Oct 22, 2019 at 04:39:14PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 0245dcadb4..5aeb9528fe 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -113,7 +113,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; }
@@ -359,8 +359,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));

On Tue, Oct 22, 2019 at 04:39:15PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 ef116e0e0a..6946da6aa4 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

On Tue, Oct 22, 2019 at 04:39:16PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: None 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 5aeb9528fe..9001731303 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -46,7 +46,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; @@ -101,7 +101,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;
@@ -387,7 +387,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",

On Tue, Oct 22, 2019 at 04:39:17PM +0200, Jean-Jacques Hiblot wrote:
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
Applied to u-boot/master, thanks!

Make the board driver available in the SPL too. The board driver is a way to provide useful information about the board and that can be useful in the SPL too.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
---
Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: - depend on SPL_DM - update the commit log
drivers/Makefile | 2 +- drivers/board/Kconfig | 3 +++ drivers/board/Makefile | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/Makefile b/drivers/Makefile index a4bb5e4975..6dd43d4949 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..254f657049 100644 --- a/drivers/board/Kconfig +++ b/drivers/board/Kconfig @@ -8,6 +8,9 @@ menuconfig BOARD
if BOARD
+config SPL_BOARD + depends on SPL_DM + 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@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

On Tue, Oct 22, 2019 at 04:39:18PM +0200, Jean-Jacques Hiblot wrote:
Make the board driver available in the SPL too. The board driver is a way to provide useful information about the board and that can be useful in the SPL too.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

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 v6: None Changes in v5: - board_get_fit_loadable() returns an error code instead of a NULL string in case of failure
Changes in v4: None Changes in v3: None Changes in v2: None
drivers/board/board-uclass.c | 11 +++++++++++ include/board.h | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c index a516ba4962..b5485e9895 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); }
+int board_get_fit_loadable(struct udevice *dev, int index, + const char *type, const char **strp) +{ + struct board_ops *ops = board_get_ops(dev); + + if (!ops->get_fit_loadable) + return -ENOSYS; + + return ops->get_fit_loadable(dev, index, type, strp); +} + 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..fd6a486702 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 + * @strp: A pointer to string. Untouched if the function fails + * + * Return: 0 if OK, -ENOENT if no loadable is available else -ve on + * error. + */ + int (*get_fit_loadable)(struct udevice *dev, int index, + const char *type, const char **strp); };
#define board_get_ops(dev) ((struct board_ops *)(dev)->driver->ops) @@ -137,3 +155,22 @@ 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 + * @strp: A pointer to string. Untouched if the function fails + * + * + * Return: 0 if OK, -ENOENT if no loadable is available else -ve on + * error. + */ +int board_get_fit_loadable(struct udevice *dev, int index, + const char *type, const char **strp);

On Tue, 22 Oct 2019 at 08:40, 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 v6: None Changes in v5:
- board_get_fit_loadable() returns an error code instead of a NULL string in case of failure
Changes in v4: None Changes in v3: None Changes in v2: None
drivers/board/board-uclass.c | 11 +++++++++++ include/board.h | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, Oct 22, 2019 at 04:39:19PM +0200, Jean-Jacques Hiblot 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 Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Useful to avoid #ifdef throughout the code that uses the board driver API.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
include/board.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/include/board.h b/include/board.h index fd6a486702..678b652b0a 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 @@ -174,3 +175,39 @@ int board_get(struct udevice **devp); */ int board_get_fit_loadable(struct udevice *dev, int index, const char *type, const char **strp); + +#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 int board_get_fit_loadable(struct udevice *dev, int index, + const char *type, const char **strp) +{ + return -ENOSYS; +} + +#endif

On Tue, Oct 22, 2019 at 04:39:20PM +0200, Jean-Jacques Hiblot wrote:
Useful to avoid #ifdef throughout the code that uses the board driver API.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

If u-boot.img is a FIT image, CONFIG_OF_OVERLAY_LIST can be used to add DT overlays to u-boot.img.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 3 ++- dts/Kconfig | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index 6fda3268e7..46c5bd4753 100644 --- a/Makefile +++ b/Makefile @@ -1262,7 +1262,8 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ -p $(CONFIG_FIT_EXTERNAL_OFFSET) \ -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \ - $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) + $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) \ + $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst ",,$(CONFIG_OF_OVERLAY_LIST))) else MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ diff --git a/dts/Kconfig b/dts/Kconfig index c9ab66cccc..c150a9b2af 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -130,6 +130,14 @@ config OF_LIST device tree files (without the directory or .dtb suffix) separated by <space>.
+config OF_OVERLAY_LIST + string "List of device tree overlays to include for DT control" + depends on SPL_LOAD_FIT_APPLY_OVERLAY + help + This option specifies a list of device tree overlaysto use for DT + control. This option can then be used a FIT generator to include + the overlays in the FIT image + choice prompt "SPL OF LIST compression" depends on MULTI_DTB_FIT

On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
If u-boot.img is a FIT image, CONFIG_OF_OVERLAY_LIST can be used to add DT overlays to u-boot.img.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 3 ++- dts/Kconfig | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
nit below
diff --git a/Makefile b/Makefile index 6fda3268e7..46c5bd4753 100644 --- a/Makefile +++ b/Makefile @@ -1262,7 +1262,8 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ -p $(CONFIG_FIT_EXTERNAL_OFFSET) \ -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst ",,$(CONFIG_OF_OVERLAY_LIST)))
else MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ diff --git a/dts/Kconfig b/dts/Kconfig index c9ab66cccc..c150a9b2af 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -130,6 +130,14 @@ config OF_LIST device tree files (without the directory or .dtb suffix) separated by <space>.
+config OF_OVERLAY_LIST
string "List of device tree overlays to include for DT control"
depends on SPL_LOAD_FIT_APPLY_OVERLAY
help
This option specifies a list of device tree overlaysto use for DT
missing space
control. This option can then be used a FIT generator to include
by a FIT generator?
the overlays in the FIT image
choice prompt "SPL OF LIST compression" depends on MULTI_DTB_FIT -- 2.17.1

On Tue, Oct 22, 2019 at 04:39:21PM +0200, Jean-Jacques Hiblot wrote:
If u-boot.img is a FIT image, CONFIG_OF_OVERLAY_LIST can be used to add DT overlays to u-boot.img.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
With Simon's nits corrected:
Applied to u-boot/master, thanks!

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 quickly becomes hard to manage combinations of more than a 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 v6: - Instead of matching a overlay by the name of it's node. Try to match it first with the description, and then with the node's name. This allows to use makeimg to add the overlays to u-boot.img and not use a custom SPL_FIT_GENERATOR script
Changes in v5: -reword commit log
Changes in v4: - 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: - 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 | 65 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 9001731303..ac69d8312e 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 <gzip.h> #include <image.h> @@ -32,6 +33,29 @@ __weak ulong board_spl_fit_size_align(ulong size) return size; }
+static int find_node_from_desc(const void *fit, int node, const char *str) +{ + int child; + + if (node < 0) + return -EINVAL; + + /* iterate the FIT nodes and find a matching description */ + for (child = fdt_first_subnode(fit, node); child >= 0; + child = fdt_next_subnode(fit, child)) { + int len; + const char *desc = fdt_getprop(fit, child, "description", &len); + + if (!desc) + continue; + + if (!strcmp(desc, str)) + return child; + } + + return -ENOENT; +} + /** * 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 @@ -48,10 +72,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) { @@ -77,12 +103,45 @@ 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; + } + } + + if (!found && !board_get(&board)) { + int rc; + /* + * no string in the property for this index. Check if the board + * level code can supply one. + */ + rc = board_get_fit_loadable(board, index - i - 1, type, &str); + if (rc && rc != -ENOENT) + return rc; + + if (!rc) { + /* + * The board provided a name for a loadable. + * Try to match it against the description properties + * first. If no matching node is found, use it as a + * node name. + */ + int node; + int images = fdt_path_offset(fit, FIT_IMAGES_PATH); + + node = find_node_from_desc(fit, images, str); + if (node > 0) + str = fdt_get_name(fit, node, NULL); + + found = true; } }
- *outname = (char *)str; + if (!found) { + debug("no string for index %d\n", index); + return -E2BIG; + } + + *outname = str; return 0; }

On Tue, 22 Oct 2019 at 08:40, 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 quickly becomes hard to manage combinations of more than a 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 v6:
- Instead of matching a overlay by the name of it's node. Try to match it first with the description, and then with the node's name. This allows to use makeimg to add the overlays to u-boot.img and not use a custom SPL_FIT_GENERATOR script
Changes in v5: -reword commit log
Changes in v4:
- 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:
- 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 | 65 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Can you add a test for this to sandbox_spl?

On Tue, Oct 22, 2019 at 04:39:22PM +0200, Jean-Jacques Hiblot 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 quickly becomes hard to manage combinations of more than a 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 Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Tom, Simon,
gentle ping on this series. It has been posted for a long time and I did not push for it because I was working on other stuff. am654x and J7x SOCs will need this kind of feature.
Before sending a version rebased on latest u-boot, I would have liked to have your feeling on the series as a whole.
JJ
On 22/10/2019 16:39, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot.
Our use-case is the support of the daughter boards of the AM65x and J721e EVMs. 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.
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/600742163
Changes in v6:
- Instead of matching a overlay by the name of it's node. Try to match it first with the description, and then with the node's name. This allows to use makeimg to add the overlays to u-boot.img and not use a custom SPL_FIT_GENERATOR script
Changes in v5:
- Do not allocate the buffer if not needed (no overlay).
- Add a Kconfig option for the buffer size
- board_get_fit_loadable() returns an error code instead of a NULL string in case of failure
-reword commit log
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:
- depend on SPL_DM
- update the commit log
- 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 (12): 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 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 dts: Add support for adding DT overlays in u-boot.img 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 | 18 +++++ Makefile | 3 +- common/spl/spl_fit.c | 151 ++++++++++++++++++++++++++++++++--- drivers/Makefile | 2 +- drivers/board/Kconfig | 3 + drivers/board/Makefile | 2 +- drivers/board/board-uclass.c | 11 +++ dts/Kconfig | 8 ++ include/board.h | 74 +++++++++++++++++ scripts/Makefile.lib | 4 + 10 files changed, 263 insertions(+), 13 deletions(-)

Hi Jean-Jacques,
On Mon, 23 Dec 2019 at 09:25, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
Tom, Simon,
gentle ping on this series. It has been posted for a long time and I did not push for it because I was working on other stuff. am654x and J7x SOCs will need this kind of feature.
Before sending a version rebased on latest u-boot, I would have liked to have your feeling on the series as a whole.
It looks fine from my point of view, but does need tests.
- Simon
participants (3)
-
Jean-Jacques Hiblot
-
Simon Glass
-
Tom Rini