--- ./nandtest.c.bad 2011-08-19 15:34:03 +0200 +++ ./nandtest.c 2012-02-19 11:08:43 +0100 @@ -22,6 +22,7 @@ fprintf(stderr, "usage: %s [OPTIONS] \n\n" " -h, --help Display this help output\n" " -m, --markbad Mark blocks bad if they appear so\n" + " -M, --markeccbad Mark ECC corrected/failed blocks bad\n" " -s, --seed Supply random seed\n" " -p, --passes Number of passes\n" " -o, --offset Start offset on flash\n" @@ -35,6 +36,7 @@ struct mtd_ecc_stats oldstats, newstats; int fd; int markbad=0; +int markeccbad=0; int seed; int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf) @@ -100,10 +102,18 @@ if (newstats.corrected > oldstats.corrected) { printf("\nECC corrected at %08x\n", (unsigned) ofs); oldstats.corrected = newstats.corrected; + if (markeccbad) { + printf("Mark block bad at %08lx\n", (long)ofs); + ioctl(fd, MEMSETBADBLOCK, &ofs); + } } if (newstats.failed > oldstats.failed) { printf("\nECC failed at %08x\n", (unsigned) ofs); oldstats.corrected = newstats.corrected; + if (markeccbad) { + printf("Mark block bad at %08lx\n", (long)ofs); + ioctl(fd, MEMSETBADBLOCK, &ofs); + } } if (len < meminfo.erasesize) exit(1); @@ -139,10 +149,11 @@ uint32_t length = -1; for (;;) { - static const char *short_options="hkl:mo:p:s:"; + static const char *short_options="hkl:mMo:p:s:"; static const struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "markbad", no_argument, 0, 'm' }, + { "markeccbad", no_argument, 0, 'M' }, { "seed", required_argument, 0, 's' }, { "passes", required_argument, 0, 'p' }, { "offset", required_argument, 0, 'o' }, @@ -165,6 +176,10 @@ markbad = 1; break; + case 'M': + markeccbad = 1; + break; + case 'k': keep_contents = 1; break;