Patch adds support in spl_nand for preloading multiimage before
loading u-boot into memory. It might be used in example to put in
memory single image containing boot script, kernel and device
tree.

Behavior is triggered, if CONFIG_SPL_NAND_MULTI_PRELOAD is defined -
multiimage is loaded from CONFIG_SYS_NAND_MULTI_OFFS to address
specified on image creation.

Additionally defines it in sunxi-common.h conditionally when
CONFIG_SPL_NAND_SUPPORT is enabled. SPL tries to preload image from
beginning of non-syndrome area.

Signed-off-by: Daniel Kochmański <dkochman...@turtle-solutions.eu>
Cc: Ian Campbell <i...@hellion.org.uk>
Cc: Hans De Goede <hdego...@redhat.com>
---

 README                         |  6 ++++++
 common/spl/spl_nand.c          | 14 ++++++++++++++
 include/configs/sunxi-common.h |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/README b/README
index 4ccf3cb..444b02f 100644
--- a/README
+++ b/README
@@ -3719,6 +3719,9 @@ FIT uImage format:
                CONFIG_SPL_NAND_BOOT
                Add support NAND boot
 
+               CONFIG_SPL_NAND_MULTI_PRELOAD
+               Preload multiimage from predefined offset in NAND.
+
                CONFIG_SYS_NAND_U_BOOT_OFFS
                Location in NAND to read U-Boot from
 
@@ -3735,6 +3738,9 @@ FIT uImage format:
                CONFIG_SYS_NAND_U_BOOT_START
                Entry point in loaded image to jump to
 
+               CONFIG_SYS_NAND_MULTI_OFFS
+               Location in NAND to read multiimage from.
+
                CONFIG_SYS_NAND_HW_ECC_OOBFIRST
                Define this if you need to first read the OOB and then the
                data. This is used, for example, on davinci platforms.
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 7c44de1..f87db0a 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -89,6 +89,20 @@ void spl_nand_load_image(void)
                            (void *)spl_image.load_addr);
 #endif
 #endif
+#ifdef CONFIG_SPL_NAND_MULTI_PRELOAD
+       /* Load multiimage */
+       puts("Preloading multiimage.\n");
+       nand_spl_load_image(CONFIG_SYS_NAND_MULTI_OFFS,
+                           sizeof(*header), (void *)header);
+       spl_parse_image_header(header);
+       if (header->ih_type == IH_TYPE_MULTI) {
+               nand_spl_load_image(CONFIG_SYS_NAND_MULTI_OFFS,
+                                   spl_image.size,
+                                   (void *)(unsigned long)spl_image.load_addr);
+       } else {
+               puts("Multiimage header didn't match.\n");
+       }
+#endif /* CONFIG_SPL_NAND_MULTI_PRELOAD */
        /* Load u-boot */
        nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
                            sizeof(*header), (void *)header);
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 15fe512..0b4ea7e 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -328,9 +328,11 @@ extern int soft_i2c_gpio_scl;
 #ifdef CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_NAND
 #define CONFIG_NAND_SUNXI
+#define CONFIG_SPL_NAND_MULTI_PRELOAD
 #define CONFIG_CMD_SPL_WRITE_SIZE              0x000400
 #define CONFIG_SYS_NAND_U_BOOT_OFFS            0x008000
 #define CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS     0x208000
+#define CONFIG_SYS_NAND_MULTI_OFFS             0x400000
 #endif /* CONFIG_SPL_NAND_SUPPORT */
 
 #define CONFIG_MISC_INIT_R
-- 
2.3.6

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to