[PATCH mtd-utils 6/7] misc-utils: flashcp: verify data in --partition

Brandon Maier brandon.maier at collins.com
Wed Nov 2 15:47:56 PDT 2022


The --partition mode is not verifying that data is being written
successfully.

Signed-off-by: Brandon Maier <brandon.maier at collins.com>
---
 misc-utils/flashcp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c
index 02be081..13ff2f1 100644
--- a/misc-utils/flashcp.c
+++ b/misc-utils/flashcp.c
@@ -465,6 +465,15 @@ DIFF_BLOCKS:
 			/* write to device */
 			safe_lseek(dev_fd, current_dev_block, SEEK_SET, device);
 			safe_write(dev_fd,src,i,written,(unsigned long long)filestat.st_size,device);
+
+			/* read from device */
+			safe_lseek(dev_fd, current_dev_block, SEEK_SET, device);
+			safe_read (dev_fd,device,dest,i);
+
+			/* compare buffers for write success */
+			if (memcmp (src,dest,i))
+				log_failure("File does not seem to match flash data. First mismatch at 0x%.8zx-0x%.8zx\n",
+						written,written + i);
 		}
 
 		erase.start += i;
-- 
2.38.1




More information about the linux-mtd mailing list