diff mbox series

ffspart: Support flashing already ECC protected images

Message ID 20181210052528.4803-1-stewart@linux.ibm.com
State Superseded
Headers show
Series ffspart: Support flashing already ECC protected images | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master

Commit Message

Stewart Smith Dec. 10, 2018, 5:25 a.m. UTC
We do this by assuming filenames with '.ecc' in them are already ECC
protected.

This solves a practical problem in transitioning op-build to use ffspart
for pnor assembly rather than three perl scripts and a lot of XML.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 external/ffspart/ffspart.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c
index eeee0d4d657b..bb46a9eaf311 100644
--- a/external/ffspart/ffspart.c
+++ b/external/ffspart/ffspart.c
@@ -31,6 +31,7 @@ 
 #include <libflash/libflash.h>
 #include <libflash/libffs.h>
 #include <libflash/blocklevel.h>
+#include <libflash/ecc.h>
 #include <common/arch_flash.h>
 
 /*
@@ -250,6 +251,14 @@  static int parse_entry(struct blocklevel_device *bl,
 
 	if (*line != '\0' && *(line + 1) != '\0') {
 		filename = line + 1;
+
+		/*
+		 * Support flashing already ecc'd data as this is the case
+		 * for POWER8 SBE image binary.
+		 */
+		if (has_ecc(new_entry) && !strstr(filename, ".ecc"))
+			blocklevel_ecc_protect(bl, pbase, psize);
+
 		data_fd = open(filename, O_RDONLY);
 		if (data_fd == -1) {
 			fprintf(stderr, "Couldn't open file '%s' for '%s' partition "
@@ -269,9 +278,12 @@  static int parse_entry(struct blocklevel_device *bl,
 		 * Sanity check that the file isn't too large for
 		 * partition
 		 */
+		if (has_ecc(new_entry) && !strstr(filename, ".ecc"))
+			psize = ecc_buffer_size_minus_ecc(psize);
 		if (pactual > psize) {
-			fprintf(stderr, "File '%s' for partition '%s' is too large\n",
-					filename, name);
+			fprintf(stderr, "File '%s' for partition '%s' is too large,"
+				" %u > %u\n",
+				filename, name, pactual, psize);
 			close(data_fd);
 			return -1;
 		}