Introduces CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS, pointing to backup U-Boot instance in nand memory. In case if first header doesn't match, tries to load bootloader from this offset. In case of both failing, hang() is called.
Additionally define offset of backup U-boot for sunxi at start of second syndrome partition. 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 | 4 ++++ common/spl/spl_nand.c | 28 +++++++++++++++++++++++++--- include/configs/sunxi-common.h | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README b/README index ee65fdb..4ccf3cb 100644 --- a/README +++ b/README @@ -3722,6 +3722,10 @@ FIT uImage format: CONFIG_SYS_NAND_U_BOOT_OFFS Location in NAND to read U-Boot from + CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS + Location in NAND to read backup U-Boot from, if first + location doesn't contain valid image. + CONFIG_SYS_NAND_U_BOOT_DST Location in memory to load U-Boot to diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index 9d59fbb..7c44de1 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -2,6 +2,9 @@ * Copyright (C) 2011 * Corscience GmbH & Co. KG - Simon Schwarz <schw...@corscience.de> * + * Copyright (C) 2015 + * Turtle Solutions - Daniel Kochmański <dkochman...@turtle-solutions.eu> + * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> @@ -90,9 +93,28 @@ void spl_nand_load_image(void) nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, sizeof(*header), (void *)header); spl_parse_image_header(header); - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - spl_image.size, - (void *)(unsigned long)spl_image.load_addr); + if (header->ih_os == IH_OS_U_BOOT) { + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + spl_image.size, + (void *)(unsigned long)spl_image.load_addr); + nand_deselect(); + return; + } + puts("U-boot header didn't match.\n"); +#ifdef CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS + puts("Trying to start backup u-boot now...\n"); + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS, + sizeof(*header), (void *)header); + spl_parse_image_header(header); + if (header->ih_os == IH_OS_U_BOOT) { + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS, + spl_image.size, + (void *)(unsigned long)spl_image.load_addr); + nand_deselect(); + return; + } +#endif + puts("No valid u-boot image found.\n"); nand_deselect(); } #endif diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index b40cdd3..15fe512 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -330,6 +330,7 @@ extern int soft_i2c_gpio_scl; #define CONFIG_NAND_SUNXI #define CONFIG_CMD_SPL_WRITE_SIZE 0x000400 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x008000 +#define CONFIG_SYS_NAND_U_BOOT_BACKUP_OFFS 0x208000 #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