[U-Boot-Users] [PATCH 2/9] NAND update
William Juul
william.juul at datarespons.no
Wed Nov 14 15:28:31 CET 2007
> Hi William,
>
> please find some comments below.
>
>
> Why is the "old" code still present here (#if 0)? It it is needed for some
> reason, please add a comment why this is the case.
>
> I don't like these coding style changes in this patch series. It makes it hard
> to find the "real" changes. Please revert those coding style changes.
>
> BTW: The original alignment is better from my point of view.
>
> This change doesn't seem save to me. Perhaps I'm missing something, but the
> original version seems saver to me.
>
> What has to be fixed? Please add a more descriptive text here, that also
> others may help fixing there issues.
>
Stefan, you are absolutely rigth in all your comments. All the issues
should have been removed before I submitted the patch. Sorry about that.
Below is a revised patch of the two files in question. Now considerably
smaller and with broken code clearly marked.
When removing the "noise" it occured to me that there is outstanding issues
with regard to JFFS in common/cmd_nand.c and drivers/nand/nand_util.c. I
hope developers interested in these features can help working on these
issues... :-)
Best regards,
William
diff --git a/common/cmd_doc.c b/common/cmd_doc.c
index d6d3aff..129305c 100644
--- a/common/cmd_doc.c
+++ b/common/cmd_doc.c
@@ -17,6 +17,12 @@
#include <linux/mtd/nftl.h>
#include <linux/mtd/doc2000.h>
+/*
+ * ! BROKEN !
+ *
+ * TODO: must be implemented and tested by someone with HW
+ */
+#if 0
#ifdef CFG_DOC_SUPPORT_2000
#define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k)
#else
@@ -1607,5 +1613,7 @@ void doc_probe(unsigned long physadr)
puts ("No DiskOnChip found\n");
}
}
-
+#else
+void doc_probe(unsigned long physadr) {}
+#endif
#endif
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 1fdd7a6..bb1accd 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -18,6 +18,7 @@
*
*/
#include <common.h>
+#include <linux/mtd/mtd.h>
#if defined(CONFIG_CMD_NAND)
@@ -49,20 +50,22 @@ static int nand_dump(nand_info_t *nand, ulong off)
int i;
u_char *buf, *p;
- buf = malloc(nand->oobblock + nand->oobsize);
+ buf = malloc(nand->writesize + nand->oobsize);
if (!buf) {
puts("No memory for page buffer\n");
return 1;
}
- off &= ~(nand->oobblock - 1);
- i = nand_read_raw(nand, buf, off, nand->oobblock, nand->oobsize);
+ off &= ~(nand->writesize - 1);
+ size_t dummy;
+ loff_t addr = (loff_t) off;
+ i = nand->read(nand, addr, nand->writesize, &dummy, buf);
if (i < 0) {
printf("Error (%d) reading page %08x\n", i, off);
free(buf);
return 1;
}
printf("Page %08x dump:\n", off);
- i = nand->oobblock >> 4; p = buf;
+ i = nand->writesize >> 4; p = buf;
while (i--) {
printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x"
" %02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -158,6 +161,7 @@ out:
int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
int i, dev, ret;
+ ret = 0;
ulong addr, off, size;
char *cmd, *s;
nand_info_t *nand;
@@ -333,19 +337,22 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
opts.length = size;
opts.offset = off;
opts.quiet = quiet;
- ret = nand_read_opts(nand, &opts);
+/*
+ * ! BROKEN !
+ *
+ * TODO: Function must be implemented
+ *
+ * ret = nand_read_opts(nand, &opts);
+ */
} else {
/* write */
- nand_write_options_t opts;
+ mtd_oob_ops_t opts;
memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = size;
- opts.offset = off;
- /* opts.forcejffs2 = 1; */
- opts.pad = 1;
- opts.blockalign = 1;
- opts.quiet = quiet;
- ret = nand_write_opts(nand, &opts);
+ opts.datbuf = (u_char*) addr;
+ opts.len = size;
+ opts.ooblen = 64;
+ opts.mode = MTD_OOB_AUTO;
+ ret = nand_write_opts(nand, off, &opts);
}
} else {
if (read)
@@ -388,7 +395,12 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
if (!strcmp("status", argv[2]))
status = 1;
}
-
+/*
+ * ! BROKEN !
+ *
+ * TODO: must be implemented and tested by someone with HW
+ */
+#if 0
if (status) {
ulong block_start = 0;
ulong off;
@@ -401,19 +413,19 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
(nand_chip->read_byte(nand) & 0x80 ?
"NOT " : "" ) );
- for (off = 0; off < nand->size; off += nand->oobblock) {
+ for (off = 0; off < nand->size; off += nand->writesize) {
int s = nand_get_lock_status(nand, off);
/* print message only if status has changed
* or at end of chip
*/
- if (off == nand->size - nand->oobblock
+ if (off == nand->size - nand->writesize
|| (s != last_status && off != 0)) {
printf("%08x - %08x: %8d pages %s%s%s\n",
block_start,
off-1,
- (off-block_start)/nand->oobblock,
+ (off-block_start)/nand->writesize,
((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
@@ -429,6 +441,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 1;
}
}
+#endif
return 0;
}
@@ -436,6 +449,12 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0)
return 1;
+/*
+ * ! BROKEN !
+ *
+ * TODO: must be implemented and tested by someone with HW
+ */
+#if 0
if (!nand_unlock(nand, off, size)) {
puts("NAND flash successfully unlocked\n");
} else {
@@ -443,6 +462,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
"write and erase will probably fail\n");
return 1;
}
+#endif
return 0;
}
@@ -484,19 +504,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);
- cnt = nand->oobblock;
- if (jffs2) {
- nand_read_options_t opts;
- memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = cnt;
- opts.offset = offset;
- opts.quiet = 1;
- r = nand_read_opts(nand, &opts);
- } else {
- r = nand_read(nand, offset, &cnt, (u_char *) addr);
- }
-
+ cnt = nand->writesize;
+ r = nand_read(nand, offset, &cnt, (u_char *) addr);
if (r) {
puts("** Read error\n");
show_boot_progress (-56);
@@ -516,18 +525,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
print_image_hdr(hdr);
cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t));
- if (jffs2) {
- nand_read_options_t opts;
- memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = cnt;
- opts.offset = offset;
- opts.quiet = 1;
- r = nand_read_opts(nand, &opts);
- } else {
- r = nand_read(nand, offset, &cnt, (u_char *) addr);
- }
+ r = nand_read(nand, offset, &cnt, (u_char *) addr);
if (r) {
puts("** Read error\n");
show_boot_progress (-58);
More information about the U-Boot
mailing list