Skip to contentSkip to conversation

spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

PATCH New Jean-Jacques Hiblot 5 participants 14 messages Jul 7, 2017 – Jul 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

  MLO.reference         123450
  MLO.lzo_1_DTB         123715    +265
  MLO.lzo_4_DTB         124237    +787
  MLO.gzip_4_DTB        132006    +8556
  MLO.no_comp_4_DTB     134184    +10734
 common/spl/spl_fit.c |  2 +-
 dts/Kconfig          | 48 ++++++++++++++++++++++++++++++++++
 dts/Makefile         | 18 +++++++++++--
 include/spl.h        | 15 +++++++++++
 lib/Kconfig          | 11 ++++++++
 lib/Makefile         |  6 ++---
 lib/fdtdec.c         | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/Makefile.spl | 35 ++++++++++++++++++++++++-
 8 files changed, 201 insertions(+), 7 deletions(-)
common/spl/spl_fit.c +1 -1
index 4c42a96..3479b05 100644
@@ -75,7 +75,7 @@ static int spl_fit_find_config_node(const void *fdt)
  * Return:	the node offset of the respective image node or a negative
  * 		error number.
  */
-static int spl_fit_get_image_node(const void *fit, int images,
+int spl_fit_get_image_node(const void *fit, int images,
 				  const char *type, int index)
 {
 	const char *name, *str;
dts/Kconfig +48 -0

54 lines not on this page · raw message

dts/Makefile +16 -2
index 3a93daf..5cab6bd 100644
@@ -22,9 +22,23 @@ DTB := $(ARCH_PATH)/$(DEVICE_TREE).dtb
 dtb_depends += $(DTB:.dtb=.dts)
 endif
 
+
+ARCH_SPL_DTB := $(patsubst %,$(ARCH_PATH)/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+LOCAL_SPL_DTBS := $(patsubst %,$(obj)/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+
+.PHONY: arch-dtbs
+
 $(obj)/dt.dtb: $(DTB) FORCE
 	$(call if_changed,shipped)
 
+ARCH_SPL_DTB_EXECPT_ONE := $(filter-out $(DTB),$(ARCH_SPL_DTB))
+$(ARCH_SPL_DTB_EXECPT_ONE): arch-dtbs
+	@
+
+.SECONDEXPANSION:
+$(LOCAL_SPL_DTBS): $$(patsubst $(TARGETDIR)/%, %, arch/$(ARCH)/$$@)
+	$(shell cp $< $@)
+
 targets += dt.dtb
 
 $(DTB): $(dtb_depends)
@@ -46,10 +60,10 @@ arch-dtbs:
 
 obj-$(CONFIG_OF_EMBED) := dt.dtb.o
 
-dtbs: $(obj)/dt.dtb
+dtbs: $(obj)/dt.dtb $(LOCAL_SPL_DTBS)
 	@:
 
-clean-files := dt.dtb.S
+clean-files := dt.dtb.S *.dtb
 
 # Let clean descend into dts directories
 subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts
include/spl.h +15 -0
index ffadce9..8ff96c3 100644
@@ -49,6 +49,21 @@ struct spl_load_info {
 };
 
 /**
+ * spl_fit_get_image_node(): By using the matching configuration subnode,
+ * retrieve the name of an image, specified by a property name and an index
+ * into that.
+ * @fit:	Pointer to the FDT blob.
+ * @images:	Offset of the /images subnode.
+ * @type:	Name of the property within the configuration subnode.
+ * @index:	Index into the list of strings in this property.
+ *
+ * Return:	the node offset of the respective image node or a negative
+ *		error number.
+ */
+int spl_fit_get_image_node(const void *fit, int images,
+				  const char *type, int index);
+
+/**
  * spl_load_simple_fit() - Loads a fit image from a device.
  * @spl_image:	Image description to set up
  * @info:	Structure containing the information required to load data.
lib/Kconfig +11 -0
index 09670f0..6865325 100644
@@ -158,6 +158,17 @@ config LZMA
 
 config LZO
 	bool
+
+config SPL_LZO
+	bool
+
+config SPL_GZIP
+	bool
+	depends on SPL_ZLIB
+
+config SPL_ZLIB
+	bool
+
 endmenu
 
 config ERRNO_STR
lib/Makefile +3 -3
index eacc7d6..82b2de0 100644
@@ -4,14 +4,15 @@
 #
 # SPDX-License-Identifier:	GPL-2.0+
 #
+obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
+obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
+obj-$(CONFIG_$(SPL_)LZO) += lzo/
 
 ifndef CONFIG_SPL_BUILD
-
 obj-$(CONFIG_EFI) += efi/
 obj-$(CONFIG_EFI_LOADER) += efi_loader/
 obj-$(CONFIG_LZMA) += lzma/
 obj-$(CONFIG_LZO) += lzo/
-obj-$(CONFIG_ZLIB) += zlib/
 obj-$(CONFIG_BZIP2) += bzip2/
 obj-$(CONFIG_TIZEN) += tizen/
 obj-$(CONFIG_FIT) += libfdt/
@@ -26,7 +27,6 @@ obj-y += crc16.o
 obj-$(CONFIG_ERRNO_STR) += errno_str.o
 obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
-obj-$(CONFIG_GZIP) += gunzip.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
 obj-y += initcall.o
lib/fdtdec.c +73 -0

91 lines not on this page · raw message

scripts/Makefile.spl +34 -1
index ac3c2c7..39aa939 100644
@@ -202,10 +202,21 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@
 quiet_cmd_copy = COPY    $@
       cmd_copy = cp $< $@
 
+ifneq ($(CONFIG_SPL_MULTI_DTB),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb
+else ifeq ($(CONFIG_SPL_MULTI_DTB_LZO),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo
+else ifeq ($(CONFIG_SPL_MULTI_DTB_GZ),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz
+else
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
+endif
+
+
 ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy)
 $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
 		$(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
-		$(obj)/$(SPL_BIN).dtb FORCE
+		$(FINAL_DTB_CONTAINER)  FORCE
 	$(call if_changed,cat)
 
 $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE
@@ -369,6 +380,28 @@ checkdtoc: tools
 PHONY += FORCE
 FORCE:
 
+PHONY += dtbs
+dtbs:
+	$(Q)$(MAKE) $(build)=dts dtbs
+
 # Declare the contents of the .PHONY variable as phony.  We keep that
 # information in a variable so we can use it in if_changed and friends.
 .PHONY: $(PHONY)
+
+SHRUNK_ARCH_DTB = $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+.SECONDEXPANSION:
+$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@)
+	$(call if_changed,fdtgrep)
+
+MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+	-n "Multi DTB fit image for $(SPL_BIN) JJH" -E \
+	$(patsubst %,-b $(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+
+$(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE
+	$(call if_changed,mkimage)
+
+$(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit
+	@gzip -kf9 $< > $@
+
+$(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit
+	@lzop -f9 $< > $@
\ No newline at end of file
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

+ Tom Rini <[email protected]>

Quoted 378 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

   MLO.reference         123450
   MLO.lzo_1_DTB         123715    +265
   MLO.lzo_4_DTB         124237    +787
   MLO.gzip_4_DTB        132006    +8556
   MLO.no_comp_4_DTB     134184    +10734
  common/spl/spl_fit.c |  2 +-
  dts/Kconfig          | 48 ++++++++++++++++++++++++++++++++++
  dts/Makefile         | 18 +++++++++++--
  include/spl.h        | 15 +++++++++++
  lib/Kconfig          | 11 ++++++++
  lib/Makefile         |  6 ++---
  lib/fdtdec.c         | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  scripts/Makefile.spl | 35 ++++++++++++++++++++++++-
  8 files changed, 201 insertions(+), 7 deletions(-)
common/spl/spl_fit.c +1 -1
index 4c42a96..3479b05 100644
@@ -75,7 +75,7 @@ static int spl_fit_find_config_node(const void *fdt)
   * Return:	the node offset of the respective image node or a negative
   * 		error number.
   */
-static int spl_fit_get_image_node(const void *fit, int images,
+int spl_fit_get_image_node(const void *fit, int images,
  				  const char *type, int index)
  {
  	const char *name, *str;
dts/Kconfig +48 -0
index b3009af..80f21e0 100644
@@ -99,6 +99,54 @@ config OF_LIST
  	  reading a board ID value). This is a list of device tree files
  	  (without the directory or .dtb suffix) separated by <space>.
 
+
+config SPL_MULTI_DTB
+	depends on SPL_LOAD_FIT && SPL_OF_CONTROL && !SPL_OF_PLATDATA
+	bool "support embedding several DTB in the SPL"
+	default n
+
+config SPL_OF_LIST
+	string "List of device tree files to include for DT control in SPL"
+	depends on SPL_MULTI_DTB
+	default OF_LIST
+	help
+	  blablablabla
+
+choice
+	prompt "SPL OF LIST compression"
+	depends on SPL_MULTI_DTB
+	default SPL_MULTI_DTB_LZO
+
+config SPL_MULTI_DTB_LZO
+	bool "Compress the DTBs with LZO"
+	depends on SYS_MALLOC_F
+	select SPL_LZO
+	help
+	  Compres the FIT image containing the DTBs available for the SPL
+	  using LZO compression. (requires lzop on host).
+
+config SPL_MULTI_DTB_GZ
+	bool "Compress the DTBs with GZip"
+	depends on SYS_MALLOC_F
+	select SPL_GZIP
+	help
+	  Compres the FIT image containing the DTBs available for the SPL
+	  using GZIP compression. (requires gzip on host)
+
+config SPL_MULTI_DTB_NO_COMPRESSION
+	bool "do not compress the DTBs"
+	help
+	  Do not tompres the FIT image containing the DTBs available for the SPL.
+	  Use this options only if LZO is not available and the DTBs are very small.
+endchoice
+
+config SPL_MULTI_DTB_GZ_SZ
+	hex "Size of mmemory allocated to uncompress the dtbs"
+	depends on SYS_MALLOC_F && (SPL_MULTI_DTB_GZ || SPL_MULTI_DTB_LZO)
+	default 0x10000
+	help
+	   blablabla
+
  config OF_SPL_REMOVE_PROPS
  	string "List of device tree properties to drop for SPL"
  	depends on SPL_OF_CONTROL
dts/Makefile +16 -2
index 3a93daf..5cab6bd 100644
@@ -22,9 +22,23 @@ DTB := $(ARCH_PATH)/$(DEVICE_TREE).dtb
  dtb_depends += $(DTB:.dtb=.dts)
  endif
 
+
+ARCH_SPL_DTB := $(patsubst %,$(ARCH_PATH)/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+LOCAL_SPL_DTBS := $(patsubst %,$(obj)/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+
+.PHONY: arch-dtbs
+
  $(obj)/dt.dtb: $(DTB) FORCE
  	$(call if_changed,shipped)
 
+ARCH_SPL_DTB_EXECPT_ONE := $(filter-out $(DTB),$(ARCH_SPL_DTB))
+$(ARCH_SPL_DTB_EXECPT_ONE): arch-dtbs
+	@
+
+.SECONDEXPANSION:
+$(LOCAL_SPL_DTBS): $$(patsubst $(TARGETDIR)/%, %, arch/$(ARCH)/$$@)
+	$(shell cp $< $@)
+
  targets += dt.dtb
 
  $(DTB): $(dtb_depends)
@@ -46,10 +60,10 @@ arch-dtbs:
 
  obj-$(CONFIG_OF_EMBED) := dt.dtb.o
 
-dtbs: $(obj)/dt.dtb
+dtbs: $(obj)/dt.dtb $(LOCAL_SPL_DTBS)
  	@:
 
-clean-files := dt.dtb.S
+clean-files := dt.dtb.S *.dtb
 
  # Let clean descend into dts directories
  subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts
include/spl.h +15 -0
index ffadce9..8ff96c3 100644
@@ -49,6 +49,21 @@ struct spl_load_info {
  };
 
  /**
+ * spl_fit_get_image_node(): By using the matching configuration subnode,
+ * retrieve the name of an image, specified by a property name and an index
+ * into that.
+ * @fit:	Pointer to the FDT blob.
+ * @images:	Offset of the /images subnode.
+ * @type:	Name of the property within the configuration subnode.
+ * @index:	Index into the list of strings in this property.
+ *
+ * Return:	the node offset of the respective image node or a negative
+ *		error number.
+ */
+int spl_fit_get_image_node(const void *fit, int images,
+				  const char *type, int index);
+
+/**
   * spl_load_simple_fit() - Loads a fit image from a device.
   * @spl_image:	Image description to set up
   * @info:	Structure containing the information required to load data.
lib/Kconfig +11 -0
index 09670f0..6865325 100644
@@ -158,6 +158,17 @@ config LZMA
 
  config LZO
  	bool
+
+config SPL_LZO
+	bool
+
+config SPL_GZIP
+	bool
+	depends on SPL_ZLIB
+
+config SPL_ZLIB
+	bool
+
  endmenu
 
  config ERRNO_STR
lib/Makefile +3 -3
index eacc7d6..82b2de0 100644
@@ -4,14 +4,15 @@
  #
  # SPDX-License-Identifier:	GPL-2.0+
  #
+obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
+obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
+obj-$(CONFIG_$(SPL_)LZO) += lzo/
 
  ifndef CONFIG_SPL_BUILD
-
  obj-$(CONFIG_EFI) += efi/
  obj-$(CONFIG_EFI_LOADER) += efi_loader/
  obj-$(CONFIG_LZMA) += lzma/
  obj-$(CONFIG_LZO) += lzo/
-obj-$(CONFIG_ZLIB) += zlib/
  obj-$(CONFIG_BZIP2) += bzip2/
  obj-$(CONFIG_TIZEN) += tizen/
  obj-$(CONFIG_FIT) += libfdt/
@@ -26,7 +27,6 @@ obj-y += crc16.o
  obj-$(CONFIG_ERRNO_STR) += errno_str.o
  obj-$(CONFIG_FIT) += fdtdec_common.o
  obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
-obj-$(CONFIG_GZIP) += gunzip.o
  obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
  obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
  obj-y += initcall.o
lib/fdtdec.c +73 -0
index 91503b8..68322d8 100644
@@ -7,6 +7,8 @@
  #include <common.h>
  #include <dm.h>
  #include <errno.h>
+#include <spl.h>
+#include <linux/lzo.h>
  #include <serial.h>
  #include <libfdt.h>
  #include <fdt_support.h>
@@ -1208,6 +1210,65 @@ int fdtdec_setup_memory_banksize(void)
  }
  #endif
 
+#if defined(CONFIG_SPL_MULTI_DTB) && defined(CONFIG_SPL_BUILD)
+const void *get_dtb_blob_from_fit(const void *fit)
+{
+	int node, images;
+	ulong fit_size, offset;
+
+#if defined(CONFIG_SPL_MULTI_DTB_GZ) || defined(CONFIG_SPL_MULTI_DTB_LZO)
+	if (image_get_magic(fit) != FDT_MAGIC) {
+		/* not a valid FIT, maybe it is a compressed fit */
+		void *dst = malloc(CONFIG_SPL_MULTI_DTB_GZ_SZ);
+		size_t sz_out = CONFIG_SPL_MULTI_DTB_GZ_SZ;
+		ulong sz_in = 1024*1024; /* not more than 1MB */
+		if (!dst) {
+			puts("Unable to allocate memory to uncompress the DTBs\n");
+			return NULL;
+		}
+#ifdef CONFIG_SPL_MULTI_DTB_GZ
+		int rc = gunzip(dst, sz_out,
+				(u8 *)fit, &sz_in);
+#elif defined CONFIG_SPL_MULTI_DTB_LZO
+		int rc = lzop_decompress(fit, sz_in, dst, &sz_out);
+#endif
+		if (rc < 0) {
+			/* not a valid compressed blob */
+			free(dst);
+			return NULL;
+		}
+		fit = dst;
+	}
+#endif
+
+	if (image_get_magic(fit) != FDT_MAGIC) {
+		debug("not a FIT image\n");
+		return NULL;
+	}
+
+	fit_size = fdt_totalsize(fit);
+	fit_size = (fit_size + 3) & ~3; /* align on 32bit upper boundary */
+
+	/* find the node holding the images information */
+	images = fdt_path_offset(fit, FIT_IMAGES_PATH);
+	if (images < 0) {
+		debug("could not find the '/images' node\n");
+		return NULL;
+	}
+
+	/* Figure out which device tree the board wants to use */
+	node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
+	if (node < 0)
+		return NULL;
+
+	offset = fdtdec_get_int(fit, node, "data-offset", -1);
+	if (offset < 0)
+		return NULL;
+
+	return fit + fit_size + offset;
+}
+#endif
+
  int fdtdec_setup(void)
  {
  #if CONFIG_IS_ENABLED(OF_CONTROL)
@@ -1239,6 +1300,18 @@ int fdtdec_setup(void)
  	gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
  						(uintptr_t)gd->fdt_blob);
  # endif
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB)
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+		const void *fdt_blob;
+		fdt_blob = get_dtb_blob_from_fit(gd->fdt_blob);
+		if (fdt_blob) {
+			debug("found FIT containg several DTBs\n");
+			gd->fdt_blob = fdt_blob;
+		} else {
+			debug("legacy DTB file\n");
+		}
+	}
+#endif
  #endif
  	return fdtdec_prepare_fdt();
  }
scripts/Makefile.spl +34 -1
index ac3c2c7..39aa939 100644
@@ -202,10 +202,21 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@
  quiet_cmd_copy = COPY    $@
        cmd_copy = cp $< $@
 
+ifneq ($(CONFIG_SPL_MULTI_DTB),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb
+else ifeq ($(CONFIG_SPL_MULTI_DTB_LZO),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo
+else ifeq ($(CONFIG_SPL_MULTI_DTB_GZ),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz
+else
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
+endif
+
+
  ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy)
  $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
  		$(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
-		$(obj)/$(SPL_BIN).dtb FORCE
+		$(FINAL_DTB_CONTAINER)  FORCE
  	$(call if_changed,cat)
 
  $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE
@@ -369,6 +380,28 @@ checkdtoc: tools
  PHONY += FORCE
  FORCE:
 
+PHONY += dtbs
+dtbs:
+	$(Q)$(MAKE) $(build)=dts dtbs
+
  # Declare the contents of the .PHONY variable as phony.  We keep that
  # information in a variable so we can use it in if_changed and friends.
  .PHONY: $(PHONY)
+
+SHRUNK_ARCH_DTB = $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+.SECONDEXPANSION:
+$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@)
+	$(call if_changed,fdtgrep)
+
+MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+	-n "Multi DTB fit image for $(SPL_BIN) JJH" -E \
+	$(patsubst %,-b $(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+
+$(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE
+	$(call if_changed,mkimage)
+
+$(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit
+	@gzip -kf9 $< > $@
+
+$(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit
+	@lzop -f9 $< > $@
\ No newline at end of file
#2 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Hi all,

I forgot to mention in the title that it is a RFC only. I'd like to know if you think that this feature is desirable or not. and if the approach seems correct. If so I will send a proper patch later with the proper Kconfig description and proposed modifications.

Jean-Jacques

Quoted 391 lines · Jean-Jacques Hiblot

+ Tom Rini <[email protected]>

Quoted 372 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

   MLO.reference         123450
   MLO.lzo_1_DTB         123715    +265
   MLO.lzo_4_DTB         124237    +787
   MLO.gzip_4_DTB        132006    +8556
   MLO.no_comp_4_DTB     134184    +10734
  common/spl/spl_fit.c |  2 +-
  dts/Kconfig          | 48 ++++++++++++++++++++++++++++++++++
  dts/Makefile         | 18 +++++++++++--
  include/spl.h        | 15 +++++++++++
  lib/Kconfig          | 11 ++++++++
  lib/Makefile         |  6 ++---
  lib/fdtdec.c         | 73 
++++++++++++++++++++++++++++++++++++++++++++++++++++
  scripts/Makefile.spl | 35 ++++++++++++++++++++++++-
  8 files changed, 201 insertions(+), 7 deletions(-)
common/spl/spl_fit.c +0 -0
index 4c42a96..3479b05 100644
@@ -75,7 +75,7 @@ static int spl_fit_find_config_node(const void *fdt)
   * Return:    the node offset of the respective image node or a 

negative
* error number.
*/

common/spl/spl_fit.c +1 -1
-static int spl_fit_get_image_node(const void *fit, int images,
+int spl_fit_get_image_node(const void *fit, int images,
                    const char *type, int index)
  {
      const char *name, *str;
dts/Kconfig +37 -0
index b3009af..80f21e0 100644
@@ -99,6 +99,54 @@ config OF_LIST
        reading a board ID value). This is a list of device tree files
        (without the directory or .dtb suffix) separated by <space>.
  +
+config SPL_MULTI_DTB
+    depends on SPL_LOAD_FIT && SPL_OF_CONTROL && !SPL_OF_PLATDATA
+    bool "support embedding several DTB in the SPL"
+    default n
+
+config SPL_OF_LIST
+    string "List of device tree files to include for DT control in SPL"
+    depends on SPL_MULTI_DTB
+    default OF_LIST
+    help
+      blablablabla
+
+choice
+    prompt "SPL OF LIST compression"
+    depends on SPL_MULTI_DTB
+    default SPL_MULTI_DTB_LZO
+
+config SPL_MULTI_DTB_LZO
+    bool "Compress the DTBs with LZO"
+    depends on SYS_MALLOC_F
+    select SPL_LZO
+    help
+      Compres the FIT image containing the DTBs available for the SPL
+      using LZO compression. (requires lzop on host).
+
+config SPL_MULTI_DTB_GZ
+    bool "Compress the DTBs with GZip"
+    depends on SYS_MALLOC_F
+    select SPL_GZIP
+    help
+      Compres the FIT image containing the DTBs available for the SPL
+      using GZIP compression. (requires gzip on host)
+
+config SPL_MULTI_DTB_NO_COMPRESSION
+    bool "do not compress the DTBs"
+    help
+      Do not tompres the FIT image containing the DTBs available for 

the SPL.
+ Use this options only if LZO is not available and the DTBs are
very small.

dts/Kconfig +9 -0
+endchoice
+
+config SPL_MULTI_DTB_GZ_SZ
+    hex "Size of mmemory allocated to uncompress the dtbs"
+    depends on SYS_MALLOC_F && (SPL_MULTI_DTB_GZ || SPL_MULTI_DTB_LZO)
+    default 0x10000
+    help
+       blablabla
+
  config OF_SPL_REMOVE_PROPS
      string "List of device tree properties to drop for SPL"
      depends on SPL_OF_CONTROL
dts/Makefile +14 -0
index 3a93daf..5cab6bd 100644
@@ -22,9 +22,23 @@ DTB := $(ARCH_PATH)/$(DEVICE_TREE).dtb
  dtb_depends += $(DTB:.dtb=.dts)
  endif
  +
+ARCH_SPL_DTB := $(patsubst %,$(ARCH_PATH)/%.dtb,$(subst 
 ",,$(CONFIG_SPL_OF_LIST)))
+LOCAL_SPL_DTBS := $(patsubst %,$(obj)/%.dtb,$(subst 
 ",,$(CONFIG_SPL_OF_LIST)))
+
+.PHONY: arch-dtbs
+
  $(obj)/dt.dtb: $(DTB) FORCE
      $(call if_changed,shipped)
  +ARCH_SPL_DTB_EXECPT_ONE := $(filter-out $(DTB),$(ARCH_SPL_DTB))
+$(ARCH_SPL_DTB_EXECPT_ONE): arch-dtbs
+    @
+
+.SECONDEXPANSION:
+$(LOCAL_SPL_DTBS): $$(patsubst $(TARGETDIR)/%, %, arch/$(ARCH)/$$@)
+    $(shell cp $< $@)
+
  targets += dt.dtb
    $(DTB): $(dtb_depends)
@@ -46,10 +60,10 @@ arch-dtbs:
    obj-$(CONFIG_OF_EMBED) := dt.dtb.o
  -dtbs: $(obj)/dt.dtb
+dtbs: $(obj)/dt.dtb $(LOCAL_SPL_DTBS)
      @:
  -clean-files := dt.dtb.S
+clean-files := dt.dtb.S *.dtb
    # Let clean descend into dts directories
  subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 

../arch/sandbox/dts ../arch/x86/dts

include/spl.h +2 -0
index ffadce9..8ff96c3 100644
@@ -49,6 +49,21 @@ struct spl_load_info {
  };
    /**
+ * spl_fit_get_image_node(): By using the matching configuration 
 subnode,
+ * retrieve the name of an image, specified by a property name and 

an index
+ * into that.
+ * @fit: Pointer to the FDT blob.
+ * @images: Offset of the /images subnode.
+ * @type: Name of the property within the configuration subnode.
+ * @index: Index into the list of strings in this property.
+ *
+ * Return: the node offset of the respective image node or a
negative
+ * error number.
+ */

include/spl.h +4 -0
+int spl_fit_get_image_node(const void *fit, int images,
+                  const char *type, int index);
+
+/**
   * spl_load_simple_fit() - Loads a fit image from a device.
   * @spl_image:    Image description to set up
   * @info:    Structure containing the information required to load 

data.

lib/Kconfig +11 -0
index 09670f0..6865325 100644
@@ -158,6 +158,17 @@ config LZMA
    config LZO
      bool
+
+config SPL_LZO
+    bool
+
+config SPL_GZIP
+    bool
+    depends on SPL_ZLIB
+
+config SPL_ZLIB
+    bool
+
  endmenu
    config ERRNO_STR
lib/Makefile +3 -3
index eacc7d6..82b2de0 100644
@@ -4,14 +4,15 @@
  #
  # SPDX-License-Identifier:    GPL-2.0+
  #
+obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
+obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
+obj-$(CONFIG_$(SPL_)LZO) += lzo/
    ifndef CONFIG_SPL_BUILD
-
  obj-$(CONFIG_EFI) += efi/
  obj-$(CONFIG_EFI_LOADER) += efi_loader/
  obj-$(CONFIG_LZMA) += lzma/
  obj-$(CONFIG_LZO) += lzo/
-obj-$(CONFIG_ZLIB) += zlib/
  obj-$(CONFIG_BZIP2) += bzip2/
  obj-$(CONFIG_TIZEN) += tizen/
  obj-$(CONFIG_FIT) += libfdt/
@@ -26,7 +27,6 @@ obj-y += crc16.o
  obj-$(CONFIG_ERRNO_STR) += errno_str.o
  obj-$(CONFIG_FIT) += fdtdec_common.o
  obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
-obj-$(CONFIG_GZIP) += gunzip.o
  obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
  obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
  obj-y += initcall.o
lib/fdtdec.c +72 -0
index 91503b8..68322d8 100644
@@ -7,6 +7,8 @@
  #include <common.h>
  #include <dm.h>
  #include <errno.h>
+#include <spl.h>
+#include <linux/lzo.h>
  #include <serial.h>
  #include <libfdt.h>
  #include <fdt_support.h>
@@ -1208,6 +1210,65 @@ int fdtdec_setup_memory_banksize(void)
  }
  #endif
  +#if defined(CONFIG_SPL_MULTI_DTB) && defined(CONFIG_SPL_BUILD)
+const void *get_dtb_blob_from_fit(const void *fit)
+{
+    int node, images;
+    ulong fit_size, offset;
+
+#if defined(CONFIG_SPL_MULTI_DTB_GZ) || 
 defined(CONFIG_SPL_MULTI_DTB_LZO)
+    if (image_get_magic(fit) != FDT_MAGIC) {
+        /* not a valid FIT, maybe it is a compressed fit */
+        void *dst = malloc(CONFIG_SPL_MULTI_DTB_GZ_SZ);
+        size_t sz_out = CONFIG_SPL_MULTI_DTB_GZ_SZ;
+        ulong sz_in = 1024*1024; /* not more than 1MB */
+        if (!dst) {
+            puts("Unable to allocate memory to uncompress the DTBs\n");
+            return NULL;
+        }
+#ifdef CONFIG_SPL_MULTI_DTB_GZ
+        int rc = gunzip(dst, sz_out,
+                (u8 *)fit, &sz_in);
+#elif defined CONFIG_SPL_MULTI_DTB_LZO
+        int rc = lzop_decompress(fit, sz_in, dst, &sz_out);
+#endif
+        if (rc < 0) {
+            /* not a valid compressed blob */
+            free(dst);
+            return NULL;
+        }
+        fit = dst;
+    }
+#endif
+
+    if (image_get_magic(fit) != FDT_MAGIC) {
+        debug("not a FIT image\n");
+        return NULL;
+    }
+
+    fit_size = fdt_totalsize(fit);
+    fit_size = (fit_size + 3) & ~3; /* align on 32bit upper boundary */
+
+    /* find the node holding the images information */
+    images = fdt_path_offset(fit, FIT_IMAGES_PATH);
+    if (images < 0) {
+        debug("could not find the '/images' node\n");
+        return NULL;
+    }
+
+    /* Figure out which device tree the board wants to use */
+    node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
+    if (node < 0)
+        return NULL;
+
+    offset = fdtdec_get_int(fit, node, "data-offset", -1);
+    if (offset < 0)
+        return NULL;
+
+    return fit + fit_size + offset;
+}
+#endif
+
  int fdtdec_setup(void)
  {
  #if CONFIG_IS_ENABLED(OF_CONTROL)
@@ -1239,6 +1300,18 @@ int fdtdec_setup(void)
      gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
                          (uintptr_t)gd->fdt_blob);
  # endif
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB)
+    if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+        const void *fdt_blob;
+        fdt_blob = get_dtb_blob_from_fit(gd->fdt_blob);
+        if (fdt_blob) {
+            debug("found FIT containg several DTBs\n");
+            gd->fdt_blob = fdt_blob;
+        } else {
+            debug("legacy DTB file\n");
+        }
+    }
+#endif
  #endif
      return fdtdec_prepare_fdt();
  }
scripts/Makefile.spl +14 -1
index ac3c2c7..39aa939 100644
@@ -202,10 +202,21 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@
  quiet_cmd_copy = COPY    $@
        cmd_copy = cp $< $@
  +ifneq ($(CONFIG_SPL_MULTI_DTB),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb
+else ifeq ($(CONFIG_SPL_MULTI_DTB_LZO),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo
+else ifeq ($(CONFIG_SPL_MULTI_DTB_GZ),y)
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz
+else
+FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
+endif
+
+
  ifeq 
 ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy)
  $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
          $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
-        $(obj)/$(SPL_BIN).dtb FORCE
+        $(FINAL_DTB_CONTAINER)  FORCE
      $(call if_changed,cat)
    $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE
@@ -369,6 +380,28 @@ checkdtoc: tools
  PHONY += FORCE
  FORCE:
  +PHONY += dtbs
+dtbs:
+    $(Q)$(MAKE) $(build)=dts dtbs
+
  # Declare the contents of the .PHONY variable as phony.  We keep that
  # information in a variable so we can use it in if_changed and 

friends.
.PHONY: $(PHONY)

scripts/Makefile.spl +2 -0
+
+SHRUNK_ARCH_DTB = $(patsubst %,$(obj)/dts/%.dtb,$(subst 

",,$(CONFIG_SPL_OF_LIST)))
+.SECONDEXPANSION:
+$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@)

scripts/Makefile.spl +3 -0
+    $(call if_changed,fdtgrep)
+
+MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T 

firmware -C none -O u-boot \

scripts/Makefile.spl +2 -0
+    -n "Multi DTB fit image for $(SPL_BIN) JJH" -E \
+    $(patsubst %,-b $(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))

scripts/Makefile.spl checkdtoc: tools · line 407

Quoted 10 lines
scripts/Makefile.spl +9 -0
+
+$(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE
+    $(call if_changed,mkimage)
+
+$(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit
+    @gzip -kf9 $< > $@
+
+$(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit
+    @lzop -f9 $< > $@
\ No newline at end of file

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#3 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

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

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

  MLO.reference         123450
  MLO.lzo_1_DTB         123715    +265
  MLO.lzo_4_DTB         124237    +787
  MLO.gzip_4_DTB        132006    +8556
  MLO.no_comp_4_DTB     134184    +10734

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded? I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

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

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 23 lines · Tom Rini
Quoted 14 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

   MLO.reference         123450
   MLO.lzo_1_DTB         123715    +265
   MLO.lzo_4_DTB         124237    +787
   MLO.gzip_4_DTB        132006    +8556
   MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 6 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Jean-Jacques

Quoted 1 line
#5 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 23 lines · Jean-Jacques Hiblot
Quoted 20 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

   MLO.reference         123450
   MLO.lzo_1_DTB         123715    +265
   MLO.lzo_4_DTB         124237    +787
   MLO.gzip_4_DTB        132006    +8556
   MLO.no_comp_4_DTB     134184    +10734

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

Quoted 13 lines
Quoted 3 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 6 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 4 lines

Jean-Jacques

Quoted 1 line
#6 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 31 lines · Franklin S Cooper Jr
Quoted 22 lines · Jean-Jacques Hiblot
Quoted 20 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

I'll add the measurements in the next version.

Quoted 7 lines

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

It makes sense. I'll look into it.
I wasn't aware of your work in this area (CONFIG_FIT_EMBED). Now that is in mainline u-boot, I'll leverage on it as it mostly does the same thing. At the end, I may just end up removing the restriction that prevents using CONFIG_FIT_EMBED in the SPL and move the decompression stage at the very end of fdtdec_setup()

JJ

Quoted 28 lines
Quoted 14 lines
Quoted 4 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 6 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 1 line

Jean-Jacques

#7 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 38 lines · Jean-Jacques Hiblot
Quoted 31 lines · Franklin S Cooper Jr
Quoted 22 lines · Jean-Jacques Hiblot
Quoted 20 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

I'll add the measurements in the next version.

Quoted 8 lines
Quoted 7 lines

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

It makes sense. I'll look into it.

I made a short experiment and it turns out that the compression ratio is better when compressing the whole FIT image:
15468 spl/u-boot-spl.multidtb.fit -- baseline: 4 dtbs, no compression
2389 spl/u-boot-spl.multidtb.fit.lzo -- compressed as a whole 7120 spl/u-boot-spl.multidtb.itb -- FIT containing individually compressed dtbs

Since the DTB for the SPL should be quite small and kind of similar to each other in the case of board variants, I think it's better to keep the compression stage at the level of the FIT image.

Quoted 41 lines

I wasn't aware of your work in this area (CONFIG_FIT_EMBED). Now that is in mainline u-boot, I'll leverage on it as it mostly does the same thing.
At the end, I may just end up removing the restriction that prevents using CONFIG_FIT_EMBED in the SPL and move the decompression stage at the very end of fdtdec_setup()

JJ

Quoted 32 lines
Quoted 18 lines
Quoted 6 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of
it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 8 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file
that represents the SoC such that any real boards can get U-Boot loaded
and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 1 line

Jean-Jacques

#8 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 48 lines · Jean-Jacques Hiblot
Quoted 45 lines · Jean-Jacques Hiblot
Quoted 31 lines · Franklin S Cooper Jr
Quoted 22 lines · Jean-Jacques Hiblot
Quoted 20 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

I'll add the measurements in the next version.

Quoted 7 lines

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

Quoted 7 lines
Quoted 1 line

It makes sense. I'll look into it.

I made a short experiment and it turns out that the compression ratio is better when compressing the whole FIT image:
15468 spl/u-boot-spl.multidtb.fit -- baseline: 4 dtbs, no compression
2389 spl/u-boot-spl.multidtb.fit.lzo -- compressed as a whole 7120 spl/u-boot-spl.multidtb.itb -- FIT containing individually compressed dtbs

Just to clarify is the last one also using lzo?

Quoted 4 lines

Since the DTB for the SPL should be quite small and kind of similar to each other in the case of board variants, I think it's better to keep the compression stage at the level of the FIT image.

Ok

Quoted 43 lines
Quoted 42 lines

I wasn't aware of your work in this area (CONFIG_FIT_EMBED). Now that is in mainline u-boot, I'll leverage on it as it mostly does the same thing.
At the end, I may just end up removing the restriction that prevents using CONFIG_FIT_EMBED in the SPL and move the decompression stage at the very end of fdtdec_setup()

JJ

Quoted 32 lines
Quoted 18 lines
Quoted 6 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of
it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 8 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file
that represents the SoC such that any real boards can get U-Boot loaded
and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 1 line

Jean-Jacques

#9 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

In reply to Jean-Jacques Hiblot

Hi,

Quoted 52 lines · Jean-Jacques Hiblot
Quoted 35 lines · Franklin S Cooper Jr
Quoted 24 lines · Jean-Jacques Hiblot
Quoted 21 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

I'll add the measurements in the next version.

Quoted 8 lines

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

Quoted 6 lines

It makes sense. I'll look into it.
I wasn't aware of your work in this area (CONFIG_FIT_EMBED). Now that is in mainline u-boot, I'll leverage on it as it mostly does the same thing. At the end, I may just end up removing the restriction that prevents using CONFIG_FIT_EMBED in the SPL and move the decompression stage at the very end of fdtdec_setup()

I am not too keen on CONFIG_FIT_EMBED as a name since it is similar to CONFIG_OF_EMBED. Can we perhaps rename it, e.g. to CONFIG_OF_INSIDE_FIT? That's not a great name, maybe you can think of something better.

Quoted 38 lines

JJ

Quoted 33 lines
Quoted 17 lines
Quoted 4 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 7 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 2 lines

Jean-Jacques

#10 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Hi Jean-Jacques,

Quoted 62 lines · Simon Glass

Hi,

Quoted 52 lines · Jean-Jacques Hiblot
Quoted 35 lines · Franklin S Cooper Jr
Quoted 24 lines · Jean-Jacques Hiblot
Quoted 21 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

It would great if you can show the difference in time between todays, approach, your FIT approach gzipped and your FIT approach using lzo in terms of time between power on to SPL handling things off to U-boot.

I'll add the measurements in the next version.

Quoted 8 lines

Also would it make sense to sacrifice saving some space by not compressing the entire FIT but instead compressing dtbs individually and storing it in an uncompressed FIT? This way any additional boot time is limited to uncompressing the DTB you need. It would be especially helpful in the case of a large amount of dtbs being stored, slower devices, or using compression algorithms that save more space but its decompression is slower.

Quoted 6 lines

It makes sense. I'll look into it.
I wasn't aware of your work in this area (CONFIG_FIT_EMBED). Now that is in mainline u-boot, I'll leverage on it as it mostly does the same thing. At the end, I may just end up removing the restriction that prevents using CONFIG_FIT_EMBED in the SPL and move the decompression stage at the very end of fdtdec_setup()

Quoted 4 lines

I am not too keen on CONFIG_FIT_EMBED as a name since it is similar to CONFIG_OF_EMBED. Can we perhaps rename it, e.g. to CONFIG_OF_INSIDE_FIT? That's not a great name, maybe you can think of something better.

Also on the patch itself a few comments:

- can you split out the lb/Makefile changes into a separate patch?
- Would it be better to use fit_image_load() to reduce code duplication?
- blablablabla needs more detail :-)

Regards,
Simon

Quoted 39 lines
Quoted 39 lines

JJ

Quoted 33 lines
Quoted 17 lines
Quoted 4 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 7 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Yeah I think thats the toughest thing with my approach. It only works in situations where loading the "next stage" is consistent between boards. In my case Keystone doesn't use SPL so I benefited from the ROM handling any board specific logic to load U-boot. Not sure if it will work well in SPL since loading U-boot can vary quite a bit.

Quoted 2 lines

Jean-Jacques

#11 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

In reply to Jean-Jacques Hiblot
Quoted 39 lines · Jean-Jacques Hiblot
Quoted 23 lines · Tom Rini
Quoted 14 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

  MLO.reference         123450
  MLO.lzo_1_DTB         123715    +265
  MLO.lzo_4_DTB         124237    +787
  MLO.gzip_4_DTB        132006    +8556
  MLO.no_comp_4_DTB     134184    +10734
Quoted 3 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

Quoted 6 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded and from there have the real board dtb be used. Or am I forgetting something? Thanks!

Quoted 8 lines

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

OK. Lets move forward with seeing what this looks like as a clean series of patches with everything new being opt-in, thanks!

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

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

In reply to Jean-Jacques Hiblot
Quoted 30 lines · Jean-Jacques Hiblot
Quoted 27 lines · Tom Rini
Quoted 25 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Here are some sumbers with a DRA7 platform (numbers in bytes):
size delta with ref

   MLO.reference         123450
   MLO.lzo_1_DTB         123715    +265
   MLO.lzo_4_DTB         124237    +787
   MLO.gzip_4_DTB        132006    +8556
   MLO.no_comp_4_DTB     134184    +10734
Quoted 7 lines
Quoted 3 lines

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

This identification should eventually use DM + DT. May I know why it can't use DM I2C in SPL?

Quoted 4 lines
Quoted 4 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded

This is right. We should be using the same for SPL as well and eventually remove non-DM code.

Thanks and regards,
Lokesh

Quoted 18 lines
Quoted 2 lines

and from there have the real board dtb be used. Or am I forgetting something? Thanks!

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Jean-Jacques

Quoted 1 line

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#13 lore raw

PATCH 1/1 spl: dm: Make it possible for the SPL to pick its own DTB from a FIT

Quoted 34 lines · Lokesh Vutla
Quoted 32 lines · Jean-Jacques Hiblot
Quoted 30 lines · Tom Rini
Quoted 18 lines · Jean-Jacques Hiblot

u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the
SPL.

---

The impact in terms of boot time is not high when using LZO but I gues it can vary
from platform to platform.
The size of the SPL binary is increased (1.5kB more code on ARM), but the compression
really flattens the DTBS. so at the end of the day, enabling this option doesn't add much.

Quoted 7 lines

Here are some sumbers with a DRA7 platform (numbers in bytes):

                            size  delta with ref
    MLO.reference         123450
    MLO.lzo_1_DTB         123715    +265
    MLO.lzo_4_DTB         124237    +787
    MLO.gzip_4_DTB        132006    +8556
    MLO.no_comp_4_DTB     134184    +10734

Bearing in mind that you said in a follow up this is RFC, I'm ignoring all of the stuff that I believe you would fix in a v1. At the heart of it, are you able to tell different boards before you have a DTB loaded?

Quoted 6 lines
Quoted 4 lines

In my case (DRA7) the board can be identified before the dtb is loaded. The identification
is done by reading an eeprom on I2c. It just can't be using DM I2C in the SPL.

This identification should eventually use DM + DT. May I know why it can't use DM I2C in SPL?

The reason is that the SPL relies on the information from the EEPROM to know which
platform it is running on. It has to be done before selecting the correct DTB. That being
said, it may be solvable using the new CONFIG_DTB_RESELEC option. I'll look at it before
sending a new version.

JJ

Quoted 27 lines
Quoted 5 lines
Quoted 5 lines

I keep coming back to the problem that for SPL it seems like we should be able to do what Franklin did for keystone
(https://patchwork.ozlabs.org/patch/777242/) and have a 'fake' dts file that represents the SoC such that any real boards can get U-Boot loaded

This is right. We should be using the same for SPL as well and eventually remove non-DM code.

Thanks and regards,
Lokesh

Quoted 16 lines
Quoted 2 lines

and from there have the real board dtb be used. Or am I forgetting something? Thanks!

That's more or less the situation now with DRA7. This idea comes from the need to accelerate the fastboot path by using the HS200 mode of the eMMC. There we need to configure the lines of the eMMC and this information is typically found in the DTB and differs from SOC to SOC. At the moment in the ti tree this is done by duplicating this information in C structures protected with #ifdef CONFIG_SPL_BUILD. While this works, it would be nicer to get it from the dtb as done in u-boot.

Jean-Jacques
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot