[U-Boot] [PATCH 3/5] nand: sunxi: Add secondary U-Boot offset on second syndrome partition

Tim Harvey tharvey at gateworks.com
Tue May 5 16:21:58 CEST 2015


On Wed, Apr 29, 2015 at 8:02 AM, Daniel Kochmański
<dkochmanski at turtle-solutions.eu> wrote:
> 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 <dkochmanski at turtle-solutions.eu>
> Cc: Ian Campbell <ijc at hellion.org.uk>
> Cc: Hans De Goede <hdegoede at 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 <schwarz at corscience.de>
>   *
> + * Copyright (C) 2015
> + * Turtle Solutions - Daniel Kochmański <dkochmanski at 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

Daniel,

Under what circumstances would header->ih_os not be IH_OS_U_BOOT? It
seems to me only if CONFIG_SYS_NAND_U_BOOT_OFFS pointed to the wrong
place but wouldn't this be a board configuration error?

Are you trying to put some redundancy in for detecting a corrupted
image? It seems to me that you would want to do more than check the
header type in that case.

Tim


More information about the U-Boot mailing list