diff mbox

[3/5] Fix the bug of writing a yaffs2 image to NAND

Message ID 1265165796-24686-4-git-send-email-stanley.miao@windriver.com
State New, archived
Headers show

Commit Message

Stanley.Miao Feb. 3, 2010, 2:56 a.m. UTC
The tool mkyaffs2image doesn't know the oob layout of a NAND flash, so it
puts the yaffs2 tags at the offset 0 of oob area. When nandwrite writes the
image into NAND flash, it should put the yaffs2 tags at the right position
according to the NAND oob layout.

Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
 nandwrite.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/nandwrite.c b/nandwrite.c
index c66ab54..35f1e4d 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -429,6 +429,8 @@  int main(int argc, char * const argv[])
 
 		if (writeoob) {
 			int i, start, len;
+			int tags_pos = 0;
+
 			oobreadbuf = writebuf + meminfo.writesize;
 
 			// Read more data for the OOB from the input if there isn't enough in the buffer
@@ -470,8 +472,8 @@  int main(int argc, char * const argv[])
 				start = ecclayout.oobfree[i].offset;
 				len = ecclayout.oobfree[i].length;
 				memcpy(oobbuf + start,
-						oobreadbuf + start,
-						len);
+						oobreadbuf + tags_pos, len);
+				tags_pos += len;
 			}
 			/* Write OOB data first, as ecc will be placed in there*/
 			oob.start = mtdoffset;