Received: from elasmtp-junco.atl.sa.earthlink.net ([209.86.89.63]) by pentafluge.infradead.org with esmtp (Exim 4.62 #1 (Red Hat Linux)) id 1FeJkQ-0002ea-BV for linux-mtd@lists.infradead.org; Thu, 11 May 2006 23:35:07 +0100 Received: from [209.86.224.34] (helo=elwamui-hound.atl.sa.earthlink.net) by elasmtp-junco.atl.sa.earthlink.net with asmtp (Exim 4.34) id 1FeJkF-0001d7-91 for linux-mtd@lists.infradead.org; Thu, 11 May 2006 18:34:55 -0400 Message-ID: <1641800.1147386895133.JavaMail.root@elwamui-hound.atl.sa.earthlink.net> Date: Thu, 11 May 2006 15:34:54 -0700 (GMT-07:00) From: Steve Finney To: linux-mtd@lists.infradead.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_13303_3306445.1147386894872" Subject: [PATCH 3/3] MTD Utils. (Resubmit as attachment) Reply-To: Steve Finney List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , ------=_Part_13303_3306445.1147386894872 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Modify nanddump to take a '-n' argument for reading without error correction; also accept hex (and octal) for start and length. Signed-off-by: Steven Finney (sfinney@healthhero.com) ------=_Part_13303_3306445.1147386894872 Content-Disposition: attachment; filename="patch.nanddump" Content-Type: application/octet-stream; name=patch.nanddump Content-Transfer-Encoding: 7bit Modify nanddump to take a '-n' argument for reading without error correction; also accept hex (and octal) for start and length. Signed-off-by: Steven Finney (sfinney@healthhero.com) ------------------------------------- --- util.orig/nanddump.c 2006-05-02 07:52:41.000000000 -0700 +++ util/nanddump.c 2006-05-10 11:51:46.000000000 -0700 @@ -33,6 +33,10 @@ #define PROGRAM "nanddump" #define VERSION "$Revision: 1.29 $" +struct nand_oobinfo none_oobinfo = { + .useecc = MTD_NANDECC_OFF, +}; + void display_help (void) { printf("Usage: nanddump [OPTIONS] MTD-device\n" @@ -43,6 +47,7 @@ void display_help (void) "-f file --file=file dump to file\n" "-i --ignoreerrors ignore errors\n" "-l length --length=length length\n" + "-n --noecc read without error correction\n" "-o --omitoob omit oob data\n" "-b --omitbad omit bad blocks from the dump\n" "-p --prettyprint print nice (hexdump)\n" @@ -67,6 +72,7 @@ void display_version (void) int ignoreerrors; // ignore errors int pretty_print; // print nice in ascii +int noecc; // don't error correct int omitoob; // omit oob data unsigned long start_addr; // start address unsigned long length; // dump length @@ -80,7 +86,7 @@ void process_options (int argc, char *ar for (;;) { int option_index = 0; - static const char *short_options = "bs:f:il:op"; + static const char *short_options = "bs:f:il:opn"; static const struct option long_options[] = { {"help", no_argument, 0, 0}, {"version", no_argument, 0, 0}, @@ -90,6 +96,7 @@ void process_options (int argc, char *ar {"omitbad", no_argument, 0, 'b'}, {"startaddress", required_argument, 0, 's'}, {"length", required_argument, 0, 'l'}, + {"noecc", no_argument, 0, 'n'}, {0, 0, 0, 0}, }; @@ -114,7 +121,7 @@ void process_options (int argc, char *ar omitbad = 1; break; case 's': - start_addr = atol(optarg); + start_addr = strtol(optarg, NULL, 0); break; case 'f': if (!(dumpfile = strdup(optarg))) { @@ -126,7 +133,7 @@ void process_options (int argc, char *ar ignoreerrors = 1; break; case 'l': - length = atol(optarg); + length = strtol(optarg, NULL, 0); break; case 'o': omitoob = 1; @@ -134,6 +141,9 @@ void process_options (int argc, char *ar case 'p': pretty_print = 1; break; + case 'n': + noecc = 1; + break; case '?': error = 1; break; @@ -163,6 +173,8 @@ int main(int argc, char **argv) struct mtd_oob_buf oob = {0, 16, oobbuf}; mtd_info_t meminfo; char pretty_buf[80]; + int oobinfochanged = 0 ; + struct nand_oobinfo old_oobinfo ; process_options(argc, argv); @@ -190,6 +202,21 @@ int main(int argc, char **argv) /* Read the real oob length */ oob.length = meminfo.oobsize; + if (noecc) { + if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) { + perror ("MEMGETOOBSEL"); + close (fd); + exit (1); + } + if (ioctl (fd, MEMSETOOBSEL, &none_oobinfo) != 0) { + perror ("MEMSETOOBSEL"); + close (fd); + exit (1); + } + oobinfochanged = 1 ; + } + + /* Open output file for writing. If file name is "-", write to standard output. */ if (!dumpfile) { ofd = STDOUT_FILENO; @@ -297,6 +324,15 @@ int main(int argc, char **argv) write(ofd, oobbuf, meminfo.oobsize); } + /* reset oobinfo */ + if (oobinfochanged) { + if (ioctl (fd, MEMSETOOBSEL, &old_oobinfo) != 0) { + perror ("MEMSETOOBSEL"); + close(fd); + close(ofd); + return 1; + } + } /* Close the output file and MTD device */ close(fd); close(ofd); @@ -305,6 +341,11 @@ int main(int argc, char **argv) return 0; closeall: + if (oobinfochanged) { + if (ioctl (fd, MEMSETOOBSEL, &old_oobinfo) != 0) { + perror ("MEMSETOOBSEL"); + } + } close(fd); close(ofd); exit(1); ------=_Part_13303_3306445.1147386894872--