[U-Boot] [PATCH v1 04/10] spl, nand: add option to boot raw u-boot.bin image only

Heiko Schocher hs at denx.de
Wed Oct 1 07:54:48 CEST 2014


enable to boot only a raw u-boot.bin image from nand with the
CONFIG_SPL_NAND_RAW_ONLY define. This option saves space on
boards where spl space is low.

Signed-off-by: Heiko Schocher <hs at denx.de>
Cc: Andreas Bießmann <andreas.devel at googlemail.com>
Cc: Bo Shen <voice.shen at atmel.com>
Cc: Scott Wood <scottwood at freescale.com>
Cc: Josh Wu <josh.wu at atmel.com>

---

on the siemens taurus board, this option saved 0x14d bytes
---
 README                |  4 ++++
 common/spl/spl.c      | 15 ++++++++++-----
 common/spl/spl_nand.c | 13 +++++++++++++
 include/spl.h         |  1 +
 4 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/README b/README
index 46def00..d5736b3 100644
--- a/README
+++ b/README
@@ -3596,6 +3596,10 @@ FIT uImage format:
 		Support for the MTD subsystem within SPL.  Useful for
 		environment on NAND support within SPL.
 
+		CONFIG_SPL_NAND_RAW_ONLY
+		Support to boot only raw u-boot.bin images. Use this only
+		if you need to save space.
+
 		CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
 		Set for the SPL on PPC mpc8xxx targets, support for
 		drivers/ddr/fsl/libddr.o in SPL binary.
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b16664f..97dc0f0 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -61,6 +61,15 @@ __weak void spl_board_prepare_for_linux(void)
 	/* Nothing to do! */
 }
 
+void spl_set_header_raw_uboot(void)
+{
+	spl_image.size = CONFIG_SYS_MONITOR_LEN;
+	spl_image.entry_point = CONFIG_SYS_UBOOT_START;
+	spl_image.load_addr = CONFIG_SYS_TEXT_BASE;
+	spl_image.os = IH_OS_U_BOOT;
+	spl_image.name = "U-Boot";
+}
+
 void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);
@@ -93,11 +102,7 @@ void spl_parse_image_header(const struct image_header *header)
 		debug("mkimage signature not found - ih_magic = %x\n",
 			header->ih_magic);
 		/* Let's assume U-Boot will not be more than 200 KB */
-		spl_image.size = CONFIG_SYS_MONITOR_LEN;
-		spl_image.entry_point = CONFIG_SYS_UBOOT_START;
-		spl_image.load_addr = CONFIG_SYS_TEXT_BASE;
-		spl_image.os = IH_OS_U_BOOT;
-		spl_image.name = "U-Boot";
+		spl_set_header_raw_uboot();
 	}
 }
 
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 9b200bc..b7801cb 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -10,6 +10,18 @@
 #include <asm/io.h>
 #include <nand.h>
 
+#if defined(CONFIG_SPL_NAND_RAW_ONLY)
+void spl_nand_load_image(void)
+{
+	nand_init();
+
+	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+			    CONFIG_SYS_NAND_U_BOOT_SIZE,
+			    (void *)CONFIG_SYS_NAND_U_BOOT_DST);
+	spl_set_header_raw_uboot();
+	nand_deselect();
+}
+#else
 void spl_nand_load_image(void)
 {
 	struct image_header *header;
@@ -82,3 +94,4 @@ void spl_nand_load_image(void)
 		spl_image.size, (void *)spl_image.load_addr);
 	nand_deselect();
 }
+#endif
diff --git a/include/spl.h b/include/spl.h
index a7e41da..6d2040d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -35,6 +35,7 @@ extern struct spl_image_info spl_image;
 void preloader_console_init(void);
 u32 spl_boot_device(void);
 u32 spl_boot_mode(void);
+void spl_set_header_raw_uboot(void);
 void spl_parse_image_header(const struct image_header *header);
 void spl_board_prepare_for_linux(void);
 void __noreturn jump_to_image_linux(void *arg);
-- 
1.8.3.1



More information about the U-Boot mailing list