public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] spl: Fix redundant image of uboot
@ 2018-07-04 13:53 Michael Trimarchi
  2018-07-04 13:53 ` [U-Boot] [PATCH 2/2] spl: Make the spl_nand_load_image static Michael Trimarchi
  2018-07-04 14:19 ` [U-Boot] [PATCH 1/2] spl: Fix redundant image of uboot Lothar Waßmann
  0 siblings, 2 replies; 16+ messages in thread
From: Michael Trimarchi @ 2018-07-04 13:53 UTC (permalink / raw)
  To: u-boot

We need to address the redundat image case and undestand if the
image is corrupted or not and fallback to the copy. The function
used before was always return 0 without any evaluation of the
error. We try to make it work properly

Change-Id: Id6fc221c5cc08934b7324dd5d319b93c56e2e678
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 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..b96fce2 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);
+
+	/*
+	 * Logic of the error is inverted for image_check* functions.
+	 * We want to verify that header is correct and the data are correct
+	 * for LEGACY image type
+	 */
+	err = image_check_hcrc((const image_header_t *)spl_image->load_addr);
+	if (!err) {
+		debug("Header checksum failed\n");
+		return -EINVAL;
+	}
+	err = image_check_dcrc((const image_header_t *)spl_image->load_addr);
+	if (!err) {
+		debug("Image checksum failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
 }
 
 static int spl_nand_load_image(struct spl_image_info *spl_image,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-07-20 22:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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       ` [U-Boot] [PATCH V2 " Michael Trimarchi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox