From: Tim Gardner <timg@tpi.com>
To: linux-mtd@lists.infradead.org
Subject: Patches to nanddump.c
Date: Thu, 2 Oct 2003 13:44:14 -0600 [thread overview]
Message-ID: <200310021344.14931.timg@tpi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
I've added a couple of options to nanddump.c:
-no-oob allowa you to retrieve the contents of a NAND character partiion
without the OOB info.
-no-print satisfies the interactive pretty-print request.
See attached patch file.
--
Tim Gardner - timg@tpi.com 406-443-5357
TriplePoint, Inc. - http://www.tpi.com
PGP: http://www.tpi.com/PGP/Tim.txt
[-- Attachment #2: mtd.diff.IceCube --]
[-- Type: text/x-diff, Size: 2858 bytes --]
diff -r -u --new-file mtd/util/nanddump.c mtd.new/util/nanddump.c
--- mtd/util/nanddump.c 2003-02-20 06:34:20.000000000 -0700
+++ mtd.new/util/nanddump.c 2003-10-02 12:11:27.000000000 -0600
@@ -41,17 +41,31 @@
int main(int argc, char **argv)
{
unsigned long ofs;
- int i, fd, ofd, bs, start_addr, end_addr, pretty_print;
+ int i, fd, ofd, bs, start_addr, end_addr;
+ int pretty_print=(-1);
+ int no_oob=0;
struct mtd_oob_buf oob = {0, 16, oobbuf};
mtd_info_t meminfo;
unsigned char pretty_buf[80];
/* Make sure enough arguments were passed */
if (argc < 3) {
- printf("usage: %s <mtdname> <dumpname> [start addr] [length]\n", argv[0]);
+ printf("usage: %s <mtdname> <dumpname> [start addr] [length] [-no-oob] [-no-print]\n", argv[0]);
exit(1);
}
+ for (i=1; i<argc; i++)
+ {
+ if (!strcmp(argv[i],"-no-oob"))
+ {
+ no_oob = 1;
+ }
+ if (!strcmp(argv[i],"-no-print"))
+ {
+ pretty_print = 0;
+ }
+ }
+
/* Open MTD device */
if ((fd = open(argv[1], O_RDONLY)) == -1) {
perror("open flash");
@@ -72,6 +86,7 @@
close(fd);
exit(1);
}
+ printf("NAND block size %u Oob block %u\n", meminfo.oobblock,meminfo.oobsize);
/* Open output file for writing */
if ((ofd = open(argv[2], O_WRONLY | O_TRUNC | O_CREAT, 0644)) == -1) {
@@ -86,20 +101,23 @@
bs = meminfo.oobblock;
/* See if start address and length were specified */
- if (argc == 4) {
+ if (argc >= 4) {
start_addr = strtoul(argv[3], NULL, 0) & ~(bs - 1);
end_addr = meminfo.size;
- } else if (argc == 5) {
+ } else if (argc >= 5) {
start_addr = strtoul(argv[3], NULL, 0) & ~(bs - 1);
end_addr = (strtoul(argv[3], NULL, 0) + strtoul(argv[4], NULL, 0)) & ~(bs - 1);
}
/* Ask user if they would like pretty output */
- printf("Would you like formatted output? ");
- if (tolower(getc(stdin)) != 'y')
- pretty_print = 0;
- else
- pretty_print = 1;
+ if (pretty_print < 0)
+ {
+ printf("Would you like formatted output? ");
+ if (tolower(getc(stdin)) != 'y')
+ pretty_print = 0;
+ else
+ pretty_print = 1;
+ }
/* Print informative message */
printf("Dumping data starting at 0x%08x and ending at 0x%08x...\n",
@@ -138,7 +156,7 @@
/* Read OOB data and exit on failure */
oob.start = ofs;
- printf("Dumping %lx\n", ofs);
+ if (pretty_print > 0) printf("Dumping %lx\n", ofs);
if (ioctl(fd, MEMREADOOB, &oob) != 0) {
perror("ioctl(MEMREADOOB)");
close(fd);
@@ -147,7 +165,7 @@
}
/* Write out OOB data */
- if (pretty_print) {
+ if ((!no_oob) && pretty_print) {
if (meminfo.oobsize == 16) {
sprintf(pretty_buf, " OOB Data: %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -166,7 +184,7 @@
oobbuf[6], oobbuf[7]);
write(ofd, pretty_buf, 48);
}
- } else
+ } else if (!no_oob)
write(ofd, oobbuf, meminfo.oobsize);
}
next reply other threads:[~2003-10-02 19:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-02 19:44 Tim Gardner [this message]
2003-10-04 17:19 ` Patches to nanddump.c David Woodhouse
2003-10-06 13:13 ` Tim Gardner
2003-10-06 13:15 ` David Woodhouse
2003-10-06 17:32 ` Tim Gardner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200310021344.14931.timg@tpi.com \
--to=timg@tpi.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox