Patchwork [PATCHv2] nanddump: Support 4096+218 and 4096+224 page sizes

login
register
mail settings
Submitter Kevin Cernekee
Date May 4, 2010, 5:10 a.m.
Message ID <947e853e5d1ba35a67546703267b0fabe59af110@localhost.localdomain>
Download mbox | patch
Permalink /patch/51564/
State New
Headers show

Comments

Kevin Cernekee - May 4, 2010, 5:10 a.m.
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(-)
Artem Bityutskiy - May 5, 2010, 11:26 a.m.
On Mon, 2010-05-03 at 22:10 -0700, Kevin Cernekee wrote:
> 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>

Does not apply to the latest mtd-utils:

Applying: nanddump: Support 4096+218 and 4096+224 page sizes
error: patch failed: nanddump.c:209
error: nanddump.c: patch does not apply
Patch failed at 0001 nanddump: Support 4096+218 and 4096+224 page sizes
When you have resolved this problem run "git am -i --resolved".
If you would prefer to skip this patch, instead run "git am -i --skip".
To restore the original branch and stop patching run "git am -i --abort".
[dedekind@eru mtd-utils]$ patch -p1 < .git/rebase-apply/patch 
patching file nanddump.c
Hunk #2 FAILED at 212.
Hunk #3 succeeded at 359 (offset 2 lines).
1 out of 3 hunks FAILED -- saving rejects to file nanddump.c.rej

Patch

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) {