blob: 3703fea525fe3a476a36dfb0ae01873d4d9d0edc [file] [log] [blame]
diff -aruN a/nanddump.c b/nanddump.c
--- a/nanddump.c 2011-11-02 21:48:36.159532935 -0700
+++ b/nanddump.c 2011-11-04 12:20:36.000000000 -0700
@@ -54,6 +54,7 @@
"-p --prettyprint Print nice (hexdump)\n"
"-q --quiet Don't display progress and status messages\n"
"-s addr --startaddress=addr Start address\n"
+"-e --omitempty Omit empty pages\n"
);
exit(EXIT_SUCCESS);
}
@@ -83,6 +84,7 @@
static const char *dumpfile; // dump file name
static bool omitbad = false;
static bool quiet = false; // suppress diagnostic output
+static bool omitempty = false; // don't output empty pages
static void process_options (int argc, char * const argv[])
{
@@ -90,7 +92,7 @@
for (;;) {
int option_index = 0;
- static const char *short_options = "bs:f:il:opqn";
+ static const char *short_options = "bs:f:il:opqne";
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
@@ -103,6 +105,7 @@
{"length", required_argument, 0, 'l'},
{"noecc", no_argument, 0, 'n'},
{"quiet", no_argument, 0, 'q'},
+ {"omitempty", no_argument, 0, 'e'},
{0, 0, 0, 0},
};
@@ -153,6 +156,9 @@
case 'n':
noecc = true;
break;
+ case 'e':
+ omitempty = true;
+ break;
case '?':
error++;
break;
@@ -192,6 +198,7 @@
struct nand_oobinfo old_oobinfo;
struct mtd_ecc_stats stat1, stat2;
bool eccstats = false;
+ bool isempty;
process_options(argc, argv);
@@ -329,6 +336,23 @@
stat1 = stat2;
}
+ if (omitempty) {
+ isempty = true;
+ for (i = 0; i < bs; i++) {
+ if (readbuf[i] != 0xff) {
+ isempty = false;
+ break;
+ }
+ }
+
+ if (isempty) {
+ if (!quiet)
+ fprintf(stderr, "Skipping empty page at offset 0x%08lx\n", ofs);
+
+ continue;
+ }
+ }
+
/* Write out page data */
if (pretty_print) {
for (i = 0; i < bs; i += 16) {
diff -aruN a/nandwrite.c b/nandwrite.c
--- a/nandwrite.c 2011-11-02 21:48:36.159532935 -0700
+++ b/nandwrite.c 2011-11-03 15:54:26.949570997 -0700
@@ -486,6 +486,9 @@
if (baderaseblock) {
mtdoffset = blockstart + meminfo.erasesize;
+ if (mtdoffset >= meminfo.size) {
+ goto closeall;
+ }
}
offs += meminfo.erasesize / blockalign ;
} while ( offs < blockstart + meminfo.erasesize );