linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] nanddump: Support 4096+218 and 4096+224 page sizes
@ 2010-05-04  5:10 Kevin Cernekee
  2010-05-05 11:26 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Cernekee @ 2010-05-04  5:10 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd

Tested with Samsung K9GAG08U0D (4096+218).

This fixes three additional problems found after the initial patch
submission:

1) oobbuf was only 128B.  Needs to be 256B now.

2) Random OOB data is output when nanddump hits a bad block, because
the code was initializing readbuf instead.

3) When using "-p", random data is displayed for bytes 218-223 since
the OOB does not end on a 16B boundary.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 nanddump.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index 678d684..4c0a094 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -174,8 +174,11 @@ static void process_options (int argc, char * const argv[])
 /*
  * Buffers for reading data from flash
  */
+
+#define NAND_MAX_OOBSIZE 256
+
 static unsigned char readbuf[4096];
-static unsigned char oobbuf[128];
+static unsigned char oobbuf[NAND_MAX_OOBSIZE];
 
 /*
  * Main program
@@ -209,7 +212,9 @@ int main(int argc, char * const argv[])
 	}
 
 	/* Make sure device page sizes are valid */
-	if (!(meminfo.oobsize == 128 && meminfo.writesize == 4096) &&
+	if (!(meminfo.oobsize == 224 && meminfo.writesize == 4096) &&
+			!(meminfo.oobsize == 218 && meminfo.writesize == 4096) &&
+			!(meminfo.oobsize == 128 && meminfo.writesize == 4096) &&
 			!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
 			!(meminfo.oobsize == 32 && meminfo.writesize == 1024) &&
 			!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
@@ -354,9 +359,8 @@ int main(int argc, char * const argv[])
 		if (omitoob)
 			continue;
 
-		if (badblock) {
-			memset (readbuf, 0xff, meminfo.oobsize);
-		} else {
+		memset (oobbuf, 0xff, NAND_MAX_OOBSIZE);
+		if (!badblock) {
 			/* Read OOB data and exit on failure */
 			oob.start = ofs;
 			if (ioctl(fd, MEMREADOOB, &oob) != 0) {
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-05 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  5:10 [PATCHv2] nanddump: Support 4096+218 and 4096+224 page sizes Kevin Cernekee
2010-05-05 11:26 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).