[PATCH 2/2] ubiformat: Fix formatting devices with unreadable areas

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When parts of a Nand device are not readable due to excessive bit flips
we should not bail out with an error as this means we can never repair
the device by flashing a fresh image using ubiformat. Instead, treat a
failed read as a corrupt block and ignore the read failure.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 lib/libscan.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/libscan.c b/lib/libscan.c
index 13bd625..74a24b5 100644
--- a/lib/libscan.c
+++ b/lib/libscan.c
@@ -82,8 +82,13 @@ int libscan_ubi_scan(struct mtd_info *mtd, struct ubi_scan_info **info,
 		}
 
 		ret = mtd_peb_read(mtd, &ech, eb, 0, sizeof(struct ubi_ec_hdr));
-		if (ret < 0 && !mtd_is_bitflip(ret))
-			goto out_ec;
+		if (ret < 0 && !mtd_is_bitflip(ret)) {
+			si->corrupted_cnt += 1;
+			si->ec[eb] = EB_CORRUPTED;
+			if (v)
+				printf(": not readable\n");
+			continue;
+		}
 
 		if (be32_to_cpu(ech.magic) != UBI_EC_HDR_MAGIC) {
 			if (mtd_buf_all_ff(&ech, sizeof(struct ubi_ec_hdr))) {
-- 
2.8.0.rc3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux