[U-Boot] [RFC PATCH v2 00/12] 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 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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 Makefile.lib: include /__symbols__ in dtb if OF_LIBFDT_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: use custom ITS to build u-boot.img if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set 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 configs: am335x_evm: enable SPL_FIT_IMAGE_TINY !!! TEMP !!! For demonstration only !!! DRA76: Usage of overlays in SPL
Michal Simek (1): spl: fit: Add support for applying DT overlay
Makefile | 27 +++++-- arch/arm/dts/Makefile | 2 +- arch/arm/dts/dra76-evm-dummy.dts | 14 ++++ arch/arm/dts/dra76-evm-dummy2.dts | 15 ++++ 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 + .../lion_rk3368/fit_spl_atf.its | 6 +- .../puma_rk3399/fit_spl_atf.its | 8 +- board/ti/dra7xx/evm.c | 30 +++++++ board/ti/dra7xx/evm.its | 48 +++++++++++ common/spl/spl_fit.c | 81 +++++++++++++++++-- configs/am335x_evm_defconfig | 1 + configs/dra7xx_evm_defconfig | 2 + include/spl.h | 16 ++++ scripts/Makefile.lib | 4 + 16 files changed, 239 insertions(+), 25 deletions(-) create mode 100644 arch/arm/dts/dra76-evm-dummy.dts create mode 100644 arch/arm/dts/dra76-evm-dummy2.dts create mode 100644 board/ti/dra7xx/evm.its

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 ---
Changes in v2: None
common/spl/spl_fit.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index c9bfe0cc8a..6b71de73e7 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -278,10 +278,10 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, void *fit, int images, ulong base_offset) { struct spl_image_info image_info; - int node, ret; + int node, ret, index = 0;
/* Figure out which device tree the board wants to use */ - node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0); + node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++); if (node < 0) { debug("%s: cannot find FDT node\n", __func__); return node; @@ -303,8 +303,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_OF_LIBFDT_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; }

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 ---
Changes in v2: None
common/spl/spl_fit.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 6b71de73e7..a2909604cd 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -301,11 +301,6 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, /* Make the load-address of the FDT available for the SPL framework */ spl_image->fdt_addr = (void *)image_info.load_addr; #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY) - /* Try to make space, so we can inject details on the loadables */ - ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192); - if (ret < 0) - return ret; -#endif #if defined(CONFIG_OF_LIBFDT_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; }

If the node describing an overlay does not specify a load address, it will be loaded at the address previously used. Fixing it by allocating a temporary 64kB region that will be used as a default load address.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v2: None
common/spl/spl_fit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index a2909604cd..b54b30820e 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -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_OF_LIBFDT_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);

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 ---
Changes in v2: None
scripts/Makefile.lib | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 70de9bb13a..75a170380e 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_OF_LIBFDT_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

The current tests do to handle well the cases where those variables are not defined. When CONFIG_SPL_LOAD_FIT is not defined, U_BOOT_ITS gets defined as an empty string. Fixing it by using intermediate variables with the quotes removed
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v2: None
Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile index c1af9307b3..26235d8933 100644 --- a/Makefile +++ b/Makefile @@ -1148,12 +1148,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 @@ -1162,7 +1165,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

Include the object tree and the source tree in the search path of the FIT compîler (dtc). This allows to use paths relative to the root of the source or object trees in the ITS instead of working backward from the actual location of the ITS. It also allows to use a build directory different of the source directory.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
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(-)
diff --git a/Makefile b/Makefile index 26235d8933..9275c8930e 100644 --- a/Makefile +++ b/Makefile @@ -893,7 +893,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 $@ @@ -1154,7 +1155,7 @@ endif SPL_FIT_SOURCE := $(subst ",,$(CONFIG_SPL_FIT_SOURCE)) SPL_FIT_GENERATOR := $(subst ",,$(CONFIG_SPL_FIT_GENERATOR)) ifneq ($(SPL_FIT_SOURCE),) -U_BOOT_ITS = $(SPL_FIT_SOURCE) +U_BOOT_ITS = $(src)/$(SPL_FIT_SOURCE) else ifneq ($(SPL_FIT_GENERATOR),) U_BOOT_ITS := u-boot.its diff --git a/board/theobroma-systems/lion_rk3368/fit_spl_atf.its b/board/theobroma-systems/lion_rk3368/fit_spl_atf.its index 6b04fbc7da..69202a117b 100644 --- a/board/theobroma-systems/lion_rk3368/fit_spl_atf.its +++ b/board/theobroma-systems/lion_rk3368/fit_spl_atf.its @@ -14,7 +14,7 @@ images { uboot { description = "U-Boot (64-bit)"; - data = /incbin/("../../../u-boot-nodtb.bin"); + data = /incbin/("u-boot-nodtb.bin"); type = "standalone"; os = "U-Boot"; arch = "arm64"; @@ -23,7 +23,7 @@ }; atf { description = "ARM Trusted Firmware"; - data = /incbin/("../../../bl31-rk3368.bin"); + data = /incbin/("bl31-rk3368.bin"); type = "firmware"; os = "arm-trusted-firmware"; arch = "arm64"; @@ -34,7 +34,7 @@
fdt { description = "RK3368-uQ7 (Lion) flat device-tree"; - data = /incbin/("../../../u-boot.dtb"); + data = /incbin/("u-boot.dtb"); type = "flat_dt"; compression = "none"; }; diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.its b/board/theobroma-systems/puma_rk3399/fit_spl_atf.its index 530f059f3d..659183ecc1 100644 --- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.its +++ b/board/theobroma-systems/puma_rk3399/fit_spl_atf.its @@ -14,7 +14,7 @@ images { uboot { description = "U-Boot (64-bit)"; - data = /incbin/("../../../u-boot-nodtb.bin"); + data = /incbin/("u-boot-nodtb.bin"); type = "standalone"; os = "U-Boot"; arch = "arm64"; @@ -23,7 +23,7 @@ }; atf { description = "ARM Trusted Firmware"; - data = /incbin/("../../../bl31-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"; };

Currently the FIT generator scripts are passed only a list of dtbs. However some platforms may also require information about the board itself.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
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(-)
diff --git a/Makefile b/Makefile index 9275c8930e..d30e229ad9 100644 --- a/Makefile +++ b/Makefile @@ -1166,7 +1166,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 diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh b/arch/arm/mach-imx/mkimage_fit_atf.sh index 38c9858e84..45b325665e 100755 --- a/arch/arm/mach-imx/mkimage_fit_atf.sh +++ b/arch/arm/mach-imx/mkimage_fit_atf.sh @@ -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 diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d1faff1957..4138b04a37 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -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")
diff --git a/board/sunxi/mksunxi_fit_atf.sh b/board/sunxi/mksunxi_fit_atf.sh index 88ad719747..0dc7ab4348 100755 --- a/board/sunxi/mksunxi_fit_atf.sh +++ b/board/sunxi/mksunxi_fit_atf.sh @@ -46,6 +46,8 @@ cat << __HEADER_EOF }; __HEADER_EOF
+shift + cnt=1 for dtname in $* do

If SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set, then the default output image should be built using the provided/generated ITS, not using the default template implemented by mkimage. In that case, make u-boot.img a symbolic link to u-boot.itb
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v2: None
Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index d30e229ad9..306d2ee4b3 100644 --- a/Makefile +++ b/Makefile @@ -888,6 +888,9 @@ cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD
MKIMAGEOUTPUT ?= /dev/null
+quiet_cmd_ln = LN $@ -> $< +cmd_ln = ln -f -s $< $@ + quiet_cmd_mkimage = MKIMAGE $@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ >$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT)) @@ -1199,7 +1202,7 @@ MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
-u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ +u-boot-dtb.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ $(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE $(call if_changed,mkimage) $(BOARD_SIZE_CHECK) @@ -1210,10 +1213,18 @@ else MKIMAGEFLAGS_u-boot.itb = -E endif
+ifndef U_BOOT_ITS +u-boot.img: $(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE + $(call if_changed,mkimage) +else u-boot.itb: u-boot-nodtb.bin dts/dt.dtb $(U_BOOT_ITS) FORCE $(call if_changed,mkfitimage) $(BOARD_SIZE_CHECK)
+u-boot.img: u-boot.itb + $(call if_changed,ln) +endif + u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)

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 ---
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 b54b30820e..b11344ec6a 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -39,7 +39,7 @@ __weak ulong board_spl_fit_size_align(ulong size) */ static int spl_fit_get_image_name(const void *fit, int images, const char *type, int index, - char **outname) + const char **outname) { const char *name, *str; __maybe_unused int node; @@ -94,7 +94,7 @@ static int spl_fit_get_image_name(const void *fit, int images, static int spl_fit_get_image_node(const void *fit, int images, const char *type, int index) { - char *str; + const char *str; int err; int node;
@@ -356,7 +356,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",

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.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v2: None
common/spl/spl_fit.c | 28 +++++++++++++++++++++++++--- include/spl.h | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index b11344ec6a..9d4ceb4ae1 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -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; }
diff --git a/include/spl.h b/include/spl.h index f09909e189..72e9c75e36 100644 --- a/include/spl.h +++ b/include/spl.h @@ -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

The size of the SPL for the am335x_evm is constrained. There is no need to have advanced SPL FIT features, so keep the SPL FIT support tiny.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
Changes in v2: None
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index 6c791be374..83a046e826 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -10,6 +10,7 @@ CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run f CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_VERSION_VARIABLE=y CONFIG_ARCH_MISC_INIT=y +CONFIG_SPL_FIT_IMAGE_TINY=y # CONFIG_SPL_FS_EXT4 is not set CONFIG_SPL_MTD_SUPPORT=y CONFIG_SPL_MUSB_NEW_SUPPORT=y

This is an example of how to apply overlays in SPL for the DRA76
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
---
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
arch/arm/dts/Makefile | 2 +- arch/arm/dts/dra76-evm-dummy.dts | 14 +++++++++ arch/arm/dts/dra76-evm-dummy2.dts | 15 ++++++++++ board/ti/dra7xx/evm.c | 30 +++++++++++++++++++ board/ti/dra7xx/evm.its | 48 +++++++++++++++++++++++++++++++ configs/dra7xx_evm_defconfig | 2 ++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/dra76-evm-dummy.dts create mode 100644 arch/arm/dts/dra76-evm-dummy2.dts create mode 100644 board/ti/dra7xx/evm.its
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 0e2ffdb87f..65bb6396c5 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -276,7 +276,7 @@ dtb-$(CONFIG_ARCH_SOCFPGA) += \ socfpga_stratix10_socdk.dtb
dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb \ - dra72-evm-revc.dtb dra71-evm.dtb dra76-evm.dtb + dra72-evm-revc.dtb dra71-evm.dtb dra76-evm.dtb dra76-evm-dummy.dtbo dra76-evm-dummy2.dtbo dtb-$(CONFIG_TARGET_AM57XX_EVM) += am57xx-beagle-x15.dtb \ am57xx-beagle-x15-revb1.dtb \ am57xx-beagle-x15-revc.dtb \ diff --git a/arch/arm/dts/dra76-evm-dummy.dts b/arch/arm/dts/dra76-evm-dummy.dts new file mode 100644 index 0000000000..6b55670281 --- /dev/null +++ b/arch/arm/dts/dra76-evm-dummy.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/dts-v1/; +/plugin/; + + +&mmc1 { + dummy_node { + dummy_val = "this is only in overlay 1"; + }; +}; diff --git a/arch/arm/dts/dra76-evm-dummy2.dts b/arch/arm/dts/dra76-evm-dummy2.dts new file mode 100644 index 0000000000..0f0411164c --- /dev/null +++ b/arch/arm/dts/dra76-evm-dummy2.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/dts-v1/; +/plugin/; + + +&mmc2 { + dummy_node { + dummy_val = "this is only in overlay 2"; + }; + +}; diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index 060c471032..a5e4867206 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -704,6 +704,14 @@ int board_late_init(void) if (device_okay("/ocp/omap_dwc3_2@488c0000")) enable_usb_clocks(1); #endif + char preboot_cmd[255]; + + sprintf(preboot_cmd, "fdt addr %p;\ + fdt print /ocp/mmc@480b4000/dummy_node;\ + fdt print /ocp/mmc@4809c000/dummy_node;", + gd->fdt_blob); + + env_set("preboot", preboot_cmd); return 0; }
@@ -1069,6 +1077,28 @@ int ft_board_setup(void *blob, bd_t *bd) #endif
#ifdef CONFIG_SPL_LOAD_FIT +#define MAX_DAUGHTER_BOARDS 2 +const bool detected[MAX_DAUGHTER_BOARDS] = {false, true}; +const char *dtbo_nodes[] = {"dra76-evm-dummy", "dra76-evm-dummy2"}; + +const char *board_fit_get_additionnal_images(int index, const char *type) +{ + int i, j; + + if (strcmp(type, FIT_FDT_PROP)) + return NULL; + + j = 0; + for (i = 0; i < MAX_DAUGHTER_BOARDS; i++) { + if (detected[i]) { + if (j == index) + return dtbo_nodes[i]; + j++; + } + } + return NULL; +} + int board_fit_config_name_match(const char *name) { if (is_dra72x()) { diff --git a/board/ti/dra7xx/evm.its b/board/ti/dra7xx/evm.its new file mode 100644 index 0000000000..9f6d14cf9c --- /dev/null +++ b/board/ti/dra7xx/evm.its @@ -0,0 +1,48 @@ +/dts-v1/; + +/ { + description = "Firmware image with one or more FDT blobs"; + #address-cells = <0x1>; + + images { + + firmware-1 { + description = "U-Boot 2019.01 for DRA76 board"; + type = "firmware"; + arch = "arm"; + os = "u-boot"; + compression = "none"; + load = <0x80800000>; + entry = <0x0>; + data = /incbin/("u-boot-nodtb.bin"); + + }; + + fdt-1 { + description = "dra76-evm"; + type = "fdt"; + data = /incbin/("arch/arm/dts/dra76-evm.dtb"); + }; + + dra76-evm-dummy { + description = "dra76-evm dummy overlay 1"; + data = /incbin/("arch/arm/dts/dra76-evm-dummy.dtbo"); + }; + + dra76-evm-dummy2 { + description = "dra76-evm dummy overlay 2"; + data = /incbin/("arch/arm/dts/dra76-evm-dummy2.dtbo"); + }; + }; + + configurations { + default = "dra76-evm"; + + dra76-evm { + description = "dra76-evm"; + firmware = "firmware-1"; + fdt = "fdt-1"; + }; + + }; +}; diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 3f25a2ec28..f44a673acd 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -12,10 +12,12 @@ CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL_LOAD_FIT=y +CONFIG_SPL_FIT_SOURCE="board/ti/dra7xx/evm.its" CONFIG_OF_BOARD_SETUP=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=jacinto6evmboard" # CONFIG_USE_BOOTCOMMAND is not set +CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_VERSION_VARIABLE=y

On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
This series looks better. Is this able to also handle different images then just dtbs?
Thanks, Michal

Hi Michal,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
This series looks better. Is this able to also handle different images then just dtbs?
Sorry I thought had answered this.
Yes this is able to handle different image types, not just dtbos.
Have you been able to play with it ? any additional comment ?
JJ
Thanks, Michal

On 17. 04. 19 11:34, Jean-Jacques Hiblot wrote:
Hi Michal,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
This series looks better. Is this able to also handle different images then just dtbs?
Sorry I thought had answered this.
Yes this is able to handle different image types, not just dtbos.
Have you been able to play with it ? any additional comment ?
I haven't had a time but series is going in a right direction. I found 2 days ago that applying my patch is increasing size for some platforms that travis is failing. It means I would definitely suggest you to run travis on branch with all patches applied to see if this passing or some changes need to happen.
Thanks, Michal

On 17/04/2019 12:38, Michal Simek wrote:
On 17. 04. 19 11:34, Jean-Jacques Hiblot wrote:
Hi Michal,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
This series looks better. Is this able to also handle different images then just dtbs?
Sorry I thought had answered this.
Yes this is able to handle different image types, not just dtbos.
Have you been able to play with it ? any additional comment ?
I haven't had a time but series is going in a right direction. I found 2 days ago that applying my patch is increasing size for some platforms that travis is failing. It means I would definitely suggest you to run travis on branch with all patches applied to see if this passing or some changes need to happen.
Already done. https://travis-ci.org/jjhiblot/u-boot/builds/511617974
The failures (except dra7 which is unresolved) are all related to the generation of u-boot.itb (one patch replaces u-boot.img with a link to u-boot.itb, making travis build u-boot.itb)
Was the broken platform the am335x_evm? In that case, the fix is in the series. I disabled advanced FIT features for this platform as this is definitely not needed.
Thanks,
JJ
Thanks, Michal

On 17. 04. 19 14:29, Jean-Jacques Hiblot wrote:
On 17/04/2019 12:38, Michal Simek wrote:
On 17. 04. 19 11:34, Jean-Jacques Hiblot wrote:
Hi Michal,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
This series looks better. Is this able to also handle different images then just dtbs?
Sorry I thought had answered this.
Yes this is able to handle different image types, not just dtbos.
Have you been able to play with it ? any additional comment ?
I haven't had a time but series is going in a right direction. I found 2 days ago that applying my patch is increasing size for some platforms that travis is failing. It means I would definitely suggest you to run travis on branch with all patches applied to see if this passing or some changes need to happen.
Already done. https://travis-ci.org/jjhiblot/u-boot/builds/511617974
The failures (except dra7 which is unresolved) are all related to the generation of u-boot.itb (one patch replaces u-boot.img with a link to u-boot.itb, making travis build u-boot.itb)
Was the broken platform the am335x_evm? In that case, the fix is in the series. I disabled advanced FIT features for this platform as this is definitely not needed.
https://travis-ci.org/michalsimek/u-boot/builds/518675021
This was the issue.
aarch64: + orangepi_pc2 +aarch64-linux-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram' +aarch64-linux-ld.bfd: region `.sram' overflowed by 3152 bytes
M

Tom, Simon,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
I don't know if you had time to look at this series. Its purpose is to allow the SPL to apply DT overlays to the FDT loaded for u-boot based on a runtime detection of the HW.
We are going to need this kind of feature in our tree, I would really appreciate your feedback. I don't want to go in the wrong direction.
JJ
This series looks better. Is this able to also handle different images then just dtbs? Thanks, Michal

Hi Jean-Jacques,
On Wed, 17 Apr 2019 at 02:48, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
Tom, Simon,
On 28/03/2019 15:03, Michal Simek wrote:
On 27. 03. 19 16:38, Jean-Jacques Hiblot wrote:
The purpose of this series is to provide the SPL with ability to apply overlays for u-boot. this is only a RFC so far, to get a feedback on the approach.
Our use-case is the support of the daughter boards of the AM65x EVM. In Linux, each board is supported by a unique overlay. The presence of the boards is detected at runtime, and some useful features (like USB) are implemented on those daughter boards. Instead of providing multiple dtbs and fall in a combinatorial pit, we propose to use DT overlays.
Patch #1 "spl: fit: Add support for applying DT overlay" has been posted a few weeks ago by Michal Simek. Patch #2 and #3 amend Michal's patch. Patch #4 and #5 are simple fixes for the Makefile Patch #6 is not required but relates to this series and will be required later by the AM6x platform Patch #7 may be a bit controversial. It basically replaces u-boot.img with a symlink to u-boot.itb in case we use a "complex" FIT (ie: if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set). This breaks buildman for several platforms because not all the binaries embedded in the FIT are available. Patch #9 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). Patch #10 disables advanced SPL FIT features to keep the size of the SPL of the am335x_evm in check Patch #11 is not required, but demonstrates on a DRA76-evm how this series can be used.
On arm, if overlay are supported, this series increases the size of the SPL by 3-4 kB.
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
I don't know if you had time to look at this series. Its purpose is to allow the SPL to apply DT overlays to the FDT loaded for u-boot based on a runtime detection of the HW.
We are going to need this kind of feature in our tree, I would really appreciate your feedback. I don't want to go in the wrong direction.
No I have not looked at this yet. My only comment so far is to make sure that this feature is fully optional so it does not expand the size of SPL for other boards.
Regards, Simon
participants (3)
-
Jean-Jacques Hiblot
-
Michal Simek
-
Simon Glass