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> SVN-Revision: 40021
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user