diff --exclude CVS --exclude .git -uNr mtd-utils/nanddump.c mtd-utils.modified/nanddump.c
--- mtd-utils/nanddump.c	2010-01-16 01:12:24.000000000 +0800
+++ mtd-utils.modified/nanddump.c	2010-07-20 15:49:19.000000000 +0800
@@ -174,8 +174,10 @@
 /*
  * Buffers for reading data from flash
  */
-static unsigned char readbuf[4096];
-static unsigned char oobbuf[128];
+#define NAND_MAX_PAGESIZE 4096
+#define NAND_MAX_OOBSIZE 256
+static unsigned char readbuf[NAND_MAX_PAGESIZE];
+static unsigned char oobbuf[NAND_MAX_OOBSIZE];
 
 /*
  * Main program
@@ -209,7 +211,10 @@
 	}
 
 	/* 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 == 4096) &&
 			!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
 			!(meminfo.oobsize == 32 && meminfo.writesize == 1024) &&
 			!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
diff --exclude CVS --exclude .git -uNr mtd-utils/nandwrite.c mtd-utils.modified/nandwrite.c
--- mtd-utils/nandwrite.c	2010-01-16 01:12:24.000000000 +0800
+++ mtd-utils.modified/nandwrite.c	2010-07-20 15:51:00.000000000 +0800
@@ -43,7 +43,7 @@
 #define VERSION "$Revision: 1.32 $"
 
 #define MAX_PAGE_SIZE	4096
-#define MAX_OOB_SIZE	128
+#define MAX_OOB_SIZE	256
 
 // oob layouts to pass into the kernel as default
 static struct nand_oobinfo none_oobinfo = {
@@ -80,6 +80,7 @@
 "  -m, --markbad           Mark blocks bad if write fails\n"
 "  -n, --noecc             Write without ecc\n"
 "  -o, --oob               Image contains oob data\n"
+"  -r, --raw               Image contains the raw oob data dumped by nanddump\n"
 "  -s addr, --start=addr   Set start address (default is 0)\n"
 "  -p, --pad               Pad to page size\n"
 "  -b, --blockalign=1|2|4  Set multiple of eraseblocks to align to\n"
@@ -110,6 +111,7 @@
 static int		mtdoffset = 0;
 static bool		quiet = false;
 static bool		writeoob = false;
+static bool		rawoob = false;
 static bool		autoplace = false;
 static bool		markbad = false;
 static bool		forcejffs2 = false;
@@ -125,7 +127,7 @@
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "ab:fjmnopqs:y";
+		static const char *short_options = "ab:fjmnopqrs:y";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -138,6 +140,7 @@
 			{"oob", no_argument, 0, 'o'},
 			{"pad", no_argument, 0, 'p'},
 			{"quiet", no_argument, 0, 'q'},
+			{"raw", no_argument, 0, 'r'},
 			{"start", required_argument, 0, 's'},
 			{"yaffs", no_argument, 0, 'y'},
 			{0, 0, 0, 0},
@@ -187,6 +190,10 @@
 			case 'p':
 				pad = true;
 				break;
+			case 'r':
+				rawoob = true;
+				writeoob = true;
+				break;
 			case 's':
 				mtdoffset = strtol (optarg, NULL, 0);
 				break;
@@ -294,12 +301,23 @@
 	if (!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
 			!(meminfo.oobsize == 8 && meminfo.writesize == 256) &&
 			!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
-			!(meminfo.oobsize == 128 && meminfo.writesize == 4096)) {
+			!(meminfo.oobsize == 64 && meminfo.writesize == 4096) &&
+			!(meminfo.oobsize == 128 && meminfo.writesize == 4096)&&
+			!(meminfo.oobsize == 218 && meminfo.writesize == 4096)&&
+			!(meminfo.oobsize == 224 && meminfo.writesize == 4096)) {
 		fprintf(stderr, "Unknown flash (not normal NAND)\n");
 		close(fd);
 		exit (EXIT_FAILURE);
 	}
 
+	if (mtdoffset & (meminfo.writesize - 1)) {
+		fprintf(stderr, "The start address is not page-aligned !\n"
+				"The pagesize of this NAND Flash is 0x%x.\n",
+				meminfo.writesize);
+		close(fd);
+		exit(EXIT_FAILURE);
+	}
+
 	if (autoplace) {
 		/* Read the current oob info */
 		if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
@@ -583,6 +601,7 @@
 				oob.ptr = oobreadbuf;
 			} else {
 				int i, start, len;
+				int tags_pos = 0;
 				/*
 				 *  We use autoplacement and have the oobinfo with the autoplacement
 				 * information from the kernel available
@@ -595,9 +614,13 @@
 						/* Set the reserved bytes to 0xff */
 						start = old_oobinfo.oobfree[i][0];
 						len = old_oobinfo.oobfree[i][1];
-						memcpy(oobbuf + start,
-								oobreadbuf + start,
-								len);
+						if (rawoob)
+							memcpy(oobbuf + start,
+									oobreadbuf + start, len);
+						else
+							memcpy(oobbuf + start,
+									oobreadbuf + tags_pos, len);
+						tags_pos += len;
 					}
 				} else {
 					/* Set at least the ecc byte positions to 0xff */
