diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-03-26 10:50:09 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-03-26 10:50:09 +0000 |
commit | d7a9700570eb6d3e55777cda1ae1503000692bb9 (patch) | |
tree | 8b5e673dcb2d98876d031a93934705a34c3336b6 /package/system/mtd/src/jffs2.c | |
parent | 58ca40c218871497e81d4cffacea10bef2c265bf (diff) | |
download | master-187ad058-d7a9700570eb6d3e55777cda1ae1503000692bb9.tar.gz master-187ad058-d7a9700570eb6d3e55777cda1ae1503000692bb9.tar.bz2 master-187ad058-d7a9700570eb6d3e55777cda1ae1503000692bb9.zip |
mtd: add support for bad blocks in NAND flash
NAND flash is very likely to contain bad blocks.
Currently, mtd and therefore sysupgrade fails when it encounters a single bad block, potentially leaving an unbootable system.
This patch allows the mtd utility to skip bad blocks in NAND flash and complete sysupgrade successfully.
Patch by: Matthew Redfearn <matt.redfearn@nxp.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@40021 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/system/mtd/src/jffs2.c')
-rw-r--r-- | package/system/mtd/src/jffs2.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/package/system/mtd/src/jffs2.c b/package/system/mtd/src/jffs2.c index 2a83bd47f4..c29fb33e5c 100644 --- a/package/system/mtd/src/jffs2.c +++ b/package/system/mtd/src/jffs2.c @@ -59,6 +59,15 @@ static void pad(int size) } ofs = ofs % erasesize; if (ofs == 0) { + while (mtd_block_is_bad(outfd, mtdofs) && (mtdofs < mtdsize)) { + if (!quiet) + fprintf(stderr, "\nSkipping bad block at 0x%08x ", mtdofs); + + mtdofs += erasesize; + + /* Move the file pointer along over the bad block. */ + lseek(outfd, erasesize, SEEK_CUR); + } mtd_erase_block(outfd, mtdofs); write(outfd, buf, erasesize); mtdofs += erasesize; |