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;
182 #ifdef CFG_NAND_SELECT_DEVICE
184 * Select the chip in the board/cpu specific driver
186 board_nand_select_device(nand_info[dev].priv, dev);
192 if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 &&
193 strncmp(cmd, "dump", 4) != 0 &&
194 strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
195 strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
196 strcmp(cmd, "biterr") != 0 &&
197 strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
200 /* the following commands operate on the current device */
201 if (nand_curr_device < 0 || nand_curr_device >= CFG_MAX_NAND_DEVICE ||
202 !nand_info[nand_curr_device].name) {
203 puts("\nno devices available\n");
206 nand = &nand_info[nand_curr_device];
208 if (strcmp(cmd, "bad") == 0) {
209 printf("\nDevice %d bad blocks:\n", nand_curr_device);
210 for (off = 0; off < nand->size; off += nand->erasesize)
211 if (nand_block_isbad(nand, off))
212 printf(" %08x\n", off);
216 if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
217 nand_erase_options_t opts;
218 int clean = argc >= 3 && !strcmp("clean", argv[2]);
219 int rest_argc = argc - 2;
220 char **rest_argv = argv + 2;
221 int scrub = !strcmp(cmd, "scrub");
228 if (rest_argc == 0) {
230 printf("\nNAND %s: device %d whole chip\n",
236 arg_off_size(rest_argc, rest_argv, &off, &size,
239 if (off == 0 && size == 0)
242 printf("\nNAND %s: device %d offset 0x%x, size 0x%x\n",
243 cmd, nand_curr_device, off, size);
246 memset(&opts, 0, sizeof(opts));
254 "scrub option will erase all factory set "
257 "There is no reliable way to recover them.\n"
259 "Use this command only for testing purposes "
262 "are sure of what you are doing!\n"
263 "\nReally scrub this NAND flash? <y/N>\n"
266 if (getc() == 'y' && getc() == '\r') {
269 printf("scrub aborted\n");
273 ret = nand_erase_opts(nand, &opts);
274 printf("%s\n", ret ? "ERROR" : "OK");
276 return ret == 0 ? 0 : 1;
279 if (strncmp(cmd, "dump", 4) == 0) {
283 s = strchr(cmd, '.');
284 off = (int)simple_strtoul(argv[2], NULL, 16);
286 if (s != NULL && strcmp(s, ".oob") == 0)
287 ret = nand_dump_oob(nand, off);
289 ret = nand_dump(nand, off);
291 return ret == 0 ? 1 : 0;
296 if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {
302 addr = (ulong)simple_strtoul(argv[2], NULL, 16);
304 arg_off_size(argc - 3, argv + 3, &off, &size, nand->size);
305 if (off == 0 && size == 0)
308 read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
309 printf("\nNAND %s: device %d offset %u, size %u ... ",
310 read ? "read" : "write", nand_curr_device, off, size);
312 s = strchr(cmd, '.');
314 (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
317 nand_read_options_t opts;
318 memset(&opts, 0, sizeof(opts));
319 opts.buffer = (u_char*) addr;
323 ret = nand_read_opts(nand, &opts);
326 nand_write_options_t opts;
327 memset(&opts, 0, sizeof(opts));
328 opts.buffer = (u_char*) addr;
331 /* opts.forcejffs2 = 1; */
335 ret = nand_write_opts(nand, &opts);
337 printf("%s\n", ret ? "ERROR" : "OK");
338 return ret == 0 ? 0 : 1;
342 ret = nand_read(nand, off, &size, (u_char *)addr);
344 ret = nand_write(nand, off, &size, (u_char *)addr);
346 printf(" %d bytes %s: %s\n", size,
347 read ? "read" : "written", ret ? "ERROR" : "OK");
349 return ret == 0 ? 0 : 1;
352 if (strcmp(cmd, "markbad") == 0) {
353 addr = (ulong)simple_strtoul(argv[2], NULL, 16);
355 int ret = nand->block_markbad(nand, addr);
357 printf("block 0x%08lx successfully marked as bad\n",
361 printf("block 0x%08lx NOT marked as bad! ERROR %d\n",
366 if (strcmp(cmd, "biterr") == 0) {
371 if (strcmp(cmd, "lock") == 0) {
375 if (!strcmp("tight", argv[2]))
377 if (!strcmp("status", argv[2]))
382 ulong block_start = 0;
384 int last_status = -1;
386 struct nand_chip *nand_chip = nand->priv;
387 /* check the WP bit */
388 nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1);
389 printf("device is %swrite protected\n",
390 (nand_chip->read_byte(nand) & 0x80 ?
393 for (off = 0; off < nand->size; off += nand->oobblock) {
394 int s = nand_get_lock_status(nand, off);
396 /* print message only if status has changed
399 if (off == nand->size - nand->oobblock
400 || (s != last_status && off != 0)) {
402 printf("%08x - %08x: %8d pages %s%s%s\n",
405 (off-block_start)/nand->oobblock,
406 ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
407 ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
408 ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
414 if (!nand_lock(nand, tight)) {
415 printf ("NAND flash successfully locked\n");
417 printf ("Error locking NAND flash. \n");
424 if (strcmp(cmd, "unlock") == 0) {
429 arg_off_size(argc - 2, argv + 2, &off, &size,
433 if (!nand_unlock(nand, off, size)) {
434 printf("NAND flash successfully unlocked\n");
436 printf("Error unlocking NAND flash. "
437 "Write and erase will probably fail\n");
444 printf("Usage:\n%s\n", cmdtp->usage);
448 U_BOOT_CMD(nand, 5, 1, do_nand,
449 "nand - NAND sub-system\n",
450 "info - show available NAND devices\n"
451 "nand device [dev] - show or set current device\n"
452 "nand read[.jffs2] - addr off size\n"
453 "nand write[.jffs2] - addr off size - read/write `size' bytes starting\n"
454 " at offset `off' to/from memory address `addr'\n"
455 "nand erase [clean] [off size] - erase `size' bytes from\n"
456 " offset `off' (entire device if not specified)\n"
457 "nand bad - show bad blocks\n"
458 "nand dump[.oob] off - dump page\n"
459 "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
460 "nand markbad off - mark bad block at offset (UNSAFE)\n"
461 "nand biterr off - make a bit error at offset (UNSAFE)\n"
462 "nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
463 "nand unlock [offset] [size] - unlock section\n");
465 int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
467 char *boot_device = NULL;
471 ulong addr, cnt, offset = 0;
477 addr = CFG_LOAD_ADDR;
478 boot_device = getenv("bootdevice");
481 addr = simple_strtoul(argv[1], NULL, 16);
482 boot_device = getenv("bootdevice");
485 addr = simple_strtoul(argv[1], NULL, 16);
486 boot_device = argv[2];
489 addr = simple_strtoul(argv[1], NULL, 16);
490 boot_device = argv[2];
491 offset = simple_strtoul(argv[3], NULL, 16);
494 printf("Usage:\n%s\n", cmdtp->usage);
495 SHOW_BOOT_PROGRESS(-1);
500 puts("\n** No boot device **\n");
501 SHOW_BOOT_PROGRESS(-1);
505 dev = simple_strtoul(boot_device, &ep, 16);
507 if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) {
508 printf("\n** Device %d not available\n", dev);
509 SHOW_BOOT_PROGRESS(-1);
513 nand = &nand_info[dev];
514 printf("\nLoading from device %d: %s (offset 0x%lx)\n",
515 dev, nand->name, offset);
517 cnt = nand->oobblock;
518 r = nand_read(nand, offset, &cnt, (u_char *) addr);
520 printf("** Read error on %d\n", dev);
521 SHOW_BOOT_PROGRESS(-1);
525 hdr = (image_header_t *) addr;
527 if (ntohl(hdr->ih_magic) != IH_MAGIC) {
528 printf("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic);
529 SHOW_BOOT_PROGRESS(-1);
533 print_image_hdr(hdr);
535 cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t));
537 r = nand_read(nand, offset, &cnt, (u_char *) addr);
539 printf("** Read error on %d\n", dev);
540 SHOW_BOOT_PROGRESS(-1);
544 /* Loading ok, update default load address */
548 /* Check if we should attempt an auto-start */
549 if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
551 extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
553 local_args[0] = argv[0];
554 local_args[1] = NULL;
556 printf("Automatic boot of image at addr 0x%08lx ...\n", addr);
558 do_bootm(cmdtp, 0, 1, local_args);
564 U_BOOT_CMD(nboot, 4, 1, do_nandboot,
565 "nboot - boot from NAND device\n", "loadAddr dev\n");
568 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
570 #else /* CFG_NAND_LEGACY */
573 * Legacy NAND support - to be phased out
579 #include <watchdog.h>
581 #ifdef CONFIG_SHOW_BOOT_PROGRESS
582 # include <status_led.h>
583 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
585 # define SHOW_BOOT_PROGRESS(arg)
588 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
589 #include <linux/mtd/nand_legacy.h>
591 #include <linux/mtd/nand_ids.h>
592 #include <jffs2/jffs2.h>
595 #ifdef CONFIG_OMAP1510
596 void archflashwp(void *archdata, int wp);
599 #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
604 /* ****************** WARNING *********************
605 * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
606 * erase (or at least attempt to erase) blocks that are marked
607 * bad. This can be very handy if you are _sure_ that the block
608 * is OK, say because you marked a good block bad to test bad
609 * block handling and you are done testing, or if you have
610 * accidentally marked blocks bad.
612 * Erasing factory marked bad blocks is a _bad_ idea. If the
613 * erase succeeds there is no reliable way to find them again,
614 * and attempting to program or erase bad blocks can affect
615 * the data in _other_ (good) blocks.
617 #define ALLOW_ERASE_BAD_DEBUG 0
619 #define CONFIG_MTD_NAND_ECC /* enable ECC */
620 #define CONFIG_MTD_NAND_ECC_JFFS2
622 /* bits for nand_legacy_rw() `cmd'; or together as needed */
623 #define NANDRW_READ 0x01
624 #define NANDRW_WRITE 0x00
625 #define NANDRW_JFFS2 0x02
626 #define NANDRW_JFFS2_SKIP 0x04
629 * Imports from nand_legacy.c
631 extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
632 extern int curr_device;
633 extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs,
634 size_t len, int clean);
635 extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start,
636 size_t len, size_t *retlen, u_char *buf);
637 extern void nand_print(struct nand_chip *nand);
638 extern void nand_print_bad(struct nand_chip *nand);
639 extern int nand_read_oob(struct nand_chip *nand, size_t ofs,
640 size_t len, size_t *retlen, u_char *buf);
641 extern int nand_write_oob(struct nand_chip *nand, size_t ofs,
642 size_t len, size_t *retlen, const u_char *buf);
645 int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
652 printf ("Usage:\n%s\n", cmdtp->usage);
655 if (strcmp(argv[1],"info") == 0) {
660 for (i=0; i<CFG_MAX_NAND_DEVICE; ++i) {
661 if(nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN)
662 continue; /* list only known devices */
663 printf ("Device %d: ", i);
664 nand_print(&nand_dev_desc[i]);
668 } else if (strcmp(argv[1],"device") == 0) {
669 if ((curr_device < 0) || (curr_device >= CFG_MAX_NAND_DEVICE)) {
670 puts ("\nno devices available\n");
673 printf ("\nDevice %d: ", curr_device);
674 nand_print(&nand_dev_desc[curr_device]);
677 } else if (strcmp(argv[1],"bad") == 0) {
678 if ((curr_device < 0) || (curr_device >= CFG_MAX_NAND_DEVICE)) {
679 puts ("\nno devices available\n");
682 printf ("\nDevice %d bad blocks:\n", curr_device);
683 nand_print_bad(&nand_dev_desc[curr_device]);
687 printf ("Usage:\n%s\n", cmdtp->usage);
690 if (strcmp(argv[1],"device") == 0) {
691 int dev = (int)simple_strtoul(argv[2], NULL, 10);
693 printf ("\nDevice %d: ", dev);
694 if (dev >= CFG_MAX_NAND_DEVICE) {
695 puts ("unknown device\n");
698 nand_print(&nand_dev_desc[dev]);
699 /*nand_print (dev);*/
701 if (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN) {
707 puts ("... is now current device\n");
711 else if (strcmp(argv[1],"erase") == 0 && strcmp(argv[2], "clean") == 0) {
712 struct nand_chip* nand = &nand_dev_desc[curr_device];
714 ulong size = nand->totlen;
717 printf ("\nNAND erase: device %d offset %ld, size %ld ... ",
718 curr_device, off, size);
720 ret = nand_legacy_erase (nand, off, size, 1);
722 printf("%s\n", ret ? "ERROR" : "OK");
727 printf ("Usage:\n%s\n", cmdtp->usage);
730 /* at least 4 args */
732 if (strncmp(argv[1], "read", 4) == 0 ||
733 strncmp(argv[1], "write", 5) == 0) {
734 ulong addr = simple_strtoul(argv[2], NULL, 16);
735 ulong off = simple_strtoul(argv[3], NULL, 16);
736 ulong size = simple_strtoul(argv[4], NULL, 16);
737 int cmd = (strncmp(argv[1], "read", 4) == 0) ?
738 NANDRW_READ : NANDRW_WRITE;
740 char* cmdtail = strchr(argv[1], '.');
742 if (cmdtail && !strncmp(cmdtail, ".oob", 2)) {
743 /* read out-of-band data */
744 if (cmd & NANDRW_READ) {
745 ret = nand_read_oob(nand_dev_desc + curr_device,
746 off, size, (size_t *)&total,
750 ret = nand_write_oob(nand_dev_desc + curr_device,
751 off, size, (size_t *)&total,
756 else if (cmdtail && !strncmp(cmdtail, ".jffs2", 2))
757 cmd |= NANDRW_JFFS2; /* skip bad blocks */
758 else if (cmdtail && !strncmp(cmdtail, ".jffs2s", 2)) {
759 cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
760 if (cmd & NANDRW_READ)
761 cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
764 /* need ".e" same as ".j" for compatibility with older units */
765 else if (cmdtail && !strcmp(cmdtail, ".e"))
766 cmd |= NANDRW_JFFS2; /* skip bad blocks */
768 #ifdef CFG_NAND_SKIP_BAD_DOT_I
769 /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */
770 /* ".i" for image -> read skips bad block (no 0xff) */
771 else if (cmdtail && !strcmp(cmdtail, ".i")) {
772 cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
773 if (cmd & NANDRW_READ)
774 cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
776 #endif /* CFG_NAND_SKIP_BAD_DOT_I */
778 printf ("Usage:\n%s\n", cmdtp->usage);
782 printf ("\nNAND %s: device %d offset %ld, size %ld ...\n",
783 (cmd & NANDRW_READ) ? "read" : "write",
784 curr_device, off, size);
786 ret = nand_legacy_rw(nand_dev_desc + curr_device, cmd, off, size,
787 (size_t *)&total, (u_char*)addr);
789 printf (" %d bytes %s: %s\n", total,
790 (cmd & NANDRW_READ) ? "read" : "written",
791 ret ? "ERROR" : "OK");
794 } else if (strcmp(argv[1],"erase") == 0 &&
795 (argc == 4 || strcmp("clean", argv[2]) == 0)) {
796 int clean = argc == 5;
797 ulong off = simple_strtoul(argv[2 + clean], NULL, 16);
798 ulong size = simple_strtoul(argv[3 + clean], NULL, 16);
801 printf ("\nNAND erase: device %d offset %ld, size %ld ...\n",
802 curr_device, off, size);
804 ret = nand_legacy_erase (nand_dev_desc + curr_device,
807 printf("%s\n", ret ? "ERROR" : "OK");
811 printf ("Usage:\n%s\n", cmdtp->usage);
821 "nand - legacy NAND sub-system\n",
822 "info - show available NAND devices\n"
823 "nand device [dev] - show or set current device\n"
824 "nand read[.jffs2[s]] addr off size\n"
825 "nand write[.jffs2] addr off size - read/write `size' bytes starting\n"
826 " at offset `off' to/from memory address `addr'\n"
827 "nand erase [clean] [off size] - erase `size' bytes from\n"
828 " offset `off' (entire device if not specified)\n"
829 "nand bad - show bad blocks\n"
830 "nand read.oob addr off size - read out-of-band data\n"
831 "nand write.oob addr off size - read out-of-band data\n"
834 int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
836 char *boot_device = NULL;
846 addr = CFG_LOAD_ADDR;
847 boot_device = getenv ("bootdevice");
850 addr = simple_strtoul(argv[1], NULL, 16);
851 boot_device = getenv ("bootdevice");
854 addr = simple_strtoul(argv[1], NULL, 16);
855 boot_device = argv[2];
858 addr = simple_strtoul(argv[1], NULL, 16);
859 boot_device = argv[2];
860 offset = simple_strtoul(argv[3], NULL, 16);
863 printf ("Usage:\n%s\n", cmdtp->usage);
864 SHOW_BOOT_PROGRESS (-1);
869 puts ("\n** No boot device **\n");
870 SHOW_BOOT_PROGRESS (-1);
874 dev = simple_strtoul(boot_device, &ep, 16);
876 if ((dev >= CFG_MAX_NAND_DEVICE) ||
877 (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
878 printf ("\n** Device %d not available\n", dev);
879 SHOW_BOOT_PROGRESS (-1);
883 printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
884 dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
887 if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
888 SECTORSIZE, NULL, (u_char *)addr)) {
889 printf ("** Read error on %d\n", dev);
890 SHOW_BOOT_PROGRESS (-1);
894 hdr = (image_header_t *)addr;
896 if (ntohl(hdr->ih_magic) == IH_MAGIC) {
898 print_image_hdr (hdr);
900 cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
903 printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic));
904 SHOW_BOOT_PROGRESS (-1);
908 if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ,
909 offset + SECTORSIZE, cnt, NULL,
910 (u_char *)(addr+SECTORSIZE))) {
911 printf ("** Read error on %d\n", dev);
912 SHOW_BOOT_PROGRESS (-1);
916 /* Loading ok, update default load address */
920 /* Check if we should attempt an auto-start */
921 if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
923 extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
925 local_args[0] = argv[0];
926 local_args[1] = NULL;
928 printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
930 do_bootm (cmdtp, 0, 1, local_args);
937 nboot, 4, 1, do_nandboot,
938 "nboot - boot from NAND device\n",
942 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
944 #endif /* CFG_NAND_LEGACY */