From: Michael Trimarchi <michael@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 1/2] spl: Fix redundant image of uboot
Date: Fri, 6 Jul 2018 08:08:46 +0200 [thread overview]
Message-ID: <20180706060844.GA17021@panicking> (raw)
In-Reply-To: <20180704171041.4f0886b1@ipc1.ka-ro>
We need to address the redundat image case and undestand if the
image is corrupted or not. In error case we need to try the fallback copy.
The function used before was always return 0 without any evaluation of the
error. We try to make it work properly
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
Changes V1->V2:
Address the comments on using the err variable
---
common/spl/spl_nand.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 9a52500..109dd6e 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -44,9 +44,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
{
int err;
- err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
- if (err)
- return err;
+ nand_spl_load_image(offset, sizeof(*header), (void *)header);
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
@@ -59,13 +57,31 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
load.bl_len = 1;
load.read = spl_nand_fit_read;
return spl_load_simple_fit(spl_image, &load, offset, header);
- } else {
- err = spl_parse_image_header(spl_image, header);
- if (err)
- return err;
- return nand_spl_load_image(offset, spl_image->size,
- (void *)(ulong)spl_image->load_addr);
}
+ err = spl_parse_image_header(spl_image, header);
+ if (err)
+ return err;
+
+ nand_spl_load_image(offset, spl_image->size,
+ (void *)(ulong)spl_image->load_addr);
+
+ /*
+ * Verify the crc of the header
+ */
+ if (!((const image_header_t *)spl_image->load_addr)) {
+ debug("Header checksum failed\n");
+ return -EINVAL;
+ }
+
+ /*
+ * Verify the crc of the data
+ */
+ if (!image_check_dcrc((const image_header_t *)spl_image->load_addr)) {
+ debug("Image checksum failed\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
static int spl_nand_load_image(struct spl_image_info *spl_image,
--
2.7.4
--
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO - Founder Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
| [`as] http://www.amarulasolutions.com |
next prev parent reply other threads:[~2018-07-06 6:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 13:53 [U-Boot] [PATCH 1/2] spl: Fix redundant image of uboot Michael Trimarchi
2018-07-04 13:53 ` [U-Boot] [PATCH 2/2] spl: Make the spl_nand_load_image static Michael Trimarchi
2018-07-20 22:34 ` [U-Boot] [U-Boot,2/2] " Tom Rini
2018-07-04 14:19 ` [U-Boot] [PATCH 1/2] spl: Fix redundant image of uboot Lothar Waßmann
2018-07-04 14:27 ` Michael Nazzareno Trimarchi
2018-07-04 15:10 ` Lothar Waßmann
2018-07-04 15:12 ` Michael Nazzareno Trimarchi
2018-07-06 6:08 ` Michael Trimarchi [this message]
2018-07-06 15:09 ` [U-Boot] [PATCH V3 " Michael Trimarchi
2018-07-11 11:37 ` Michael Nazzareno Trimarchi
2018-07-11 12:16 ` Lothar Waßmann
2018-07-20 19:54 ` [U-Boot] [U-Boot,V3,1/2] " Tom Rini
2018-07-20 20:09 ` Michael Nazzareno Trimarchi
2018-07-20 20:11 ` Tom Rini
2018-07-20 20:27 ` Michael Nazzareno Trimarchi
2018-07-20 20:56 ` Tom Rini
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=20180706060844.GA17021@panicking \
--to=michael@amarulasolutions.com \
--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