summaryrefslogtreecommitdiff
path: root/nanddump.c
diff options
context:
space:
mode:
Diffstat (limited to 'nanddump.c')
-rw-r--r--nanddump.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/nanddump.c b/nanddump.c
index ab39c04..f1b58a9 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -91,6 +91,7 @@ void process_options (int argc, char *argv[])
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
+ {"file", required_argument, 0, 'f'},
{"ignoreerrors", no_argument, 0, 'i'},
{"prettyprint", no_argument, 0, 'p'},
{"omitoob", no_argument, 0, 'o'},
@@ -170,7 +171,7 @@ int main(int argc, char **argv)
{
unsigned long ofs, end_addr = 0;
unsigned long long blockstart = 1;
- int i, fd, ofd, bs, badblock = 0;
+ int ret, i, fd, ofd, bs, badblock = 0;
struct mtd_oob_buf oob = {0, 16, oobbuf};
mtd_info_t meminfo;
char pretty_buf[80];
@@ -196,6 +197,7 @@ int main(int argc, char **argv)
/* Make sure device page sizes are valid */
if (!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
+ !(meminfo.oobsize == 32 && meminfo.writesize == 1024) &&
!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
!(meminfo.oobsize == 8 && meminfo.writesize == 256)) {
fprintf(stderr, "Unknown flash (not normal NAND)\n");
@@ -206,9 +208,12 @@ int main(int argc, char **argv)
oob.length = meminfo.oobsize;
if (noecc) {
- switch (ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW)) {
-
- case -ENOTTY:
+ ret = ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW);
+ if (ret == 0) {
+ oobinfochanged = 2;
+ } else {
+ switch (errno) {
+ case ENOTTY:
if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
perror ("MEMGETOOBSEL");
close (fd);
@@ -221,14 +226,11 @@ int main(int argc, char **argv)
}
oobinfochanged = 1;
break;
-
- case 0:
- oobinfochanged = 2;
- break;
default:
perror ("MTDFILEMODE");
close (fd);
exit (1);
+ }
}
} else {