nandwrite autoplace for real

Todd Poynor tpoynor at mvista.com
Mon Nov 28 20:01:48 EST 2005


On Tue, Nov 22, 2005 at 06:47:38PM -0800, Todd Poynor wrote:
> nandwrite -a, on the other hand, requires the input to have the OOB data
> already autoplaced (skipping ECC bytes, etc.), and copies the free bytes
> position-by-position from input to OOB.
> 
> The former definition seems much more useful.  Any objection to the
> following patch?  Is anything using the current definition?

To err on the side of safety, here's a new version that only triggers the
new behavior when the "-a" option is given and the target mtd device
advertises an autoplace OOB layout (which used to be a NOP).

To recap: the new behavior is to take a string of bytes without ECC or
bad blocks information from the input file (supplied by the fs creation
utility) and place those bytes in free OOB positions in the target
device (much like the in-kernel nand_write_ecc).  The existing behavior
is to copy free OOB byte positions from input to the device, skipping
ECC bytes and bad block indicator in both input and output (when the
destination device uses an auto OOB layout).

If you use nandwrite -a on files containing OOB data that is formatted
to match the auto OOB layout of a particular device, this patch will
break that usage, but omitting the "-a" option should preserve the
existing behavior.

Any disagreement that this is an appropriate way for nandwrite -a to
behave real soon now?

Index: util/nandwrite.c
===================================================================
RCS file: /home/cvs/mtd/util/nandwrite.c,v
retrieving revision 1.32
diff -u -r1.32 nandwrite.c
--- util/nandwrite.c	7 Nov 2005 11:15:13 -0000	1.32
+++ util/nandwrite.c	29 Nov 2005 00:39:49 -0000
@@ -400,7 +400,20 @@
 				 * Modified to support out of order oobfree segments,
 				 * such as the layout used by diskonchip.c
 				 */
-				if (!oobinfochanged && (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE)) {
+				if (autoplace &&
+				    (old_oobinfo.useecc == 
+				     MTD_NANDECC_AUTOPLACE)) {
+					int src;
+
+					for (src = 0, i = 0;old_oobinfo.oobfree[i][1]; i++) {
+						start = old_oobinfo.oobfree[i][0];
+						len = old_oobinfo.oobfree[i][1];
+						memcpy(oobbuf + start,
+						       oobreadbuf + src,
+						       len);
+						src += len;
+					}
+				} else if (!oobinfochanged && (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE)) {
 					for (i = 0;old_oobinfo.oobfree[i][1]; i++) {
 						/* Set the reserved bytes to 0xff */
 						start = old_oobinfo.oobfree[i][0];
 
 




More information about the linux-mtd mailing list