Skip to contentSkip to conversation

Add Yaffs2 image writing support.

PATCH New Li Wenhao 3 participants 5 messages Jan 10, 2010 – Apr 10, 2010

lore
Share & tools
lore

Li Wenhao

author
#0 lore raw

PATCH 1/1 Add Yaffs2 image writing support.

---
 common/cmd_nand.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
common/cmd_nand.c +21 -0
index 075a8af..38c6480 100644
@@ -390,6 +390,27 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 				ret = nand->read_oob(nand, off, &ops);
 			else
 				ret = nand->write_oob(nand, off, &ops);
+		} else if (!strcmp(s, ".yaffs2") && !read) {
+			mtd_oob_ops_t ops = {
+				.mode = MTD_OOB_AUTO,
+				.len = 2048,	/* page size */
+				.ooblen = 64,	/* spare size */
+			};
+
+			ulong page = 0;
+			ulong block_size = ops.len + ops.ooblen;
+			while (page * block_size < size) {
+				ops.datbuf = addr + page * block_size;
+				ops.oobbuf = ops.datbuf + ops.len;
+
+				ret = nand->write_oob(nand, 
+						      off + page * ops.len,
+						      &ops);
+
+				if (ret) break;
+
+				page++;
+			}
 		} else {
 			printf("Unknown nand command suffix '%s'.\n", s);
 			return 1;
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 Add Yaffs2 image writing support.

Dear Scott,

Quoted 40 lines · In message <[email protected]> Li Wenha…
---
 common/cmd_nand.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
common/cmd_nand.c +21 -0
index 075a8af..38c6480 100644
@@ -390,6 +390,27 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 				ret = nand->read_oob(nand, off, &ops);
 			else
 				ret = nand->write_oob(nand, off, &ops);
+		} else if (!strcmp(s, ".yaffs2") && !read) {
+			mtd_oob_ops_t ops = {
+				.mode = MTD_OOB_AUTO,
+				.len = 2048,	/* page size */
+				.ooblen = 64,	/* spare size */
+			};
+
+			ulong page = 0;
+			ulong block_size = ops.len + ops.ooblen;
+			while (page * block_size < size) {
+				ops.datbuf = addr + page * block_size;
+				ops.oobbuf = ops.datbuf + ops.len;
+
+				ret = nand->write_oob(nand, 
+						      off + page * ops.len,
+						      &ops);
+
+				if (ret) break;
+
+				page++;
+			}
 		} else {
 			printf("Unknown nand command suffix '%s'.\n", s);
 			return 1;
Signature · 1 line
1.6.3.3

What is the status of this patch? Is it in your queue?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A year spent in artificial intelligence is enough to make one believe
in God.
#2 lore raw

PATCH 1/1 Add Yaffs2 image writing support.

Quoted 8 lines · Wolfgang Denk

Dear Scott,

Quoted 5 lines · In message <[email protected]> Li Wenha…
---
 common/cmd_nand.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
Quoted 14 lines
Quoted 5 lines
common/cmd_nand.c +0 -0
index 075a8af..38c6480 100644

common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) · line 398

Quoted 9 lines
common/cmd_nand.c +6 -0
@@ -390,6 +390,27 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 				ret = nand->read_oob(nand, off, &ops);
 			else
 				ret = nand->write_oob(nand, off, &ops);
+		} else if (!strcmp(s, ".yaffs2") && !read) {
+			mtd_oob_ops_t ops = {
+				.mode = MTD_OOB_AUTO,
+				.len = 2048,	/* page size */
+				.ooblen = 64,	/* spare size */
+			};

What about 512 or 4096 byte pages?

Quoted 4 lines

common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) · line 402

Quoted 4 lines
common/cmd_nand.c +4 -0
+
+			ulong page = 0;
+			ulong block_size = ops.len + ops.ooblen;
+			while (page * block_size < size) {

What if "size" is not a multiple of "block_size"? Should not read past the end of the input array, and should warn the user.

Quoted 5 lines

common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) · line 410

Quoted 5 lines
common/cmd_nand.c +5 -0
+				ret = nand->write_oob(nand, 
+						      off + page * ops.len,
+						      &ops);
+
+				if (ret) break;

The break should go on its own line, and you should tell the user about the failure.

Quoted 10 lines
Quoted 8 lines
common/cmd_nand.c +3 -0
+
+				page++;
+			}
 		} else {
 			printf("Unknown nand command suffix '%s'.\n", s);
 			return 1;
Signature · 1 line
1.6.3.3

What is the status of this patch? Is it in your queue?

No, I didn't notice it -- the subject doesn't mention NAND, and it presumably wasn't CCed to me.

Li Wenhao, could you send a new patch addressing the above issues, plus updated documentation?

-Scott

#3 lore raw

PATCH 1/1 Add Yaffs2 image writing support.

In reply to Li Wenhao

Dear Li Wenhao,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 common/cmd_nand.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

Scott sent a number of comments / change requests for this patch. Do you intend to submit an updated patch any time soon, or shall I drop this from my list?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An expert is a person who avoids the small errors while  sweeping  on
to the grand fallacy.
author
#4 lore raw

PATCH 1/1 Add Yaffs2 image writing support.

It's my mistake. I should send my mails to the mail-list instead of only replied to Scott.

After discussing the requests with Scott, I realized that my patch may not work on a lot of chips. So please drop it.

Best regards,

Li Wenhao

2010/4/10 Wolfgang Denk <[email protected]>:

Quoted 24 lines

Dear Li Wenhao,

Quoted 5 lines · In message <[email protected]> you wrote:

---
?common/cmd_nand.c | ? 21 +++++++++++++++++++++ ?1 files changed, 21 insertions(+), 0 deletions(-)

Scott sent a number of comments / change requests for this patch. Do you intend to submit an updated patch any time soon, or shall I drop this from my list?

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de An expert is a person who avoids the small errors while ?sweeping ?on to the grand fallacy.