[U-Boot] [PATCH 06/13] dm: spl: Support device tree when BSS is in a different section

Simon Glass sjg at chromium.org
Sat Aug 29 17:10:15 CEST 2015


At present in SPL we place the device tree immediately after BSS. This
avoids needing to copy it out of the way before BSS can be used. However on
some boards BSS is not placed with the image - e.g. it can be in RAM if
available.

Add an option to tell U-Boot that the device tree should be placed at the
end of the image binary (_image_binary_end) instead of at the end of BSS.

Note: A common reason to place BSS in RAM is to support the FAT filesystem.
We should update the code so that it does not use so much BSS.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 Kconfig                        | 10 ++++++++++
 include/asm-generic/sections.h |  1 +
 lib/fdtdec.c                   |  7 +++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Kconfig b/Kconfig
index 05a34f7..819fa90 100644
--- a/Kconfig
+++ b/Kconfig
@@ -132,6 +132,16 @@ config SPL_STACK_R_ADDR
 	  Specify the address in SDRAM for the SPL stack. This will be set up
 	  before board_init_r() is called.
 
+config SPL_SEPARATE_BSS
+	depends on SPL
+	bool "BSS section is in a different memory region from text"
+	help
+	  Some platforms need a large BSS region in SPL and can provide this
+	  because RAM is already set up. In this case BSS can be moved to RAM.
+	  This option should then be enabled so that the correct device tree
+	  location is used. Normally we put the device tree at the end of BSS
+	  but with this option enabled, it goes at _image_binary_end.
+
 config TPL
 	bool
 	depends on SPL && SUPPORT_TPL
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 458952f..328bc62 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -71,6 +71,7 @@ extern char __bss_start[];
 extern char __bss_end[];
 extern char __image_copy_start[];
 extern char __image_copy_end[];
+extern char _image_binary_end[];
 extern char __rel_dyn_start[];
 extern char __rel_dyn_end[];
 
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 38888de..e8684a4 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1150,8 +1150,11 @@ int fdtdec_setup(void)
 	gd->fdt_blob = __dtb_dt_begin;
 # elif defined CONFIG_OF_SEPARATE
 #  ifdef CONFIG_SPL_BUILD
-	/* FDT is at end of BSS */
-	gd->fdt_blob = (ulong *)&__bss_end;
+	/* FDT is at end of BSS unless it is in a different memory region */
+	if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
+		gd->fdt_blob = (ulong *)&_image_binary_end;
+	else
+		gd->fdt_blob = (ulong *)&__bss_end;
 #  else
 	/* FDT is at end of image */
 	gd->fdt_blob = (ulong *)&_end;
-- 
2.5.0.457.gab17608



More information about the U-Boot mailing list