[PATCH 2/2] ubiformat: Fix formatting devices with unreadable areas
Sascha Hauer
s.hauer at pengutronix.de
Thu May 19 22:58:12 PDT 2016
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 at pengutronix.de>
---
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
More information about the barebox
mailing list