From: "Daniel Kochmański" <jackdaniel@hellsgate.pl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] nand: sunxi: Add secondary U-Boot offset on second syndrome partition
Date: Tue, 05 May 2015 16:34:59 +0200 [thread overview]
Message-ID: <87vbg7t7n0.fsf@hellsgate.pl> (raw)
In-Reply-To: <CAJ+vNU03j6qzQM85-2Mp1CO4igZODtVHAJ85U0AzBQuk591CKw@mail.gmail.com>
Hi,
Tim Harvey writes:
> On Wed, Apr 29, 2015 at 8:02 AM, Daniel Kochma?ski
> <dkochmanski@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@turtle-solutions.eu>
>> Cc: Ian Campbell <ijc@hellion.org.uk>
>> Cc: Hans De Goede <hdegoede@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@corscience.de>
>> *
>> + * Copyright (C) 2015
>> + * Turtle Solutions - Daniel Kochma?ski <dkochmanski@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?
In case of sunxi boards so-called BROM when it reads bootloader from
NAND it tries to load it from first block of NAND, and if
header/checksum doesn't match, then it tries to read it from second one.
>
> 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.
SPL can't detect, from which offset it was loaded, therefore even if
image is correct and is placed on second block, it needs to check, if
something it reads is actual U-Boot. If not, then it is placed at second
one, and it should read U-Boot from second offset.
>
> Tim
--
Daniel Kochma?ski | Pozna?, Poland
;; aka jackdaniel
"Be the change that you wish to see in the world." - Mahatma Gandhi
next prev parent reply other threads:[~2015-05-05 14:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 15:02 [U-Boot] [PATCH 0/5] nand: sunxi: Add SPL support for booting from NAND Daniel Kochmański
2015-04-29 15:02 ` [U-Boot] [PATCH 1/5] nand: sunxi: change BLOCK_SIZE in mksunxiboot to match NAND block size Daniel Kochmański
2015-05-02 14:08 ` Ian Campbell
2015-05-05 9:02 ` Daniel Kochmański
2015-05-09 13:51 ` Ian Campbell
2015-04-29 15:02 ` [U-Boot] [PATCH 2/5] nand: sunxi: Add support for booting from internal NAND memory Daniel Kochmański
2015-05-02 14:21 ` Ian Campbell
2015-05-05 9:14 ` Daniel Kochmański
2015-05-05 9:19 ` Daniel Kochmański
2015-05-09 13:53 ` Ian Campbell
2015-05-09 14:33 ` Hans de Goede
2015-05-18 23:47 ` Scott Wood
2015-04-29 15:02 ` [U-Boot] [PATCH 3/5] nand: sunxi: Add secondary U-Boot offset on second syndrome partition Daniel Kochmański
2015-05-02 14:24 ` Ian Campbell
2015-05-05 14:21 ` Tim Harvey
2015-05-05 14:34 ` Daniel Kochmański [this message]
2015-05-18 23:10 ` Scott Wood
2015-04-29 15:03 ` [U-Boot] [PATCH 4/5] nand: sunxi: Add multiimage preload option Daniel Kochmański
2015-05-02 14:24 ` Ian Campbell
2015-05-18 23:43 ` Scott Wood
2015-04-29 15:03 ` [U-Boot] [PATCH 5/5] nand: sunxi: And a20_nandread command utilizing spl nand read driver Daniel Kochmański
2015-05-02 14:26 ` Ian Campbell
2015-05-04 14:20 ` Hans de Goede
2015-05-05 9:17 ` Daniel Kochmański
2015-05-05 9:45 ` Hans de Goede
2015-05-18 23:52 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbg7t7n0.fsf@hellsgate.pl \
--to=jackdaniel@hellsgate.pl \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox