wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1 | /* |
| 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> |
wdenk | 6d3c6d1 | 2005-04-03 22:35:21 +0000 | [diff] [blame] | 6 | * |
| 7 | * Added 16-bit nand support |
| 8 | * (C) 2004 Texas Instruments |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 12 | |
| 13 | |
| 14 | #ifndef CFG_NAND_LEGACY |
| 15 | /* |
| 16 | * |
| 17 | * New NAND support |
| 18 | * |
| 19 | */ |
| 20 | #include <common.h> |
| 21 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 22 | #if defined(CONFIG_CMD_NAND) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 23 | |
| 24 | #include <command.h> |
| 25 | #include <watchdog.h> |
| 26 | #include <malloc.h> |
| 27 | #include <asm/byteorder.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 28 | #include <jffs2/jffs2.h> |
| 29 | #include <nand.h> |
| 30 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 31 | #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 32 | |
| 33 | /* parition handling routines */ |
| 34 | int mtdparts_init(void); |
| 35 | int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); |
| 36 | int find_dev_and_part(const char *id, struct mtd_device **dev, |
| 37 | u8 *part_num, struct part_info **part); |
| 38 | #endif |
| 39 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 40 | extern nand_info_t nand_info[]; /* info for NAND chips */ |
| 41 | |
| 42 | static int nand_dump_oob(nand_info_t *nand, ulong off) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static int nand_dump(nand_info_t *nand, ulong off) |
| 48 | { |
| 49 | int i; |
| 50 | u_char *buf, *p; |
| 51 | |
| 52 | buf = malloc(nand->oobblock + nand->oobsize); |
| 53 | if (!buf) { |
| 54 | puts("No memory for page buffer\n"); |
| 55 | return 1; |
| 56 | } |
| 57 | off &= ~(nand->oobblock - 1); |
| 58 | i = nand_read_raw(nand, buf, off, nand->oobblock, nand->oobsize); |
| 59 | if (i < 0) { |
| 60 | printf("Error (%d) reading page %08x\n", i, off); |
| 61 | free(buf); |
| 62 | return 1; |
| 63 | } |
| 64 | printf("Page %08x dump:\n", off); |
| 65 | i = nand->oobblock >> 4; p = buf; |
| 66 | while (i--) { |
| 67 | printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x" |
| 68 | " %02x %02x %02x %02x %02x %02x %02x %02x\n", |
| 69 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], |
| 70 | p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); |
| 71 | p += 16; |
| 72 | } |
| 73 | puts("OOB:\n"); |
| 74 | i = nand->oobsize >> 3; |
| 75 | while (i--) { |
| 76 | printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x\n", |
| 77 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); |
| 78 | p += 8; |
| 79 | } |
| 80 | free(buf); |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | /* ------------------------------------------------------------------------- */ |
| 86 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 87 | static inline int str2long(char *p, ulong *num) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 88 | { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 89 | char *endptr; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 90 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 91 | *num = simple_strtoul(p, &endptr, 16); |
| 92 | return (*p != '\0' && *endptr == '\0') ? 1 : 0; |
| 93 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 94 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 95 | static int |
| 96 | arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size) |
| 97 | { |
| 98 | int idx = nand_curr_device; |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 99 | #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 100 | struct mtd_device *dev; |
| 101 | struct part_info *part; |
| 102 | u8 pnum; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 103 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 104 | if (argc >= 1 && !(str2long(argv[0], off))) { |
| 105 | if ((mtdparts_init() == 0) && |
| 106 | (find_dev_and_part(argv[0], &dev, &pnum, &part) == 0)) { |
| 107 | if (dev->id->type != MTD_DEV_TYPE_NAND) { |
| 108 | puts("not a NAND device\n"); |
| 109 | return -1; |
| 110 | } |
| 111 | *off = part->offset; |
| 112 | if (argc >= 2) { |
| 113 | if (!(str2long(argv[1], size))) { |
| 114 | printf("'%s' is not a number\n", argv[1]); |
| 115 | return -1; |
| 116 | } |
| 117 | if (*size > part->size) |
| 118 | *size = part->size; |
| 119 | } else { |
| 120 | *size = part->size; |
| 121 | } |
| 122 | idx = dev->id->num; |
| 123 | *nand = nand_info[idx]; |
| 124 | goto out; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 125 | } |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 126 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 127 | #endif |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 128 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 129 | if (argc >= 1) { |
| 130 | if (!(str2long(argv[0], off))) { |
| 131 | printf("'%s' is not a number\n", argv[0]); |
| 132 | return -1; |
| 133 | } |
| 134 | } else { |
| 135 | *off = 0; |
| 136 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 137 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 138 | if (argc >= 2) { |
| 139 | if (!(str2long(argv[1], size))) { |
| 140 | printf("'%s' is not a number\n", argv[1]); |
| 141 | return -1; |
| 142 | } |
| 143 | } else { |
| 144 | *size = nand->size - *off; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 147 | #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 148 | out: |
| 149 | #endif |
| 150 | printf("device %d ", idx); |
| 151 | if (*size == nand->size) |
| 152 | puts("whole chip\n"); |
| 153 | else |
| 154 | printf("offset 0x%x, size 0x%x\n", *off, *size); |
| 155 | return 0; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 159 | { |
| 160 | int i, dev, ret; |
| 161 | ulong addr, off, size; |
| 162 | char *cmd, *s; |
| 163 | nand_info_t *nand; |
Matthias Fuchs | d42fff2 | 2007-09-12 12:36:53 +0200 | [diff] [blame] | 164 | #ifdef CFG_NAND_QUIET |
| 165 | int quiet = CFG_NAND_QUIET; |
| 166 | #else |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 167 | int quiet = 0; |
Matthias Fuchs | d42fff2 | 2007-09-12 12:36:53 +0200 | [diff] [blame] | 168 | #endif |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 169 | const char *quiet_str = getenv("quiet"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 170 | |
| 171 | /* at least two arguments please */ |
| 172 | if (argc < 2) |
| 173 | goto usage; |
| 174 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 175 | if (quiet_str) |
| 176 | quiet = simple_strtoul(quiet_str, NULL, 0) != 0; |
| 177 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 178 | cmd = argv[1]; |
| 179 | |
| 180 | if (strcmp(cmd, "info") == 0) { |
| 181 | |
| 182 | putc('\n'); |
| 183 | for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) { |
| 184 | if (nand_info[i].name) |
| 185 | printf("Device %d: %s, sector size %lu KiB\n", |
| 186 | i, nand_info[i].name, |
| 187 | nand_info[i].erasesize >> 10); |
| 188 | } |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | if (strcmp(cmd, "device") == 0) { |
| 193 | |
| 194 | if (argc < 3) { |
| 195 | if ((nand_curr_device < 0) || |
| 196 | (nand_curr_device >= CFG_MAX_NAND_DEVICE)) |
| 197 | puts("\nno devices available\n"); |
| 198 | else |
| 199 | printf("\nDevice %d: %s\n", nand_curr_device, |
| 200 | nand_info[nand_curr_device].name); |
| 201 | return 0; |
| 202 | } |
| 203 | dev = (int)simple_strtoul(argv[2], NULL, 10); |
| 204 | if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) { |
| 205 | puts("No such device\n"); |
| 206 | return 1; |
| 207 | } |
| 208 | printf("Device %d: %s", dev, nand_info[dev].name); |
| 209 | puts("... is now current device\n"); |
| 210 | nand_curr_device = dev; |
Stefan Roese | 3cdd3fd | 2006-10-20 14:28:52 +0200 | [diff] [blame] | 211 | |
| 212 | #ifdef CFG_NAND_SELECT_DEVICE |
| 213 | /* |
| 214 | * Select the chip in the board/cpu specific driver |
| 215 | */ |
| 216 | board_nand_select_device(nand_info[dev].priv, dev); |
| 217 | #endif |
| 218 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 && |
| 223 | strncmp(cmd, "dump", 4) != 0 && |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 224 | strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 && |
| 225 | strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 && |
| 226 | strcmp(cmd, "biterr") != 0 && |
| 227 | strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 ) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 228 | goto usage; |
| 229 | |
| 230 | /* the following commands operate on the current device */ |
| 231 | if (nand_curr_device < 0 || nand_curr_device >= CFG_MAX_NAND_DEVICE || |
| 232 | !nand_info[nand_curr_device].name) { |
| 233 | puts("\nno devices available\n"); |
| 234 | return 1; |
| 235 | } |
| 236 | nand = &nand_info[nand_curr_device]; |
| 237 | |
| 238 | if (strcmp(cmd, "bad") == 0) { |
| 239 | printf("\nDevice %d bad blocks:\n", nand_curr_device); |
| 240 | for (off = 0; off < nand->size; off += nand->erasesize) |
| 241 | if (nand_block_isbad(nand, off)) |
| 242 | printf(" %08x\n", off); |
| 243 | return 0; |
| 244 | } |
| 245 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 246 | /* |
| 247 | * Syntax is: |
| 248 | * 0 1 2 3 4 |
| 249 | * nand erase [clean] [off size] |
| 250 | */ |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 251 | if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) { |
| 252 | nand_erase_options_t opts; |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 253 | /* "clean" at index 2 means request to write cleanmarker */ |
| 254 | int clean = argc > 2 && !strcmp("clean", argv[2]); |
| 255 | int o = clean ? 3 : 2; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 256 | int scrub = !strcmp(cmd, "scrub"); |
| 257 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 258 | printf("\nNAND %s: ", scrub ? "scrub" : "erase"); |
| 259 | /* skip first two or three arguments, look for offset and size */ |
| 260 | if (arg_off_size(argc - o, argv + o, nand, &off, &size) != 0) |
| 261 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 262 | |
| 263 | memset(&opts, 0, sizeof(opts)); |
| 264 | opts.offset = off; |
| 265 | opts.length = size; |
| 266 | opts.jffs2 = clean; |
| 267 | opts.quiet = quiet; |
| 268 | |
| 269 | if (scrub) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 270 | puts("Warning: " |
| 271 | "scrub option will erase all factory set " |
| 272 | "bad blocks!\n" |
| 273 | " " |
| 274 | "There is no reliable way to recover them.\n" |
| 275 | " " |
| 276 | "Use this command only for testing purposes " |
| 277 | "if you\n" |
| 278 | " " |
| 279 | "are sure of what you are doing!\n" |
| 280 | "\nReally scrub this NAND flash? <y/N>\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 281 | |
| 282 | if (getc() == 'y' && getc() == '\r') { |
| 283 | opts.scrub = 1; |
| 284 | } else { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 285 | puts("scrub aborted\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 286 | return -1; |
| 287 | } |
| 288 | } |
| 289 | ret = nand_erase_opts(nand, &opts); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 290 | printf("%s\n", ret ? "ERROR" : "OK"); |
| 291 | |
| 292 | return ret == 0 ? 0 : 1; |
| 293 | } |
| 294 | |
| 295 | if (strncmp(cmd, "dump", 4) == 0) { |
| 296 | if (argc < 3) |
| 297 | goto usage; |
| 298 | |
| 299 | s = strchr(cmd, '.'); |
| 300 | off = (int)simple_strtoul(argv[2], NULL, 16); |
| 301 | |
| 302 | if (s != NULL && strcmp(s, ".oob") == 0) |
| 303 | ret = nand_dump_oob(nand, off); |
| 304 | else |
| 305 | ret = nand_dump(nand, off); |
| 306 | |
| 307 | return ret == 0 ? 1 : 0; |
| 308 | |
| 309 | } |
| 310 | |
| 311 | /* read write */ |
| 312 | if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) { |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 313 | int read; |
| 314 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 315 | if (argc < 4) |
| 316 | goto usage; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 317 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 318 | addr = (ulong)simple_strtoul(argv[2], NULL, 16); |
| 319 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 320 | read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 321 | printf("\nNAND %s: ", read ? "read" : "write"); |
| 322 | if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0) |
| 323 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 324 | |
| 325 | s = strchr(cmd, '.'); |
| 326 | if (s != NULL && |
| 327 | (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) { |
| 328 | if (read) { |
| 329 | /* read */ |
| 330 | nand_read_options_t opts; |
| 331 | memset(&opts, 0, sizeof(opts)); |
| 332 | opts.buffer = (u_char*) addr; |
| 333 | opts.length = size; |
| 334 | opts.offset = off; |
| 335 | opts.quiet = quiet; |
| 336 | ret = nand_read_opts(nand, &opts); |
| 337 | } else { |
| 338 | /* write */ |
| 339 | nand_write_options_t opts; |
| 340 | memset(&opts, 0, sizeof(opts)); |
| 341 | opts.buffer = (u_char*) addr; |
| 342 | opts.length = size; |
| 343 | opts.offset = off; |
| 344 | /* opts.forcejffs2 = 1; */ |
| 345 | opts.pad = 1; |
| 346 | opts.blockalign = 1; |
| 347 | opts.quiet = quiet; |
| 348 | ret = nand_write_opts(nand, &opts); |
| 349 | } |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 350 | } else { |
| 351 | if (read) |
| 352 | ret = nand_read(nand, off, &size, (u_char *)addr); |
| 353 | else |
| 354 | ret = nand_write(nand, off, &size, (u_char *)addr); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 355 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 356 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 357 | printf(" %d bytes %s: %s\n", size, |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 358 | read ? "read" : "written", ret ? "ERROR" : "OK"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 359 | |
| 360 | return ret == 0 ? 0 : 1; |
| 361 | } |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 362 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 363 | if (strcmp(cmd, "markbad") == 0) { |
| 364 | addr = (ulong)simple_strtoul(argv[2], NULL, 16); |
| 365 | |
| 366 | int ret = nand->block_markbad(nand, addr); |
| 367 | if (ret == 0) { |
| 368 | printf("block 0x%08lx successfully marked as bad\n", |
| 369 | (ulong) addr); |
| 370 | return 0; |
| 371 | } else { |
| 372 | printf("block 0x%08lx NOT marked as bad! ERROR %d\n", |
| 373 | (ulong) addr, ret); |
| 374 | } |
| 375 | return 1; |
| 376 | } |
| 377 | if (strcmp(cmd, "biterr") == 0) { |
| 378 | /* todo */ |
| 379 | return 1; |
| 380 | } |
| 381 | |
| 382 | if (strcmp(cmd, "lock") == 0) { |
| 383 | int tight = 0; |
| 384 | int status = 0; |
| 385 | if (argc == 3) { |
| 386 | if (!strcmp("tight", argv[2])) |
| 387 | tight = 1; |
| 388 | if (!strcmp("status", argv[2])) |
| 389 | status = 1; |
| 390 | } |
| 391 | |
| 392 | if (status) { |
| 393 | ulong block_start = 0; |
| 394 | ulong off; |
| 395 | int last_status = -1; |
| 396 | |
| 397 | struct nand_chip *nand_chip = nand->priv; |
| 398 | /* check the WP bit */ |
| 399 | nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1); |
| 400 | printf("device is %swrite protected\n", |
| 401 | (nand_chip->read_byte(nand) & 0x80 ? |
| 402 | "NOT " : "" ) ); |
| 403 | |
| 404 | for (off = 0; off < nand->size; off += nand->oobblock) { |
| 405 | int s = nand_get_lock_status(nand, off); |
| 406 | |
| 407 | /* print message only if status has changed |
| 408 | * or at end of chip |
| 409 | */ |
| 410 | if (off == nand->size - nand->oobblock |
| 411 | || (s != last_status && off != 0)) { |
| 412 | |
| 413 | printf("%08x - %08x: %8d pages %s%s%s\n", |
| 414 | block_start, |
| 415 | off-1, |
| 416 | (off-block_start)/nand->oobblock, |
| 417 | ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""), |
| 418 | ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""), |
| 419 | ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : "")); |
| 420 | } |
| 421 | |
| 422 | last_status = s; |
| 423 | } |
| 424 | } else { |
| 425 | if (!nand_lock(nand, tight)) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 426 | puts("NAND flash successfully locked\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 427 | } else { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 428 | puts("Error locking NAND flash\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 429 | return 1; |
| 430 | } |
| 431 | } |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | if (strcmp(cmd, "unlock") == 0) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 436 | if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0) |
| 437 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 438 | |
| 439 | if (!nand_unlock(nand, off, size)) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 440 | puts("NAND flash successfully unlocked\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 441 | } else { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 442 | puts("Error unlocking NAND flash, " |
| 443 | "write and erase will probably fail\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 444 | return 1; |
| 445 | } |
| 446 | return 0; |
| 447 | } |
| 448 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 449 | usage: |
| 450 | printf("Usage:\n%s\n", cmdtp->usage); |
| 451 | return 1; |
| 452 | } |
| 453 | |
| 454 | U_BOOT_CMD(nand, 5, 1, do_nand, |
| 455 | "nand - NAND sub-system\n", |
| 456 | "info - show available NAND devices\n" |
| 457 | "nand device [dev] - show or set current device\n" |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 458 | "nand read[.jffs2] - addr off|partition size\n" |
Matthias Fuchs | 82714b9 | 2007-09-11 17:04:00 +0200 | [diff] [blame] | 459 | "nand write[.jffs2] - addr off|partition size - read/write `size' bytes starting\n" |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 460 | " at offset `off' to/from memory address `addr'\n" |
| 461 | "nand erase [clean] [off size] - erase `size' bytes from\n" |
| 462 | " offset `off' (entire device if not specified)\n" |
| 463 | "nand bad - show bad blocks\n" |
| 464 | "nand dump[.oob] off - dump page\n" |
| 465 | "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n" |
| 466 | "nand markbad off - mark bad block at offset (UNSAFE)\n" |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 467 | "nand biterr off - make a bit error at offset (UNSAFE)\n" |
| 468 | "nand lock [tight] [status] - bring nand to lock state or display locked pages\n" |
| 469 | "nand unlock [offset] [size] - unlock section\n"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 470 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 471 | static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, |
| 472 | ulong offset, ulong addr, char *cmd) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 473 | { |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 474 | int r; |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 475 | char *ep, *s; |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 476 | ulong cnt; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 477 | image_header_t *hdr; |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 478 | int jffs2 = 0; |
| 479 | |
| 480 | s = strchr(cmd, '.'); |
| 481 | if (s != NULL && |
| 482 | (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) |
| 483 | jffs2 = 1; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 484 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 485 | printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 486 | |
| 487 | cnt = nand->oobblock; |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 488 | if (jffs2) { |
| 489 | nand_read_options_t opts; |
| 490 | memset(&opts, 0, sizeof(opts)); |
| 491 | opts.buffer = (u_char*) addr; |
| 492 | opts.length = cnt; |
| 493 | opts.offset = offset; |
| 494 | opts.quiet = 1; |
| 495 | r = nand_read_opts(nand, &opts); |
| 496 | } else { |
| 497 | r = nand_read(nand, offset, &cnt, (u_char *) addr); |
| 498 | } |
| 499 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 500 | if (r) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 501 | puts("** Read error\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 502 | show_boot_progress (-56); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 503 | return 1; |
| 504 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 505 | show_boot_progress (56); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 506 | |
| 507 | hdr = (image_header_t *) addr; |
| 508 | |
| 509 | if (ntohl(hdr->ih_magic) != IH_MAGIC) { |
| 510 | printf("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 511 | show_boot_progress (-57); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 512 | return 1; |
| 513 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 514 | show_boot_progress (57); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 515 | |
| 516 | print_image_hdr(hdr); |
| 517 | |
| 518 | cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t)); |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 519 | if (jffs2) { |
| 520 | nand_read_options_t opts; |
| 521 | memset(&opts, 0, sizeof(opts)); |
| 522 | opts.buffer = (u_char*) addr; |
| 523 | opts.length = cnt; |
| 524 | opts.offset = offset; |
| 525 | opts.quiet = 1; |
| 526 | r = nand_read_opts(nand, &opts); |
| 527 | } else { |
| 528 | r = nand_read(nand, offset, &cnt, (u_char *) addr); |
| 529 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 530 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 531 | if (r) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 532 | puts("** Read error\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 533 | show_boot_progress (-58); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 534 | return 1; |
| 535 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 536 | show_boot_progress (58); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 537 | |
| 538 | /* Loading ok, update default load address */ |
| 539 | |
| 540 | load_addr = addr; |
| 541 | |
| 542 | /* Check if we should attempt an auto-start */ |
| 543 | if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) { |
| 544 | char *local_args[2]; |
| 545 | extern int do_bootm(cmd_tbl_t *, int, int, char *[]); |
| 546 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 547 | local_args[0] = cmd; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 548 | local_args[1] = NULL; |
| 549 | |
| 550 | printf("Automatic boot of image at addr 0x%08lx ...\n", addr); |
| 551 | |
| 552 | do_bootm(cmdtp, 0, 1, local_args); |
| 553 | return 1; |
| 554 | } |
| 555 | return 0; |
| 556 | } |
| 557 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 558 | int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 559 | { |
| 560 | char *boot_device = NULL; |
| 561 | int idx; |
| 562 | ulong addr, offset = 0; |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 563 | #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 564 | struct mtd_device *dev; |
| 565 | struct part_info *part; |
| 566 | u8 pnum; |
| 567 | |
| 568 | if (argc >= 2) { |
| 569 | char *p = (argc == 2) ? argv[1] : argv[2]; |
| 570 | if (!(str2long(p, &addr)) && (mtdparts_init() == 0) && |
| 571 | (find_dev_and_part(p, &dev, &pnum, &part) == 0)) { |
| 572 | if (dev->id->type != MTD_DEV_TYPE_NAND) { |
| 573 | puts("Not a NAND device\n"); |
| 574 | return 1; |
| 575 | } |
| 576 | if (argc > 3) |
| 577 | goto usage; |
| 578 | if (argc == 3) |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 579 | addr = simple_strtoul(argv[1], NULL, 16); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 580 | else |
| 581 | addr = CFG_LOAD_ADDR; |
| 582 | return nand_load_image(cmdtp, &nand_info[dev->id->num], |
| 583 | part->offset, addr, argv[0]); |
| 584 | } |
| 585 | } |
| 586 | #endif |
| 587 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 588 | show_boot_progress(52); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 589 | switch (argc) { |
| 590 | case 1: |
| 591 | addr = CFG_LOAD_ADDR; |
| 592 | boot_device = getenv("bootdevice"); |
| 593 | break; |
| 594 | case 2: |
| 595 | addr = simple_strtoul(argv[1], NULL, 16); |
| 596 | boot_device = getenv("bootdevice"); |
| 597 | break; |
| 598 | case 3: |
| 599 | addr = simple_strtoul(argv[1], NULL, 16); |
| 600 | boot_device = argv[2]; |
| 601 | break; |
| 602 | case 4: |
| 603 | addr = simple_strtoul(argv[1], NULL, 16); |
| 604 | boot_device = argv[2]; |
| 605 | offset = simple_strtoul(argv[3], NULL, 16); |
| 606 | break; |
| 607 | default: |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 608 | #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 609 | usage: |
| 610 | #endif |
| 611 | printf("Usage:\n%s\n", cmdtp->usage); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 612 | show_boot_progress(-53); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 613 | return 1; |
| 614 | } |
| 615 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 616 | show_boot_progress(53); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 617 | if (!boot_device) { |
| 618 | puts("\n** No boot device **\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 619 | show_boot_progress(-54); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 620 | return 1; |
| 621 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 622 | show_boot_progress(54); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 623 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 624 | idx = simple_strtoul(boot_device, NULL, 16); |
| 625 | |
| 626 | if (idx < 0 || idx >= CFG_MAX_NAND_DEVICE || !nand_info[idx].name) { |
| 627 | printf("\n** Device %d not available\n", idx); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 628 | show_boot_progress(-55); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 629 | return 1; |
| 630 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 631 | show_boot_progress(55); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 632 | |
| 633 | return nand_load_image(cmdtp, &nand_info[idx], offset, addr, argv[0]); |
| 634 | } |
| 635 | |
| 636 | U_BOOT_CMD(nboot, 4, 1, do_nandboot, |
| 637 | "nboot - boot from NAND device\n", |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 638 | "[.jffs2] [partition] | [[[loadAddr] dev] offset]\n"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 639 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 640 | #endif |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 641 | |
| 642 | #else /* CFG_NAND_LEGACY */ |
| 643 | /* |
| 644 | * |
| 645 | * Legacy NAND support - to be phased out |
| 646 | * |
| 647 | */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 648 | #include <command.h> |
| 649 | #include <malloc.h> |
| 650 | #include <asm/io.h> |
wdenk | 145d2c1 | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 651 | #include <watchdog.h> |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 652 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 653 | #ifdef CONFIG_show_boot_progress |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 654 | # include <status_led.h> |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 655 | # define show_boot_progress(arg) show_boot_progress(arg) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 656 | #else |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 657 | # define show_boot_progress(arg) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 658 | #endif |
| 659 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 660 | #if defined(CONFIG_CMD_NAND) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 661 | #include <linux/mtd/nand_legacy.h> |
| 662 | #if 0 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 663 | #include <linux/mtd/nand_ids.h> |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 664 | #include <jffs2/jffs2.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 665 | #endif |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 666 | |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 667 | #ifdef CONFIG_OMAP1510 |
| 668 | void archflashwp(void *archdata, int wp); |
| 669 | #endif |
| 670 | |
| 671 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) |
| 672 | |
wdenk | 934c4f8 | 2003-09-11 19:48:06 +0000 | [diff] [blame] | 673 | #undef NAND_DEBUG |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 674 | #undef PSYCHO_DEBUG |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 675 | |
| 676 | /* ****************** WARNING ********************* |
| 677 | * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will |
| 678 | * erase (or at least attempt to erase) blocks that are marked |
| 679 | * bad. This can be very handy if you are _sure_ that the block |
| 680 | * is OK, say because you marked a good block bad to test bad |
| 681 | * block handling and you are done testing, or if you have |
| 682 | * accidentally marked blocks bad. |
| 683 | * |
| 684 | * Erasing factory marked bad blocks is a _bad_ idea. If the |
| 685 | * erase succeeds there is no reliable way to find them again, |
| 686 | * and attempting to program or erase bad blocks can affect |
| 687 | * the data in _other_ (good) blocks. |
| 688 | */ |
| 689 | #define ALLOW_ERASE_BAD_DEBUG 0 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 690 | |
| 691 | #define CONFIG_MTD_NAND_ECC /* enable ECC */ |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 692 | #define CONFIG_MTD_NAND_ECC_JFFS2 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 693 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 694 | /* bits for nand_legacy_rw() `cmd'; or together as needed */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 695 | #define NANDRW_READ 0x01 |
| 696 | #define NANDRW_WRITE 0x00 |
| 697 | #define NANDRW_JFFS2 0x02 |
wdenk | 145d2c1 | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 698 | #define NANDRW_JFFS2_SKIP 0x04 |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 699 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 700 | /* |
| 701 | * Imports from nand_legacy.c |
| 702 | */ |
| 703 | extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; |
| 704 | extern int curr_device; |
| 705 | extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, |
| 706 | size_t len, int clean); |
| 707 | extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start, |
| 708 | size_t len, size_t *retlen, u_char *buf); |
| 709 | extern void nand_print(struct nand_chip *nand); |
| 710 | extern void nand_print_bad(struct nand_chip *nand); |
| 711 | extern int nand_read_oob(struct nand_chip *nand, size_t ofs, |
| 712 | size_t len, size_t *retlen, u_char *buf); |
| 713 | extern int nand_write_oob(struct nand_chip *nand, size_t ofs, |
| 714 | size_t len, size_t *retlen, const u_char *buf); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 715 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 716 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 717 | int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 718 | { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 719 | int rcode = 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 720 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 721 | switch (argc) { |
| 722 | case 0: |
| 723 | case 1: |
| 724 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 725 | return 1; |
| 726 | case 2: |
| 727 | if (strcmp (argv[1], "info") == 0) { |
| 728 | int i; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 729 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 730 | putc ('\n'); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 731 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 732 | for (i = 0; i < CFG_MAX_NAND_DEVICE; ++i) { |
| 733 | if (nand_dev_desc[i].ChipID == |
| 734 | NAND_ChipID_UNKNOWN) |
| 735 | continue; /* list only known devices */ |
| 736 | printf ("Device %d: ", i); |
| 737 | nand_print (&nand_dev_desc[i]); |
| 738 | } |
| 739 | return 0; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 740 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 741 | } else if (strcmp (argv[1], "device") == 0) { |
| 742 | if ((curr_device < 0) |
| 743 | || (curr_device >= CFG_MAX_NAND_DEVICE)) { |
| 744 | puts ("\nno devices available\n"); |
| 745 | return 1; |
| 746 | } |
| 747 | printf ("\nDevice %d: ", curr_device); |
| 748 | nand_print (&nand_dev_desc[curr_device]); |
| 749 | return 0; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 750 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 751 | } else if (strcmp (argv[1], "bad") == 0) { |
| 752 | if ((curr_device < 0) |
| 753 | || (curr_device >= CFG_MAX_NAND_DEVICE)) { |
| 754 | puts ("\nno devices available\n"); |
| 755 | return 1; |
| 756 | } |
| 757 | printf ("\nDevice %d bad blocks:\n", curr_device); |
| 758 | nand_print_bad (&nand_dev_desc[curr_device]); |
| 759 | return 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 760 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 761 | } |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 762 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 763 | return 1; |
| 764 | case 3: |
| 765 | if (strcmp (argv[1], "device") == 0) { |
| 766 | int dev = (int) simple_strtoul (argv[2], NULL, 10); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 767 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 768 | printf ("\nDevice %d: ", dev); |
| 769 | if (dev >= CFG_MAX_NAND_DEVICE) { |
| 770 | puts ("unknown device\n"); |
| 771 | return 1; |
| 772 | } |
| 773 | nand_print (&nand_dev_desc[dev]); |
| 774 | /*nand_print (dev); */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 775 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 776 | if (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN) { |
| 777 | return 1; |
| 778 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 779 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 780 | curr_device = dev; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 781 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 782 | puts ("... is now current device\n"); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 783 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 784 | return 0; |
| 785 | } else if (strcmp (argv[1], "erase") == 0 |
| 786 | && strcmp (argv[2], "clean") == 0) { |
| 787 | struct nand_chip *nand = &nand_dev_desc[curr_device]; |
| 788 | ulong off = 0; |
| 789 | ulong size = nand->totlen; |
| 790 | int ret; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 791 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 792 | printf ("\nNAND erase: device %d offset %ld, size %ld ... ", curr_device, off, size); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 793 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 794 | ret = nand_legacy_erase (nand, off, size, 1); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 795 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 796 | printf ("%s\n", ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 797 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 798 | return ret; |
| 799 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 800 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 801 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 802 | return 1; |
| 803 | default: |
| 804 | /* at least 4 args */ |
| 805 | |
| 806 | if (strncmp (argv[1], "read", 4) == 0 || |
| 807 | strncmp (argv[1], "write", 5) == 0) { |
| 808 | ulong addr = simple_strtoul (argv[2], NULL, 16); |
| 809 | ulong off = simple_strtoul (argv[3], NULL, 16); |
| 810 | ulong size = simple_strtoul (argv[4], NULL, 16); |
| 811 | int cmd = (strncmp (argv[1], "read", 4) == 0) ? |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 812 | NANDRW_READ : NANDRW_WRITE; |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 813 | int ret, total; |
| 814 | char *cmdtail = strchr (argv[1], '.'); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 815 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 816 | if (cmdtail && !strncmp (cmdtail, ".oob", 2)) { |
| 817 | /* read out-of-band data */ |
| 818 | if (cmd & NANDRW_READ) { |
| 819 | ret = nand_read_oob (nand_dev_desc + curr_device, |
| 820 | off, size, (size_t *) & total, |
| 821 | (u_char *) addr); |
| 822 | } else { |
| 823 | ret = nand_write_oob (nand_dev_desc + curr_device, |
| 824 | off, size, (size_t *) & total, |
| 825 | (u_char *) addr); |
| 826 | } |
| 827 | return ret; |
| 828 | } else if (cmdtail && !strncmp (cmdtail, ".jffs2", 2)) |
| 829 | cmd |= NANDRW_JFFS2; /* skip bad blocks */ |
| 830 | else if (cmdtail && !strncmp (cmdtail, ".jffs2s", 2)) { |
| 831 | cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */ |
| 832 | if (cmd & NANDRW_READ) |
| 833 | cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 834 | } |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 835 | #ifdef SXNI855T |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 836 | /* need ".e" same as ".j" for compatibility with older units */ |
| 837 | else if (cmdtail && !strcmp (cmdtail, ".e")) |
| 838 | cmd |= NANDRW_JFFS2; /* skip bad blocks */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 839 | #endif |
stroese | 317cbe6 | 2004-12-16 17:45:46 +0000 | [diff] [blame] | 840 | #ifdef CFG_NAND_SKIP_BAD_DOT_I |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 841 | /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */ |
| 842 | /* ".i" for image -> read skips bad block (no 0xff) */ |
| 843 | else if (cmdtail && !strcmp (cmdtail, ".i")) { |
| 844 | cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */ |
| 845 | if (cmd & NANDRW_READ) |
| 846 | cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */ |
| 847 | } |
stroese | 317cbe6 | 2004-12-16 17:45:46 +0000 | [diff] [blame] | 848 | #endif /* CFG_NAND_SKIP_BAD_DOT_I */ |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 849 | else if (cmdtail) { |
| 850 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 851 | return 1; |
| 852 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 853 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 854 | printf ("\nNAND %s: device %d offset %ld, size %ld ...\n", |
| 855 | (cmd & NANDRW_READ) ? "read" : "write", |
| 856 | curr_device, off, size); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 857 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 858 | ret = nand_legacy_rw (nand_dev_desc + curr_device, |
| 859 | cmd, off, size, |
| 860 | (size_t *) & total, |
| 861 | (u_char *) addr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 862 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 863 | printf (" %d bytes %s: %s\n", total, |
| 864 | (cmd & NANDRW_READ) ? "read" : "written", |
| 865 | ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 866 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 867 | return ret; |
| 868 | } else if (strcmp (argv[1], "erase") == 0 && |
| 869 | (argc == 4 || strcmp ("clean", argv[2]) == 0)) { |
| 870 | int clean = argc == 5; |
| 871 | ulong off = |
| 872 | simple_strtoul (argv[2 + clean], NULL, 16); |
| 873 | ulong size = |
| 874 | simple_strtoul (argv[3 + clean], NULL, 16); |
| 875 | int ret; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 876 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 877 | printf ("\nNAND erase: device %d offset %ld, size %ld ...\n", |
| 878 | curr_device, off, size); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 879 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 880 | ret = nand_legacy_erase (nand_dev_desc + curr_device, |
| 881 | off, size, clean); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 882 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 883 | printf ("%s\n", ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 884 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 885 | return ret; |
| 886 | } else { |
| 887 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 888 | rcode = 1; |
| 889 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 890 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 891 | return rcode; |
| 892 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 893 | } |
| 894 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 895 | U_BOOT_CMD( |
| 896 | nand, 5, 1, do_nand, |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 897 | "nand - legacy NAND sub-system\n", |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 898 | "info - show available NAND devices\n" |
| 899 | "nand device [dev] - show or set current device\n" |
wdenk | 145d2c1 | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 900 | "nand read[.jffs2[s]] addr off size\n" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 901 | "nand write[.jffs2] addr off size - read/write `size' bytes starting\n" |
| 902 | " at offset `off' to/from memory address `addr'\n" |
| 903 | "nand erase [clean] [off size] - erase `size' bytes from\n" |
| 904 | " offset `off' (entire device if not specified)\n" |
| 905 | "nand bad - show bad blocks\n" |
| 906 | "nand read.oob addr off size - read out-of-band data\n" |
| 907 | "nand write.oob addr off size - read out-of-band data\n" |
| 908 | ); |
| 909 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 910 | int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 911 | { |
| 912 | char *boot_device = NULL; |
| 913 | char *ep; |
| 914 | int dev; |
| 915 | ulong cnt; |
| 916 | ulong addr; |
| 917 | ulong offset = 0; |
| 918 | image_header_t *hdr; |
| 919 | int rcode = 0; |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 920 | show_boot_progress (52); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 921 | switch (argc) { |
| 922 | case 1: |
| 923 | addr = CFG_LOAD_ADDR; |
| 924 | boot_device = getenv ("bootdevice"); |
| 925 | break; |
| 926 | case 2: |
| 927 | addr = simple_strtoul(argv[1], NULL, 16); |
| 928 | boot_device = getenv ("bootdevice"); |
| 929 | break; |
| 930 | case 3: |
| 931 | addr = simple_strtoul(argv[1], NULL, 16); |
| 932 | boot_device = argv[2]; |
| 933 | break; |
| 934 | case 4: |
| 935 | addr = simple_strtoul(argv[1], NULL, 16); |
| 936 | boot_device = argv[2]; |
| 937 | offset = simple_strtoul(argv[3], NULL, 16); |
| 938 | break; |
| 939 | default: |
| 940 | printf ("Usage:\n%s\n", cmdtp->usage); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 941 | show_boot_progress (-53); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 942 | return 1; |
| 943 | } |
| 944 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 945 | show_boot_progress (53); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 946 | if (!boot_device) { |
| 947 | puts ("\n** No boot device **\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 948 | show_boot_progress (-54); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 949 | return 1; |
| 950 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 951 | show_boot_progress (54); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 952 | |
| 953 | dev = simple_strtoul(boot_device, &ep, 16); |
| 954 | |
| 955 | if ((dev >= CFG_MAX_NAND_DEVICE) || |
| 956 | (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) { |
| 957 | printf ("\n** Device %d not available\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 958 | show_boot_progress (-55); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 959 | return 1; |
| 960 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 961 | show_boot_progress (55); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 962 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 963 | printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n", |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 964 | dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR, |
| 965 | offset); |
| 966 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 967 | if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset, |
| 968 | SECTORSIZE, NULL, (u_char *)addr)) { |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 969 | printf ("** Read error on %d\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 970 | show_boot_progress (-56); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 971 | return 1; |
| 972 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 973 | show_boot_progress (56); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 974 | |
| 975 | hdr = (image_header_t *)addr; |
| 976 | |
| 977 | if (ntohl(hdr->ih_magic) == IH_MAGIC) { |
| 978 | |
| 979 | print_image_hdr (hdr); |
| 980 | |
| 981 | cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t)); |
| 982 | cnt -= SECTORSIZE; |
| 983 | } else { |
Wolfgang Denk | b6929f9 | 2006-03-12 01:59:35 +0100 | [diff] [blame] | 984 | printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic)); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 985 | show_boot_progress (-57); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 986 | return 1; |
| 987 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 988 | show_boot_progress (57); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 989 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 990 | if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, |
| 991 | offset + SECTORSIZE, cnt, NULL, |
| 992 | (u_char *)(addr+SECTORSIZE))) { |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 993 | printf ("** Read error on %d\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 994 | show_boot_progress (-58); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 995 | return 1; |
| 996 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 997 | show_boot_progress (58); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 998 | |
| 999 | /* Loading ok, update default load address */ |
| 1000 | |
| 1001 | load_addr = addr; |
| 1002 | |
| 1003 | /* Check if we should attempt an auto-start */ |
| 1004 | if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) { |
| 1005 | char *local_args[2]; |
| 1006 | extern int do_bootm (cmd_tbl_t *, int, int, char *[]); |
| 1007 | |
| 1008 | local_args[0] = argv[0]; |
| 1009 | local_args[1] = NULL; |
| 1010 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 1011 | printf ("Automatic boot of image at addr 0x%08lx ...\n", addr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1012 | |
| 1013 | do_bootm (cmdtp, 0, 1, local_args); |
| 1014 | rcode = 1; |
| 1015 | } |
| 1016 | return rcode; |
| 1017 | } |
| 1018 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1019 | U_BOOT_CMD( |
| 1020 | nboot, 4, 1, do_nandboot, |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 1021 | "nboot - boot from NAND device\n", |
| 1022 | "loadAddr dev\n" |
| 1023 | ); |
| 1024 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 1025 | #endif |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1026 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 1027 | #endif /* CFG_NAND_LEGACY */ |