summaryrefslogtreecommitdiffstats
path: root/lib/libscan.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-05-17 12:47:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-20 07:58:07 +0200
commit3dca2b0bf7936eedce9c551253c70921f0485991 (patch)
treee21b439ec62a9db5b34e625c1d3ecb0e76d0987c /lib/libscan.c
parent821de09b1fb67267ded3da11b51bd9245a6e1ce3 (diff)
downloadbarebox-3dca2b0bf7936eedce9c551253c70921f0485991.tar.gz
barebox-3dca2b0bf7936eedce9c551253c70921f0485991.tar.xz
ubiformat: Fix formatting devices with unreadable areas
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@pengutronix.de>
Diffstat (limited to 'lib/libscan.c')
-rw-r--r--lib/libscan.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libscan.c b/lib/libscan.c
index 13bd625a4c..74a24b5011 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))) {