]> git.sur5r.net Git - u-boot/commitdiff
spl: nand: support redundant u-boot image
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 6 Jun 2016 08:16:58 +0000 (10:16 +0200)
committerScott Wood <oss@buserror.net>
Mon, 20 Jun 2016 00:11:57 +0000 (19:11 -0500)
On modern NAND it's more than recommended to have a backup copy of the
u-boot binary to recover from corruption: bitflips are quite common on
MLC NANDs, and the read-disturbance will corrupt your u-boot partitition
more quickly than what you would see on an SLC NAND.

Add an extra Kconfig option to specify the offset of the redundant u-boot
image.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
[scottwood: added ifdef to fix build break]
Signed-off-by: Scott Wood <oss@buserror.net>
common/spl/spl_nand.c
drivers/mtd/nand/Kconfig

index 7cf0d1b986000b3851cd06e57b349633f9a4bea1..0e35e0fd6b1901ceec13740d5571e68035738640 100644 (file)
@@ -134,6 +134,13 @@ int spl_nand_load_image(void)
 #endif
        /* Load u-boot */
        err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
+#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
+#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
+       if (err)
+               err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
+                                           header);
+#endif
+#endif
        nand_deselect();
        return err;
 }
index 5fe169f6ce1ebecc4b7ca5ca5a2aa6771fbfb523..8c46a2ff8e1a3f9a85a06ae06aaed680d8fa8c42 100644 (file)
@@ -117,6 +117,14 @@ config SYS_NAND_U_BOOT_OFFS
        Set the offset from the start of the nand where u-boot should be
        loaded from.
 
+config SYS_NAND_U_BOOT_OFFS_REDUND
+       hex "Location in NAND to read U-Boot from"
+       default SYS_NAND_U_BOOT_OFFS
+       depends on SYS_NAND_U_BOOT_LOCATIONS
+       help
+       Set the offset from the start of the nand where the redundant u-boot
+       should be loaded from.
+
 config SPL_NAND_DENALI
        bool "Support Denali NAND controller for SPL"
        help