2 * Driver for NAND support, Rick Bronson
3 * borrowed heavily from:
4 * (c) 1999 Machine Vision Holdings, Inc.
5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
7 * Added 16-bit nand support
8 * (C) 2004 Texas Instruments
14 #ifndef CFG_NAND_LEGACY
22 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
27 #include <asm/byteorder.h>
29 #ifdef CONFIG_SHOW_BOOT_PROGRESS
30 # include <status_led.h>
31 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
33 # define SHOW_BOOT_PROGRESS(arg)
36 #include <jffs2/jffs2.h>
39 extern nand_info_t nand_info[]; /* info for NAND chips */
41 static int nand_dump_oob(nand_info_t *nand, ulong off)
46 static int nand_dump(nand_info_t *nand, ulong off)
51 buf = malloc(nand->oobblock + nand->oobsize);
53 puts("No memory for page buffer\n");
56 off &= ~(nand->oobblock - 1);
57 i = nand_read_raw(nand, buf, off, nand->oobblock, nand->oobsize);
59 printf("Error (%d) reading page %08x\n", i, off);
63 printf("Page %08x dump:\n", off);
64 i = nand->oobblock >> 4; p = buf;
66 printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x"
67 " %02x %02x %02x %02x %02x %02x %02x %02x\n",
68 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
69 p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
73 i = nand->oobsize >> 3;
75 printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x\n",
76 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
84 /* ------------------------------------------------------------------------- */
87 arg_off_size(int argc, char *argv[], ulong *off, ulong *size, ulong totsize)
92 #if defined(CONFIG_JFFS2_NAND) && defined(CFG_JFFS_CUSTOM_PART)
93 if (argc >= 1 && strcmp(argv[0], "partition") == 0) {
95 struct part_info *part;
101 partstr = getenv("partition");
104 part_num = (int)simple_strtoul(partstr, NULL, 10);
108 part = jffs2_part_info(part_num);
110 printf("\nInvalid partition %d\n", part_num);
114 *off = (ulong)part->offset;
119 *off = (ulong)simple_strtoul(argv[0], NULL, 16);
124 *size = (ulong)simple_strtoul(argv[1], NULL, 16);
126 *size = totsize - *off;
132 int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
135 ulong addr, off, size;
139 const char *quiet_str = getenv("quiet");
141 /* at least two arguments please */
146 quiet = simple_strtoul(quiet_str, NULL, 0) != 0;
150 if (strcmp(cmd, "info") == 0) {
153 for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
154 if (nand_info[i].name)
155 printf("Device %d: %s, sector size %lu KiB\n",
156 i, nand_info[i].name,
157 nand_info[i].erasesize >> 10);
162 if (strcmp(cmd, "device") == 0) {
165 if ((nand_curr_device < 0) ||
166 (nand_curr_device >= CFG_MAX_NAND_DEVICE))
167 puts("\nno devices available\n");
169 printf("\nDevice %d: %s\n", nand_curr_device,
170 nand_info[nand_curr_device].name);
173 dev = (int)simple_strtoul(argv[2], NULL, 10);
174 if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) {
175 puts("No such device\n");
178 printf("Device %d: %s", dev, nand_info[dev].name);
179 puts("... is now current device\n");
180 nand_curr_device = dev;
184 if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 &&
185 strncmp(cmd, "dump", 4) != 0 &&
186 strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
187 strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
188 strcmp(cmd, "biterr") != 0 &&
189 strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
192 /* the following commands operate on the current device */
193 if (nand_curr_device < 0 || nand_curr_device >= CFG_MAX_NAND_DEVICE ||
194 !nand_info[nand_curr_device].name) {
195 puts("\nno devices available\n");
198 nand = &nand_info[nand_curr_device];
200 if (strcmp(cmd, "bad") == 0) {
201 printf("\nDevice %d bad blocks:\n", nand_curr_device);
202 for (off = 0; off < nand->size; off += nand->erasesize)
203 if (nand_block_isbad(nand, off))
204 printf(" %08x\n", off);
208 if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
209 nand_erase_options_t opts;
210 int clean = argc >= 3 && !strcmp("clean", argv[2]);
211 int rest_argc = argc - 2;
212 char **rest_argv = argv + 2;
213 int scrub = !strcmp(cmd, "scrub");
220 if (rest_argc == 0) {
222 printf("\nNAND %s: device %d whole chip\n",
228 arg_off_size(rest_argc, rest_argv, &off, &size,
231 if (off == 0 && size == 0)
234 printf("\nNAND %s: device %d offset 0x%x, size 0x%x\n",
235 cmd, nand_curr_device, off, size);
238 memset(&opts, 0, sizeof(opts));
246 "scrub option will erase all factory set "
249 "There is no reliable way to recover them.\n"
251 "Use this command only for testing purposes "
254 "are sure of what you are doing!\n"
255 "\nReally scrub this NAND flash? <y/N>\n"
258 if (getc() == 'y' && getc() == '\r') {
261 printf("scrub aborted\n");
265 ret = nand_erase_opts(nand, &opts);
266 printf("%s\n", ret ? "ERROR" : "OK");
268 return ret == 0 ? 0 : 1;
271 if (strncmp(cmd, "dump", 4) == 0) {
275 s = strchr(cmd, '.');
276 off = (int)simple_strtoul(argv[2], NULL, 16);
278 if (s != NULL && strcmp(s, ".oob") == 0)
279 ret = nand_dump_oob(nand, off);
281 ret = nand_dump(nand, off);
283 return ret == 0 ? 1 : 0;
288 if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {
294 addr = (ulong)simple_strtoul(argv[2], NULL, 16);
296 arg_off_size(argc - 3, argv + 3, &off, &size, nand->size);
297 if (off == 0 && size == 0)
300 read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
301 printf("\nNAND %s: device %d offset %u, size %u ... ",
302 read ? "read" : "write", nand_curr_device, off, size);
304 s = strchr(cmd, '.');
306 (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
309 nand_read_options_t opts;
310 memset(&opts, 0, sizeof(opts));
311 opts.buffer = (u_char*) addr;
315 ret = nand_read_opts(nand, &opts);
318 nand_write_options_t opts;
319 memset(&opts, 0, sizeof(opts));
320 opts.buffer = (u_char*) addr;
323 /* opts.forcejffs2 = 1; */
327 ret = nand_write_opts(nand, &opts);
329 printf("%s\n", ret ? "ERROR" : "OK");
330 return ret == 0 ? 0 : 1;
334 ret = nand_read(nand, off, &size, (u_char *)addr);
336 ret = nand_write(nand, off, &size, (u_char *)addr);
338 printf(" %d bytes %s: %s\n", size,
339 read ? "read" : "written", ret ? "ERROR" : "OK");
341 return ret == 0 ? 0 : 1;
344 if (strcmp(cmd, "markbad") == 0) {
345 addr = (ulong)simple_strtoul(argv[2], NULL, 16);
347 int ret = nand->block_markbad(nand, addr);
349 printf("block 0x%08lx successfully marked as bad\n",
353 printf("block 0x%08lx NOT marked as bad! ERROR %d\n",
358 if (strcmp(cmd, "biterr") == 0) {
363 if (strcmp(cmd, "lock") == 0) {
367 if (!strcmp("tight", argv[2]))
369 if (!strcmp("status", argv[2]))
374 ulong block_start = 0;
376 int last_status = -1;
378 struct nand_chip *nand_chip = nand->priv;
379 /* check the WP bit */
380 nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1);
381 printf("device is %swrite protected\n",
382 (nand_chip->read_byte(nand) & 0x80 ?
385 for (off = 0; off < nand->size; off += nand->oobblock) {
386 int s = nand_get_lock_status(nand, off);
388 /* print message only if status has changed
391 if (off == nand->size - nand->oobblock
392 || (s != last_status && off != 0)) {
394 printf("%08x - %08x: %8d pages %s%s%s\n",
397 (off-block_start)/nand->oobblock,
398 ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
399 ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
400 ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
406 if (!nand_lock(nand, tight)) {
407 printf ("NAND flash successfully locked\n");
409 printf ("Error locking NAND flash. \n");
416 if (strcmp(cmd, "unlock") == 0) {
421 arg_off_size(argc - 2, argv + 2, &off, &size,
425 if (!nand_unlock(nand, off, size)) {
426 printf("NAND flash successfully unlocked\n");
428 printf("Error unlocking NAND flash. "
429 "Write and erase will probably fail\n");
436 printf("Usage:\n%s\n", cmdtp->usage);
440 U_BOOT_CMD(nand, 5, 1, do_nand,
441 "nand - NAND sub-system\n",
442 "info - show available NAND devices\n"
443 "nand device [dev] - show or set current device\n"
444 "nand read[.jffs2] - addr off size\n"
445 "nand write[.jffs2] - addr off size - read/write `size' bytes starting\n"
446 " at offset `off' to/from memory address `addr'\n"
447 "nand erase [clean] [off size] - erase `size' bytes from\n"
448 " offset `off' (entire device if not specified)\n"
449 "nand bad - show bad blocks\n"
450 "nand dump[.oob] off - dump page\n"
451 "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
452 "nand markbad off - mark bad block at offset (UNSAFE)\n"
453 "nand biterr off - make a bit error at offset (UNSAFE)\n"
454 "nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
455 "nand unlock [offset] [size] - unlock section\n");
457 int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
459 char *boot_device = NULL;
463 ulong addr, cnt, offset = 0;
469 addr = CFG_LOAD_ADDR;
470 boot_device = getenv("bootdevice");
473 addr = simple_strtoul(argv[1], NULL, 16);
474 boot_device = getenv("bootdevice");
477 addr = simple_strtoul(argv[1], NULL, 16);
478 boot_device = argv[2];
481 addr = simple_strtoul(argv[1], NULL, 16);
482 boot_device = argv[2];
483 offset = simple_strtoul(argv[3], NULL, 16);
486 printf("Usage:\n%s\n", cmdtp->usage);
487 SHOW_BOOT_PROGRESS(-1);
492 puts("\n** No boot device **\n");
493 SHOW_BOOT_PROGRESS(-1);
497 dev = simple_strtoul(boot_device, &ep, 16);
499 if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) {
500 printf("\n** Device %d not available\n", dev);
501 SHOW_BOOT_PROGRESS(-1);
505 nand = &nand_info[dev];
506 printf("\nLoading from device %d: %s (offset 0x%lx)\n",
507 dev, nand->name, offset);
509 cnt = nand->oobblock;
510 r = nand_read(nand, offset, &cnt, (u_char *) addr);
512 printf("** Read error on %d\n", dev);
513 SHOW_BOOT_PROGRESS(-1);
517 hdr = (image_header_t *) addr;
519 if (ntohl(hdr->ih_magic) != IH_MAGIC) {
520 printf("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic);
521 SHOW_BOOT_PROGRESS(-1);
525 print_image_hdr(hdr);
527 cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t));
529 r = nand_read(nand, offset, &cnt, (u_char *) addr);
531 printf("** Read error on %d\n", dev);
532 SHOW_BOOT_PROGRESS(-1);
536 /* Loading ok, update default load address */
540 /* Check if we should attempt an auto-start */
541 if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
543 extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
545 local_args[0] = argv[0];
546 local_args[1] = NULL;
548 printf("Automatic boot of image at addr 0x%08lx ...\n", addr);
550 do_bootm(cmdtp, 0, 1, local_args);
556 U_BOOT_CMD(nboot, 4, 1, do_nandboot,
557 "nboot - boot from NAND device\n", "loadAddr dev\n");
560 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
562 #else /* CFG_NAND_LEGACY */
565 * Legacy NAND support - to be phased out
571 #include <watchdog.h>
573 #ifdef CONFIG_SHOW_BOOT_PROGRESS
574 # include <status_led.h>
575 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
577 # define SHOW_BOOT_PROGRESS(arg)
580 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
581 #include <linux/mtd/nand_legacy.h>
583 #include <linux/mtd/nand_ids.h>
584 #include <jffs2/jffs2.h>
587 #ifdef CONFIG_OMAP1510
588 void archflashwp(void *archdata, int wp);
591 #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
596 /* ****************** WARNING *********************
597 * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
598 * erase (or at least attempt to erase) blocks that are marked
599 * bad. This can be very handy if you are _sure_ that the block
600 * is OK, say because you marked a good block bad to test bad
601 * block handling and you are done testing, or if you have
602 * accidentally marked blocks bad.
604 * Erasing factory marked bad blocks is a _bad_ idea. If the
605 * erase succeeds there is no reliable way to find them again,
606 * and attempting to program or erase bad blocks can affect
607 * the data in _other_ (good) blocks.
609 #define ALLOW_ERASE_BAD_DEBUG 0
611 #define CONFIG_MTD_NAND_ECC /* enable ECC */
612 #define CONFIG_MTD_NAND_ECC_JFFS2
614 /* bits for nand_legacy_rw() `cmd'; or together as needed */
615 #define NANDRW_READ 0x01
616 #define NANDRW_WRITE 0x00
617 #define NANDRW_JFFS2 0x02
618 #define NANDRW_JFFS2_SKIP 0x04
621 * Imports from nand_legacy.c
623 extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
624 extern int curr_device;
625 extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs,
626 size_t len, int clean);
627 extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start,
628 size_t len, size_t *retlen, u_char *buf);
629 extern void nand_print(struct nand_chip *nand);
630 extern void nand_print_bad(struct nand_chip *nand);
631 extern int nand_read_oob(struct nand_chip *nand, size_t ofs,
632 size_t len, size_t *retlen, u_char *buf);
633 extern int nand_write_oob(struct nand_chip *nand, size_t ofs,
634 size_t len, size_t *retlen, const u_char *buf);
637 int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
644 printf ("Usage:\n%s\n", cmdtp->usage);
647 if (strcmp(argv[1],"info") == 0) {
652 for (i=0; i<CFG_MAX_NAND_DEVICE; ++i) {
653 if(nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN)
654 continue; /* list only known devices */
655 printf ("Device %d: ", i);
656 nand_print(&nand_dev_desc[i]);
660 } else if (strcmp(argv[1],"device") == 0) {
661 if ((curr_device < 0) || (curr_device >= CFG_MAX_NAND_DEVICE)) {
662 puts ("\nno devices available\n");
665 printf ("\nDevice %d: ", curr_device);
666 nand_print(&nand_dev_desc[curr_device]);
669 } else if (strcmp(argv[1],"bad") == 0) {
670 if ((curr_device < 0) || (curr_device >= CFG_MAX_NAND_DEVICE)) {
671 puts ("\nno devices available\n");
674 printf ("\nDevice %d bad blocks:\n", curr_device);
675 nand_print_bad(&nand_dev_desc[curr_device]);
679 printf ("Usage:\n%s\n", cmdtp->usage);
682 if (strcmp(argv[1],"device") == 0) {
683 int dev = (int)simple_strtoul(argv[2], NULL, 10);
685 printf ("\nDevice %d: ", dev);
686 if (dev >= CFG_MAX_NAND_DEVICE) {
687 puts ("unknown device\n");
690 nand_print(&nand_dev_desc[dev]);
691 /*nand_print (dev);*/
693 if (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN) {
699 puts ("... is now current device\n");
703 else if (strcmp(argv[1],"erase") == 0 && strcmp(argv[2], "clean") == 0) {
704 struct nand_chip* nand = &nand_dev_desc[curr_device];
706 ulong size = nand->totlen;
709 printf ("\nNAND erase: device %d offset %ld, size %ld ... ",
710 curr_device, off, size);
712 ret = nand_legacy_erase (nand, off, size, 1);
714 printf("%s\n", ret ? "ERROR" : "OK");
719 printf ("Usage:\n%s\n", cmdtp->usage);
722 /* at least 4 args */
724 if (strncmp(argv[1], "read", 4) == 0 ||
725 strncmp(argv[1], "write", 5) == 0) {
726 ulong addr = simple_strtoul(argv[2], NULL, 16);
727 ulong off = simple_strtoul(argv[3], NULL, 16);
728 ulong size = simple_strtoul(argv[4], NULL, 16);
729 int cmd = (strncmp(argv[1], "read", 4) == 0) ?
730 NANDRW_READ : NANDRW_WRITE;
732 char* cmdtail = strchr(argv[1], '.');
734 if (cmdtail && !strncmp(cmdtail, ".oob", 2)) {
735 /* read out-of-band data */
736 if (cmd & NANDRW_READ) {
737 ret = nand_read_oob(nand_dev_desc + curr_device,
738 off, size, (size_t *)&total,
742 ret = nand_write_oob(nand_dev_desc + curr_device,
743 off, size, (size_t *)&total,
748 else if (cmdtail && !strncmp(cmdtail, ".jffs2", 2))
749 cmd |= NANDRW_JFFS2; /* skip bad blocks */
750 else if (cmdtail && !strncmp(cmdtail, ".jffs2s", 2)) {
751 cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
752 if (cmd & NANDRW_READ)
753 cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
756 /* need ".e" same as ".j" for compatibility with older units */
757 else if (cmdtail && !strcmp(cmdtail, ".e"))
758 cmd |= NANDRW_JFFS2; /* skip bad blocks */
760 #ifdef CFG_NAND_SKIP_BAD_DOT_I
761 /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */
762 /* ".i" for image -> read skips bad block (no 0xff) */
763 else if (cmdtail && !strcmp(cmdtail, ".i")) {
764 cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
765 if (cmd & NANDRW_READ)
766 cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
768 #endif /* CFG_NAND_SKIP_BAD_DOT_I */
770 printf ("Usage:\n%s\n", cmdtp->usage);
774 printf ("\nNAND %s: device %d offset %ld, size %ld ...\n",
775 (cmd & NANDRW_READ) ? "read" : "write",
776 curr_device, off, size);
778 ret = nand_legacy_rw(nand_dev_desc + curr_device, cmd, off, size,
779 (size_t *)&total, (u_char*)addr);
781 printf (" %d bytes %s: %s\n", total,
782 (cmd & NANDRW_READ) ? "read" : "written",
783 ret ? "ERROR" : "OK");
786 } else if (strcmp(argv[1],"erase") == 0 &&
787 (argc == 4 || strcmp("clean", argv[2]) == 0)) {
788 int clean = argc == 5;
789 ulong off = simple_strtoul(argv[2 + clean], NULL, 16);
790 ulong size = simple_strtoul(argv[3 + clean], NULL, 16);
793 printf ("\nNAND erase: device %d offset %ld, size %ld ...\n",
794 curr_device, off, size);
796 ret = nand_legacy_erase (nand_dev_desc + curr_device,
799 printf("%s\n", ret ? "ERROR" : "OK");
803 printf ("Usage:\n%s\n", cmdtp->usage);
813 "nand - legacy NAND sub-system\n",
814 "info - show available NAND devices\n"
815 "nand device [dev] - show or set current device\n"
816 "nand read[.jffs2[s]] addr off size\n"
817 "nand write[.jffs2] addr off size - read/write `size' bytes starting\n"
818 " at offset `off' to/from memory address `addr'\n"
819 "nand erase [clean] [off size] - erase `size' bytes from\n"
820 " offset `off' (entire device if not specified)\n"
821 "nand bad - show bad blocks\n"
822 "nand read.oob addr off size - read out-of-band data\n"
823 "nand write.oob addr off size - read out-of-band data\n"
826 int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
828 char *boot_device = NULL;
838 addr = CFG_LOAD_ADDR;
839 boot_device = getenv ("bootdevice");
842 addr = simple_strtoul(argv[1], NULL, 16);
843 boot_device = getenv ("bootdevice");
846 addr = simple_strtoul(argv[1], NULL, 16);
847 boot_device = argv[2];
850 addr = simple_strtoul(argv[1], NULL, 16);
851 boot_device = argv[2];
852 offset = simple_strtoul(argv[3], NULL, 16);
855 printf ("Usage:\n%s\n", cmdtp->usage);
856 SHOW_BOOT_PROGRESS (-1);
861 puts ("\n** No boot device **\n");
862 SHOW_BOOT_PROGRESS (-1);
866 dev = simple_strtoul(boot_device, &ep, 16);
868 if ((dev >= CFG_MAX_NAND_DEVICE) ||
869 (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
870 printf ("\n** Device %d not available\n", dev);
871 SHOW_BOOT_PROGRESS (-1);
875 printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
876 dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
879 if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
880 SECTORSIZE, NULL, (u_char *)addr)) {
881 printf ("** Read error on %d\n", dev);
882 SHOW_BOOT_PROGRESS (-1);
886 hdr = (image_header_t *)addr;
888 if (ntohl(hdr->ih_magic) == IH_MAGIC) {
890 print_image_hdr (hdr);
892 cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
895 printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic));
896 SHOW_BOOT_PROGRESS (-1);
900 if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ,
901 offset + SECTORSIZE, cnt, NULL,
902 (u_char *)(addr+SECTORSIZE))) {
903 printf ("** Read error on %d\n", dev);
904 SHOW_BOOT_PROGRESS (-1);
908 /* Loading ok, update default load address */
912 /* Check if we should attempt an auto-start */
913 if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
915 extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
917 local_args[0] = argv[0];
918 local_args[1] = NULL;
920 printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
922 do_bootm (cmdtp, 0, 1, local_args);
929 nboot, 4, 1, do_nandboot,
930 "nboot - boot from NAND device\n",
934 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
936 #endif /* CFG_NAND_LEGACY */