int mtdparts_init(void);
int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
int find_dev_and_part(const char *id, struct mtd_device **dev,
- u8 *part_num, struct part_info **part);
+ u8 *part_num, struct part_info **part);
#endif
static int nand_dump_oob(nand_info_t *nand, ulong off)
return 1;
}
off &= ~(nand->writesize - 1);
-#if 0
- i = nand_read_raw(nand, buf, off, nand->writesize, nand->oobsize);
-#else
size_t dummy;
loff_t addr = (loff_t) off;
i = nand->read(nand, addr, nand->writesize, &dummy, buf);
-#endif
if (i < 0) {
printf("Error (%d) reading page %08lx\n", i, off);
free(buf);
if (argc < 3) {
if ((nand_curr_device < 0) ||
- (nand_curr_device >= CFG_MAX_NAND_DEVICE))
+ (nand_curr_device >= CFG_MAX_NAND_DEVICE))
puts("\nno devices available\n");
else
printf("\nDevice %d: %s\n", nand_curr_device,
}
if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 &&
- strncmp(cmd, "dump", 4) != 0 &&
- strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
- strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
- strcmp(cmd, "biterr") != 0 &&
- strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
+ strncmp(cmd, "dump", 4) != 0 &&
+ strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
+ strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
+ strcmp(cmd, "biterr") != 0 &&
+ strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
goto usage;
/* the following commands operate on the current device */
if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
nand_erase_options_t opts;
/* "clean" at index 2 means request to write cleanmarker */
- int clean = !strcmp("clean", argv[2]);
+ int clean = argc > 2 && !strcmp("clean", argv[2]);
int o = clean ? 3 : 2;
int scrub = !strcmp(cmd, "scrub");
return 1;
memset(&opts, 0, sizeof(opts));
-
opts.offset = off;
opts.length = size;
opts.jffs2 = clean;
s = strchr(cmd, '.');
if (s != NULL &&
- (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
+ (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
if (read) {
/* read */
nand_read_options_t opts;
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 */
mtd_oob_ops_t opts;
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 block_start = 0;
ulong off;
-// int last_status = -1;
+ int last_status = -1;
struct nand_chip *nand_chip = nand->priv;
/* check the WP bit */
nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1);
printf("device is %swrite protected\n",
(nand_chip->read_byte(nand) & 0x80 ?
- "NOT " : "" ) );
+ "NOT " : ""));
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->writesize
-// || (s != last_status && off != 0)) {
-//
-// printf("%08lx - %08lx: %8d pages %s%s%s\n",
-// block_start,
-// off-1,
-// (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 " : ""));
-// }
-//
-// last_status = s;
+ 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->writesize
+ || (s != last_status && off != 0)) {
+
+ printf("%08lx - %08lx: %8d pages %s%s%s\n",
+ block_start,
+ off-1,
+ (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 " : ""));
+ }
+
+ last_status = s;
}
} else {
-// if (!nand_lock(nand, tight)) {
-// puts("NAND flash successfully locked\n");
-// } else {
-// puts("Error locking NAND flash\n");
-// return 1;
-// }
+ if (!nand_lock(nand, tight)) {
+ puts("NAND flash successfully locked\n");
+ } else {
+ puts("Error locking NAND flash\n");
+ return 1;
+ }
}
+#endif
return 0;
}
if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0)
return 1;
-// if (!nand_unlock(nand, off, size)) {
-// puts("NAND flash successfully unlocked\n");
-// } else {
-// puts("Error unlocking NAND flash, "
-// "write and erase will probably fail\n");
-// 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 {
+ puts("Error unlocking NAND flash, "
+ "write and erase will probably fail\n");
+ return 1;
+ }
+#endif
return 0;
}
puts ("** Unknown image type\n");
return 1;
}
+ show_boot_progress (57);
r = nand_read(nand, offset, &cnt, (u_char *) addr);
if (r) {
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
-#undef NAND_DEBUG
-#undef PSYCHO_DEBUG
+#undef NAND_DEBUG
+#undef PSYCHO_DEBUG
/* ****************** WARNING *********************
* When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
* and attempting to program or erase bad blocks can affect
* the data in _other_ (good) blocks.
*/
-#define ALLOW_ERASE_BAD_DEBUG 0
+#define ALLOW_ERASE_BAD_DEBUG 0
#define CONFIG_MTD_NAND_ECC /* enable ECC */
#define CONFIG_MTD_NAND_ECC_JFFS2
/* bits for nand_legacy_rw() `cmd'; or together as needed */
-#define NANDRW_READ 0x01
-#define NANDRW_WRITE 0x00
-#define NANDRW_JFFS2 0x02
+#define NANDRW_READ 0x01
+#define NANDRW_WRITE 0x00
+#define NANDRW_JFFS2 0x02
#define NANDRW_JFFS2_SKIP 0x04
/*
extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
extern int curr_device;
extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs,
- size_t len, int clean);
+ size_t len, int clean);
extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start,
- size_t len, size_t *retlen, u_char *buf);
+ size_t len, size_t *retlen, u_char *buf);
extern void nand_print(struct nand_chip *nand);
extern void nand_print_bad(struct nand_chip *nand);
extern int nand_read_oob(struct nand_chip *nand, size_t ofs,
- size_t len, size_t *retlen, u_char *buf);
+ size_t len, size_t *retlen, u_char *buf);
extern int nand_write_oob(struct nand_chip *nand, size_t ofs,
- size_t len, size_t *retlen, const u_char *buf);
+ size_t len, size_t *retlen, const u_char *buf);
int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
if (strncmp (argv[1], "read", 4) == 0 ||
strncmp (argv[1], "write", 5) == 0) {
- ulong addr = simple_strtoul (argv[2], NULL, 16);
- off_t off = simple_strtoul (argv[3], NULL, 16);
- size_t size = simple_strtoul (argv[4], NULL, 16);
- int cmd = (strncmp (argv[1], "read", 4) == 0) ?
- NANDRW_READ : NANDRW_WRITE;
+ ulong addr = simple_strtoul (argv[2], NULL, 16);
+ off_t off = simple_strtoul (argv[3], NULL, 16);
+ size_t size = simple_strtoul (argv[4], NULL, 16);
+ int cmd = (strncmp (argv[1], "read", 4) == 0) ?
+ NANDRW_READ : NANDRW_WRITE;
size_t total;
int ret;
char *cmdtail = strchr (argv[1], '.');
else if (cmdtail && !strcmp (cmdtail, ".i")) {
cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
if (cmd & NANDRW_READ)
- cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
+ cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
}
#endif /* CFG_NAND_SKIP_BAD_DOT_I */
else if (cmdtail) {
ret = nand_legacy_rw (nand_dev_desc + curr_device,
cmd, off, size,
- &total,
- (u_char *) addr);
+ &total, (u_char *) addr);
printf (" %d bytes %s: %s\n", total,
(cmd & NANDRW_READ) ? "read" : "written",
}
U_BOOT_CMD(
- nand, 5, 1, do_nand,
+ nand, 5, 1, do_nand,
"nand - legacy NAND sub-system\n",
"info - show available NAND devices\n"
"nand device [dev] - show or set current device\n"
dev = simple_strtoul(boot_device, &ep, 16);
if ((dev >= CFG_MAX_NAND_DEVICE) ||
- (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
+ (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
printf ("\n** Device %d not available\n", dev);
show_boot_progress (-55);
return 1;
}
U_BOOT_CMD(
- nboot, 4, 1, do_nandboot,
+ nboot, 4, 1, do_nandboot,
"nboot - boot from NAND device\n",
"loadAddr dev\n"
);