[U-Boot] [PATCH] ML: SPL: NOR: Add CONFIG_SPL_NOR_COPY_ENTIRE_IMAGE define to enable whole image copy from NOR

Lukasz Majewski l.majewski at majess.pl
Fri Sep 16 10:43:51 CEST 2016


This define gives the possibility to copy entire image (including header)
from NOR parallel memory to e.g. SDRAM.

The legacy behavior is preserved, since other board don't enabled this option.

Signed-off-by: Lukasz Majewski <l.majewski at majess.pl>
---
 Kconfig              | 10 ++++++++++
 README               |  4 ++++
 common/spl/spl_nor.c | 12 +++++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/Kconfig b/Kconfig
index e443490..473a099 100644
--- a/Kconfig
+++ b/Kconfig
@@ -159,6 +159,16 @@ config SPL_NOR_SUPPORT
 	help
 	  This option enables SPL NOR driver.
 
+config SPL_NOR_COPY_ENTIRE_IMAGE
+	bool
+	depends on SPL_NOR_SUPPORT
+	prompt "Copy entire image from NOR memory"
+	default n
+	help
+	  By default the SPL NOR driver supports copying only payload to
+	  destination address. Say Y if you want to copy entire image (including
+	  its image header).
+
 config SPL_SYS_MALLOC_SIMPLE
 	bool
 	depends on SPL
diff --git a/README b/README
index f41a6af..e9a3c5b 100644
--- a/README
+++ b/README
@@ -3661,6 +3661,10 @@ FIT uImage format:
 		It conflicts with SPL env from storage medium specified by
 		CONFIG_ENV_IS_xxx but CONFIG_ENV_IS_NOWHERE
 
+		CONFIG_SPL_NOR_COPY_ENTIRE_IMAGE
+		Allow NOR stored u-boot image to be copied by SPL with header to
+		SDRAM memory and executed from it
+
 		CONFIG_SPL_PAD_TO
 		Image offset to which the SPL should be padded before appending
 		the SPL payload. By default, this is defined as
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 8ea874c..1e0f739 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -9,13 +9,15 @@
 
 int spl_nor_load_image(void)
 {
+	void *img_src;
 	int ret;
+#ifndef CONFIG_SPL_NOR_COPY_ENTIRE_IMAGE
 	/*
 	 * Loading of the payload to SDRAM is done with skipping of
 	 * the mkimage header in this SPL NOR driver
 	 */
 	spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
-
+#endif
 #ifdef CONFIG_SPL_OS_BOOT
 	if (!spl_start_uboot()) {
 		const struct image_header *header;
@@ -64,9 +66,13 @@ int spl_nor_load_image(void)
 	if (ret)
 		return ret;
 
+	img_src = (void *)CONFIG_SYS_UBOOT_BASE;
+#ifndef CONFIG_SPL_NOR_COPY_ENTIRE_IMAGE
+	img_src += sizeof(struct image_header));
+#endif
+
 	memcpy((void *)(unsigned long)spl_image.load_addr,
-	       (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
-	       spl_image.size);
+	       img_src, spl_image.size);
 
 	return 0;
 }
-- 
2.1.4



More information about the U-Boot mailing list