wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * Memory Functions |
| 26 | * |
| 27 | * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
| 31 | #include <command.h> |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 32 | #if defined(CONFIG_CMD_MMC) |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 33 | #include <mmc.h> |
| 34 | #endif |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 35 | #ifdef CONFIG_HAS_DATAFLASH |
| 36 | #include <dataflash.h> |
| 37 | #endif |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 38 | #include <watchdog.h> |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 39 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 40 | #if defined(CONFIG_CMD_MEMORY) \ |
Jon Loeliger | 65c450b | 2007-06-11 19:01:54 -0500 | [diff] [blame] | 41 | || defined(CONFIG_CMD_I2C) \ |
| 42 | || defined(CONFIG_CMD_ITEST) \ |
| 43 | || defined(CONFIG_CMD_PCI) \ |
| 44 | || defined(CONFIG_CMD_PORTIO) |
| 45 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 46 | int cmd_get_data_size(char* arg, int default_size) |
| 47 | { |
| 48 | /* Check for a size specification .b, .w or .l. |
| 49 | */ |
| 50 | int len = strlen(arg); |
| 51 | if (len > 2 && arg[len-2] == '.') { |
| 52 | switch(arg[len-1]) { |
| 53 | case 'b': |
| 54 | return 1; |
| 55 | case 'w': |
| 56 | return 2; |
| 57 | case 'l': |
| 58 | return 4; |
wdenk | 2d1a537 | 2004-02-23 19:30:57 +0000 | [diff] [blame] | 59 | case 's': |
| 60 | return -2; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 61 | default: |
| 62 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | return default_size; |
| 66 | } |
| 67 | #endif |
| 68 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 69 | #if defined(CONFIG_CMD_MEMORY) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 70 | |
| 71 | #ifdef CMD_MEM_DEBUG |
| 72 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 73 | #else |
| 74 | #define PRINTF(fmt,args...) |
| 75 | #endif |
| 76 | |
| 77 | static int mod_mem(cmd_tbl_t *, int, int, int, char *[]); |
| 78 | |
| 79 | /* Display values from last command. |
| 80 | * Memory modify remembered values are different from display memory. |
| 81 | */ |
| 82 | uint dp_last_addr, dp_last_size; |
| 83 | uint dp_last_length = 0x40; |
| 84 | uint mm_last_addr, mm_last_size; |
| 85 | |
| 86 | static ulong base_address = 0; |
| 87 | |
| 88 | /* Memory Display |
| 89 | * |
| 90 | * Syntax: |
| 91 | * md{.b, .w, .l} {addr} {len} |
| 92 | */ |
| 93 | #define DISP_LINE_LEN 16 |
| 94 | int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 95 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 96 | ulong addr, length; |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 97 | #if defined(CONFIG_HAS_DATAFLASH) |
| 98 | ulong nbytes, linebytes; |
| 99 | #endif |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 100 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 101 | int rc = 0; |
| 102 | |
| 103 | /* We use the last specified parameters, unless new ones are |
| 104 | * entered. |
| 105 | */ |
| 106 | addr = dp_last_addr; |
| 107 | size = dp_last_size; |
| 108 | length = dp_last_length; |
| 109 | |
| 110 | if (argc < 2) { |
| 111 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 112 | return 1; |
| 113 | } |
| 114 | |
| 115 | if ((flag & CMD_FLAG_REPEAT) == 0) { |
| 116 | /* New command specified. Check for a size specification. |
| 117 | * Defaults to long if no or incorrect specification. |
| 118 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 119 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 120 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 121 | |
| 122 | /* Address is specified since argc > 1 |
| 123 | */ |
| 124 | addr = simple_strtoul(argv[1], NULL, 16); |
| 125 | addr += base_address; |
| 126 | |
| 127 | /* If another parameter, it is the length to display. |
| 128 | * Length is the number of objects, not number of bytes. |
| 129 | */ |
| 130 | if (argc > 2) |
| 131 | length = simple_strtoul(argv[2], NULL, 16); |
| 132 | } |
| 133 | |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 134 | #if defined(CONFIG_HAS_DATAFLASH) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 135 | /* Print the lines. |
| 136 | * |
| 137 | * We buffer all read data, so we can make sure data is read only |
| 138 | * once, and all accesses are with the specified bus width. |
| 139 | */ |
| 140 | nbytes = length * size; |
| 141 | do { |
| 142 | char linebuf[DISP_LINE_LEN]; |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 143 | void* p; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 144 | linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 145 | |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 146 | rc = read_dataflash(addr, (linebytes/size)*size, linebuf); |
| 147 | p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr; |
| 148 | print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 149 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 150 | nbytes -= linebytes; |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 151 | addr += linebytes; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 152 | if (ctrlc()) { |
| 153 | rc = 1; |
| 154 | break; |
| 155 | } |
| 156 | } while (nbytes > 0); |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 157 | #else |
Mike Frysinger | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 158 | |
| 159 | # if defined(CONFIG_BLACKFIN) |
| 160 | /* See if we're trying to display L1 inst */ |
| 161 | if (addr_bfin_on_chip_mem(addr)) { |
| 162 | char linebuf[DISP_LINE_LEN]; |
| 163 | ulong linebytes, nbytes = length * size; |
| 164 | do { |
| 165 | linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; |
| 166 | memcpy(linebuf, (void *)addr, linebytes); |
| 167 | print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size); |
| 168 | |
| 169 | nbytes -= linebytes; |
| 170 | addr += linebytes; |
| 171 | if (ctrlc()) { |
| 172 | rc = 1; |
| 173 | break; |
| 174 | } |
| 175 | } while (nbytes > 0); |
| 176 | } else |
| 177 | # endif |
| 178 | |
| 179 | { |
| 180 | /* Print the lines. */ |
| 181 | print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size); |
| 182 | addr += size*length; |
| 183 | } |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 184 | #endif |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 185 | |
| 186 | dp_last_addr = addr; |
| 187 | dp_last_length = length; |
| 188 | dp_last_size = size; |
| 189 | return (rc); |
| 190 | } |
| 191 | |
| 192 | int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 193 | { |
| 194 | return mod_mem (cmdtp, 1, flag, argc, argv); |
| 195 | } |
| 196 | int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 197 | { |
| 198 | return mod_mem (cmdtp, 0, flag, argc, argv); |
| 199 | } |
| 200 | |
| 201 | int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 202 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 203 | ulong addr, writeval, count; |
| 204 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 205 | |
| 206 | if ((argc < 3) || (argc > 4)) { |
| 207 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 208 | return 1; |
| 209 | } |
| 210 | |
| 211 | /* Check for size specification. |
| 212 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 213 | if ((size = cmd_get_data_size(argv[0], 4)) < 1) |
| 214 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 215 | |
| 216 | /* Address is specified since argc > 1 |
| 217 | */ |
| 218 | addr = simple_strtoul(argv[1], NULL, 16); |
| 219 | addr += base_address; |
| 220 | |
| 221 | /* Get the value to write. |
| 222 | */ |
| 223 | writeval = simple_strtoul(argv[2], NULL, 16); |
| 224 | |
| 225 | /* Count ? */ |
| 226 | if (argc == 4) { |
| 227 | count = simple_strtoul(argv[3], NULL, 16); |
| 228 | } else { |
| 229 | count = 1; |
| 230 | } |
| 231 | |
| 232 | while (count-- > 0) { |
| 233 | if (size == 4) |
| 234 | *((ulong *)addr) = (ulong )writeval; |
| 235 | else if (size == 2) |
| 236 | *((ushort *)addr) = (ushort)writeval; |
| 237 | else |
| 238 | *((u_char *)addr) = (u_char)writeval; |
| 239 | addr += size; |
| 240 | } |
| 241 | return 0; |
| 242 | } |
| 243 | |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 244 | #ifdef CONFIG_MX_CYCLIC |
| 245 | int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 246 | { |
| 247 | int i; |
| 248 | ulong count; |
| 249 | |
| 250 | if (argc < 4) { |
| 251 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 252 | return 1; |
| 253 | } |
| 254 | |
| 255 | count = simple_strtoul(argv[3], NULL, 10); |
| 256 | |
| 257 | for (;;) { |
| 258 | do_mem_md (NULL, 0, 3, argv); |
| 259 | |
| 260 | /* delay for <count> ms... */ |
| 261 | for (i=0; i<count; i++) |
| 262 | udelay (1000); |
| 263 | |
| 264 | /* check for ctrl-c to abort... */ |
| 265 | if (ctrlc()) { |
| 266 | puts("Abort\n"); |
| 267 | return 0; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 275 | { |
| 276 | int i; |
| 277 | ulong count; |
| 278 | |
| 279 | if (argc < 4) { |
| 280 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 281 | return 1; |
| 282 | } |
| 283 | |
| 284 | count = simple_strtoul(argv[3], NULL, 10); |
| 285 | |
| 286 | for (;;) { |
| 287 | do_mem_mw (NULL, 0, 3, argv); |
| 288 | |
| 289 | /* delay for <count> ms... */ |
| 290 | for (i=0; i<count; i++) |
| 291 | udelay (1000); |
| 292 | |
| 293 | /* check for ctrl-c to abort... */ |
| 294 | if (ctrlc()) { |
| 295 | puts("Abort\n"); |
| 296 | return 0; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | #endif /* CONFIG_MX_CYCLIC */ |
| 303 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 304 | int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 305 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 306 | ulong addr1, addr2, count, ngood; |
| 307 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 308 | int rcode = 0; |
| 309 | |
| 310 | if (argc != 4) { |
| 311 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 312 | return 1; |
| 313 | } |
| 314 | |
| 315 | /* Check for size specification. |
| 316 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 317 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 318 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 319 | |
| 320 | addr1 = simple_strtoul(argv[1], NULL, 16); |
| 321 | addr1 += base_address; |
| 322 | |
| 323 | addr2 = simple_strtoul(argv[2], NULL, 16); |
| 324 | addr2 += base_address; |
| 325 | |
| 326 | count = simple_strtoul(argv[3], NULL, 16); |
| 327 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 328 | #ifdef CONFIG_HAS_DATAFLASH |
| 329 | if (addr_dataflash(addr1) | addr_dataflash(addr2)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 330 | puts ("Comparison with DataFlash space not supported.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | #endif |
| 334 | |
Mike Frysinger | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 335 | #ifdef CONFIG_BLACKFIN |
| 336 | if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) { |
| 337 | puts ("Comparison with L1 instruction memory not supported.\n\r"); |
| 338 | return 0; |
| 339 | } |
| 340 | #endif |
| 341 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 342 | ngood = 0; |
| 343 | |
| 344 | while (count-- > 0) { |
| 345 | if (size == 4) { |
| 346 | ulong word1 = *(ulong *)addr1; |
| 347 | ulong word2 = *(ulong *)addr2; |
| 348 | if (word1 != word2) { |
| 349 | printf("word at 0x%08lx (0x%08lx) " |
| 350 | "!= word at 0x%08lx (0x%08lx)\n", |
| 351 | addr1, word1, addr2, word2); |
| 352 | rcode = 1; |
| 353 | break; |
| 354 | } |
| 355 | } |
| 356 | else if (size == 2) { |
| 357 | ushort hword1 = *(ushort *)addr1; |
| 358 | ushort hword2 = *(ushort *)addr2; |
| 359 | if (hword1 != hword2) { |
| 360 | printf("halfword at 0x%08lx (0x%04x) " |
| 361 | "!= halfword at 0x%08lx (0x%04x)\n", |
| 362 | addr1, hword1, addr2, hword2); |
| 363 | rcode = 1; |
| 364 | break; |
| 365 | } |
| 366 | } |
| 367 | else { |
| 368 | u_char byte1 = *(u_char *)addr1; |
| 369 | u_char byte2 = *(u_char *)addr2; |
| 370 | if (byte1 != byte2) { |
| 371 | printf("byte at 0x%08lx (0x%02x) " |
| 372 | "!= byte at 0x%08lx (0x%02x)\n", |
| 373 | addr1, byte1, addr2, byte2); |
| 374 | rcode = 1; |
| 375 | break; |
| 376 | } |
| 377 | } |
| 378 | ngood++; |
| 379 | addr1 += size; |
| 380 | addr2 += size; |
| 381 | } |
| 382 | |
| 383 | printf("Total of %ld %s%s were the same\n", |
| 384 | ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte", |
| 385 | ngood == 1 ? "" : "s"); |
| 386 | return rcode; |
| 387 | } |
| 388 | |
| 389 | int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 390 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 391 | ulong addr, dest, count; |
| 392 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 393 | |
| 394 | if (argc != 4) { |
| 395 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 396 | return 1; |
| 397 | } |
| 398 | |
| 399 | /* Check for size specification. |
| 400 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 401 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 402 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 403 | |
| 404 | addr = simple_strtoul(argv[1], NULL, 16); |
| 405 | addr += base_address; |
| 406 | |
| 407 | dest = simple_strtoul(argv[2], NULL, 16); |
| 408 | dest += base_address; |
| 409 | |
| 410 | count = simple_strtoul(argv[3], NULL, 16); |
| 411 | |
| 412 | if (count == 0) { |
| 413 | puts ("Zero length ???\n"); |
| 414 | return 1; |
| 415 | } |
| 416 | |
| 417 | #ifndef CFG_NO_FLASH |
| 418 | /* check if we are copying to Flash */ |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 419 | if ( (addr2info(dest) != NULL) |
| 420 | #ifdef CONFIG_HAS_DATAFLASH |
Kim B. Heino | 84d0c2f | 2008-03-03 10:39:13 +0200 | [diff] [blame] | 421 | && (!addr_dataflash(dest)) |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 422 | #endif |
| 423 | ) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 424 | int rc; |
| 425 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 426 | puts ("Copy to Flash... "); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 427 | |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 428 | rc = flash_write ((char *)addr, dest, count*size); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 429 | if (rc != 0) { |
| 430 | flash_perror (rc); |
| 431 | return (1); |
| 432 | } |
| 433 | puts ("done\n"); |
| 434 | return 0; |
| 435 | } |
| 436 | #endif |
| 437 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 438 | #if defined(CONFIG_CMD_MMC) |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 439 | if (mmc2info(dest)) { |
| 440 | int rc; |
| 441 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 442 | puts ("Copy to MMC... "); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 443 | switch (rc = mmc_write ((uchar *)addr, dest, count*size)) { |
| 444 | case 0: |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 445 | putc ('\n'); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 446 | return 1; |
| 447 | case -1: |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 448 | puts ("failed\n"); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 449 | return 1; |
| 450 | default: |
| 451 | printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); |
| 452 | return 1; |
| 453 | } |
| 454 | puts ("done\n"); |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | if (mmc2info(addr)) { |
| 459 | int rc; |
| 460 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 461 | puts ("Copy from MMC... "); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 462 | switch (rc = mmc_read (addr, (uchar *)dest, count*size)) { |
| 463 | case 0: |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 464 | putc ('\n'); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 465 | return 1; |
| 466 | case -1: |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 467 | puts ("failed\n"); |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 468 | return 1; |
| 469 | default: |
| 470 | printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); |
| 471 | return 1; |
| 472 | } |
| 473 | puts ("done\n"); |
| 474 | return 0; |
| 475 | } |
| 476 | #endif |
| 477 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 478 | #ifdef CONFIG_HAS_DATAFLASH |
| 479 | /* Check if we are copying from RAM or Flash to DataFlash */ |
| 480 | if (addr_dataflash(dest) && !addr_dataflash(addr)){ |
| 481 | int rc; |
| 482 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 483 | puts ("Copy to DataFlash... "); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 484 | |
| 485 | rc = write_dataflash (dest, addr, count*size); |
| 486 | |
| 487 | if (rc != 1) { |
| 488 | dataflash_perror (rc); |
| 489 | return (1); |
| 490 | } |
| 491 | puts ("done\n"); |
| 492 | return 0; |
| 493 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 494 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 495 | /* Check if we are copying from DataFlash to RAM */ |
Stelian Pop | 880cc43 | 2008-03-26 22:52:35 +0100 | [diff] [blame] | 496 | if (addr_dataflash(addr) && !addr_dataflash(dest) |
| 497 | #ifndef CFG_NO_FLASH |
| 498 | && (addr2info(dest) == NULL) |
| 499 | #endif |
| 500 | ){ |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 501 | int rc; |
| 502 | rc = read_dataflash(addr, count * size, (char *) dest); |
| 503 | if (rc != 1) { |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 504 | dataflash_perror (rc); |
| 505 | return (1); |
| 506 | } |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | if (addr_dataflash(addr) && addr_dataflash(dest)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 511 | puts ("Unsupported combination of source/destination.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 512 | return 1; |
| 513 | } |
| 514 | #endif |
| 515 | |
Mike Frysinger | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 516 | #ifdef CONFIG_BLACKFIN |
| 517 | /* See if we're copying to/from L1 inst */ |
| 518 | if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) { |
| 519 | memcpy((void *)dest, (void *)addr, count * size); |
| 520 | return 0; |
| 521 | } |
| 522 | #endif |
| 523 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 524 | while (count-- > 0) { |
| 525 | if (size == 4) |
| 526 | *((ulong *)dest) = *((ulong *)addr); |
| 527 | else if (size == 2) |
| 528 | *((ushort *)dest) = *((ushort *)addr); |
| 529 | else |
| 530 | *((u_char *)dest) = *((u_char *)addr); |
| 531 | addr += size; |
| 532 | dest += size; |
| 533 | } |
| 534 | return 0; |
| 535 | } |
| 536 | |
| 537 | int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 538 | { |
| 539 | if (argc > 1) { |
| 540 | /* Set new base address. |
| 541 | */ |
| 542 | base_address = simple_strtoul(argv[1], NULL, 16); |
| 543 | } |
| 544 | /* Print the current base address. |
| 545 | */ |
| 546 | printf("Base Address: 0x%08lx\n", base_address); |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 551 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 552 | ulong addr, length, i, junk; |
| 553 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 554 | volatile uint *longp; |
| 555 | volatile ushort *shortp; |
| 556 | volatile u_char *cp; |
| 557 | |
| 558 | if (argc < 3) { |
| 559 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 560 | return 1; |
| 561 | } |
| 562 | |
| 563 | /* Check for a size spefication. |
| 564 | * Defaults to long if no or incorrect specification. |
| 565 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 566 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 567 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 568 | |
| 569 | /* Address is always specified. |
| 570 | */ |
| 571 | addr = simple_strtoul(argv[1], NULL, 16); |
| 572 | |
| 573 | /* Length is the number of objects, not number of bytes. |
| 574 | */ |
| 575 | length = simple_strtoul(argv[2], NULL, 16); |
| 576 | |
| 577 | /* We want to optimize the loops to run as fast as possible. |
| 578 | * If we have only one object, just run infinite loops. |
| 579 | */ |
| 580 | if (length == 1) { |
| 581 | if (size == 4) { |
| 582 | longp = (uint *)addr; |
| 583 | for (;;) |
| 584 | i = *longp; |
| 585 | } |
| 586 | if (size == 2) { |
| 587 | shortp = (ushort *)addr; |
| 588 | for (;;) |
| 589 | i = *shortp; |
| 590 | } |
| 591 | cp = (u_char *)addr; |
| 592 | for (;;) |
| 593 | i = *cp; |
| 594 | } |
| 595 | |
| 596 | if (size == 4) { |
| 597 | for (;;) { |
| 598 | longp = (uint *)addr; |
| 599 | i = length; |
| 600 | while (i-- > 0) |
| 601 | junk = *longp++; |
| 602 | } |
| 603 | } |
| 604 | if (size == 2) { |
| 605 | for (;;) { |
| 606 | shortp = (ushort *)addr; |
| 607 | i = length; |
| 608 | while (i-- > 0) |
| 609 | junk = *shortp++; |
| 610 | } |
| 611 | } |
| 612 | for (;;) { |
| 613 | cp = (u_char *)addr; |
| 614 | i = length; |
| 615 | while (i-- > 0) |
| 616 | junk = *cp++; |
| 617 | } |
| 618 | } |
| 619 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 620 | #ifdef CONFIG_LOOPW |
| 621 | int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 622 | { |
| 623 | ulong addr, length, i, data; |
| 624 | int size; |
| 625 | volatile uint *longp; |
| 626 | volatile ushort *shortp; |
| 627 | volatile u_char *cp; |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 628 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 629 | if (argc < 4) { |
| 630 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 631 | return 1; |
| 632 | } |
| 633 | |
| 634 | /* Check for a size spefication. |
| 635 | * Defaults to long if no or incorrect specification. |
| 636 | */ |
| 637 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 638 | return 1; |
| 639 | |
| 640 | /* Address is always specified. |
| 641 | */ |
| 642 | addr = simple_strtoul(argv[1], NULL, 16); |
| 643 | |
| 644 | /* Length is the number of objects, not number of bytes. |
| 645 | */ |
| 646 | length = simple_strtoul(argv[2], NULL, 16); |
| 647 | |
| 648 | /* data to write */ |
| 649 | data = simple_strtoul(argv[3], NULL, 16); |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 650 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 651 | /* We want to optimize the loops to run as fast as possible. |
| 652 | * If we have only one object, just run infinite loops. |
| 653 | */ |
| 654 | if (length == 1) { |
| 655 | if (size == 4) { |
| 656 | longp = (uint *)addr; |
| 657 | for (;;) |
| 658 | *longp = data; |
| 659 | } |
| 660 | if (size == 2) { |
| 661 | shortp = (ushort *)addr; |
| 662 | for (;;) |
| 663 | *shortp = data; |
| 664 | } |
| 665 | cp = (u_char *)addr; |
| 666 | for (;;) |
| 667 | *cp = data; |
| 668 | } |
| 669 | |
| 670 | if (size == 4) { |
| 671 | for (;;) { |
| 672 | longp = (uint *)addr; |
| 673 | i = length; |
| 674 | while (i-- > 0) |
| 675 | *longp++ = data; |
| 676 | } |
| 677 | } |
| 678 | if (size == 2) { |
| 679 | for (;;) { |
| 680 | shortp = (ushort *)addr; |
| 681 | i = length; |
| 682 | while (i-- > 0) |
| 683 | *shortp++ = data; |
| 684 | } |
| 685 | } |
| 686 | for (;;) { |
| 687 | cp = (u_char *)addr; |
| 688 | i = length; |
| 689 | while (i-- > 0) |
| 690 | *cp++ = data; |
| 691 | } |
| 692 | } |
| 693 | #endif /* CONFIG_LOOPW */ |
| 694 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 695 | /* |
| 696 | * Perform a memory test. A more complete alternative test can be |
| 697 | * configured using CFG_ALT_MEMTEST. The complete test loops until |
| 698 | * interrupted by ctrl-c or by a failure of one of the sub-tests. |
| 699 | */ |
| 700 | int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 701 | { |
| 702 | vu_long *addr, *start, *end; |
| 703 | ulong val; |
| 704 | ulong readback; |
Guennadi Liakhovetski | 1f780aa | 2008-02-13 11:19:19 +0100 | [diff] [blame] | 705 | int rcode = 0; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 706 | |
| 707 | #if defined(CFG_ALT_MEMTEST) |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 708 | vu_long len; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 709 | vu_long offset; |
| 710 | vu_long test_offset; |
| 711 | vu_long pattern; |
| 712 | vu_long temp; |
| 713 | vu_long anti_pattern; |
| 714 | vu_long num_words; |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 715 | #if defined(CFG_MEMTEST_SCRATCH) |
| 716 | vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH; |
| 717 | #else |
Wolfgang Denk | 029b6dc | 2006-07-21 11:37:40 +0200 | [diff] [blame] | 718 | vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */ |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 719 | #endif |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 720 | int j; |
| 721 | int iterations = 1; |
| 722 | |
| 723 | static const ulong bitpattern[] = { |
| 724 | 0x00000001, /* single bit */ |
| 725 | 0x00000003, /* two adjacent bits */ |
| 726 | 0x00000007, /* three adjacent bits */ |
| 727 | 0x0000000F, /* four adjacent bits */ |
| 728 | 0x00000005, /* two non-adjacent bits */ |
| 729 | 0x00000015, /* three non-adjacent bits */ |
| 730 | 0x00000055, /* four non-adjacent bits */ |
| 731 | 0xaaaaaaaa, /* alternating 1/0 */ |
| 732 | }; |
| 733 | #else |
| 734 | ulong incr; |
| 735 | ulong pattern; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 736 | #endif |
| 737 | |
| 738 | if (argc > 1) { |
| 739 | start = (ulong *)simple_strtoul(argv[1], NULL, 16); |
| 740 | } else { |
| 741 | start = (ulong *)CFG_MEMTEST_START; |
| 742 | } |
| 743 | |
| 744 | if (argc > 2) { |
| 745 | end = (ulong *)simple_strtoul(argv[2], NULL, 16); |
| 746 | } else { |
| 747 | end = (ulong *)(CFG_MEMTEST_END); |
| 748 | } |
| 749 | |
| 750 | if (argc > 3) { |
| 751 | pattern = (ulong)simple_strtoul(argv[3], NULL, 16); |
| 752 | } else { |
| 753 | pattern = 0; |
| 754 | } |
| 755 | |
| 756 | #if defined(CFG_ALT_MEMTEST) |
| 757 | printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end); |
| 758 | PRINTF("%s:%d: start 0x%p end 0x%p\n", |
| 759 | __FUNCTION__, __LINE__, start, end); |
| 760 | |
| 761 | for (;;) { |
| 762 | if (ctrlc()) { |
| 763 | putc ('\n'); |
| 764 | return 1; |
| 765 | } |
| 766 | |
| 767 | printf("Iteration: %6d\r", iterations); |
| 768 | PRINTF("Iteration: %6d\n", iterations); |
| 769 | iterations++; |
| 770 | |
| 771 | /* |
| 772 | * Data line test: write a pattern to the first |
| 773 | * location, write the 1's complement to a 'parking' |
| 774 | * address (changes the state of the data bus so a |
| 775 | * floating bus doen't give a false OK), and then |
| 776 | * read the value back. Note that we read it back |
| 777 | * into a variable because the next time we read it, |
| 778 | * it might be right (been there, tough to explain to |
| 779 | * the quality guys why it prints a failure when the |
| 780 | * "is" and "should be" are obviously the same in the |
| 781 | * error message). |
| 782 | * |
| 783 | * Rather than exhaustively testing, we test some |
| 784 | * patterns by shifting '1' bits through a field of |
| 785 | * '0's and '0' bits through a field of '1's (i.e. |
| 786 | * pattern and ~pattern). |
| 787 | */ |
| 788 | addr = start; |
| 789 | for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) { |
| 790 | val = bitpattern[j]; |
| 791 | for(; val != 0; val <<= 1) { |
| 792 | *addr = val; |
| 793 | *dummy = ~val; /* clear the test data off of the bus */ |
| 794 | readback = *addr; |
| 795 | if(readback != val) { |
| 796 | printf ("FAILURE (data line): " |
| 797 | "expected %08lx, actual %08lx\n", |
| 798 | val, readback); |
| 799 | } |
| 800 | *addr = ~val; |
| 801 | *dummy = val; |
| 802 | readback = *addr; |
| 803 | if(readback != ~val) { |
| 804 | printf ("FAILURE (data line): " |
| 805 | "Is %08lx, should be %08lx\n", |
wdenk | e1599e8 | 2004-10-10 23:27:33 +0000 | [diff] [blame] | 806 | readback, ~val); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 807 | } |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /* |
| 812 | * Based on code whose Original Author and Copyright |
| 813 | * information follows: Copyright (c) 1998 by Michael |
| 814 | * Barr. This software is placed into the public |
| 815 | * domain and may be used for any purpose. However, |
| 816 | * this notice must not be changed or removed and no |
| 817 | * warranty is either expressed or implied by its |
| 818 | * publication or distribution. |
| 819 | */ |
| 820 | |
| 821 | /* |
| 822 | * Address line test |
| 823 | * |
| 824 | * Description: Test the address bus wiring in a |
| 825 | * memory region by performing a walking |
| 826 | * 1's test on the relevant bits of the |
| 827 | * address and checking for aliasing. |
| 828 | * This test will find single-bit |
| 829 | * address failures such as stuck -high, |
| 830 | * stuck-low, and shorted pins. The base |
| 831 | * address and size of the region are |
| 832 | * selected by the caller. |
| 833 | * |
| 834 | * Notes: For best results, the selected base |
| 835 | * address should have enough LSB 0's to |
| 836 | * guarantee single address bit changes. |
| 837 | * For example, to test a 64-Kbyte |
| 838 | * region, select a base address on a |
| 839 | * 64-Kbyte boundary. Also, select the |
| 840 | * region size as a power-of-two if at |
| 841 | * all possible. |
| 842 | * |
| 843 | * Returns: 0 if the test succeeds, 1 if the test fails. |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 844 | */ |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 845 | len = ((ulong)end - (ulong)start)/sizeof(vu_long); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 846 | pattern = (vu_long) 0xaaaaaaaa; |
| 847 | anti_pattern = (vu_long) 0x55555555; |
| 848 | |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 849 | PRINTF("%s:%d: length = 0x%.8lx\n", |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 850 | __FUNCTION__, __LINE__, |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 851 | len); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 852 | /* |
| 853 | * Write the default pattern at each of the |
| 854 | * power-of-two offsets. |
| 855 | */ |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 856 | for (offset = 1; offset < len; offset <<= 1) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 857 | start[offset] = pattern; |
| 858 | } |
| 859 | |
| 860 | /* |
| 861 | * Check for address bits stuck high. |
| 862 | */ |
| 863 | test_offset = 0; |
| 864 | start[test_offset] = anti_pattern; |
| 865 | |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 866 | for (offset = 1; offset < len; offset <<= 1) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 867 | temp = start[offset]; |
| 868 | if (temp != pattern) { |
| 869 | printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:" |
| 870 | " expected 0x%.8lx, actual 0x%.8lx\n", |
| 871 | (ulong)&start[offset], pattern, temp); |
| 872 | return 1; |
| 873 | } |
| 874 | } |
| 875 | start[test_offset] = pattern; |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 876 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 877 | |
| 878 | /* |
| 879 | * Check for addr bits stuck low or shorted. |
| 880 | */ |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 881 | for (test_offset = 1; test_offset < len; test_offset <<= 1) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 882 | start[test_offset] = anti_pattern; |
| 883 | |
Guennadi Liakhovetski | 6f4abee | 2008-02-08 21:25:58 +0100 | [diff] [blame] | 884 | for (offset = 1; offset < len; offset <<= 1) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 885 | temp = start[offset]; |
| 886 | if ((temp != pattern) && (offset != test_offset)) { |
| 887 | printf ("\nFAILURE: Address bit stuck low or shorted @" |
| 888 | " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n", |
| 889 | (ulong)&start[offset], pattern, temp); |
| 890 | return 1; |
| 891 | } |
| 892 | } |
| 893 | start[test_offset] = pattern; |
| 894 | } |
| 895 | |
| 896 | /* |
| 897 | * Description: Test the integrity of a physical |
| 898 | * memory device by performing an |
| 899 | * increment/decrement test over the |
| 900 | * entire region. In the process every |
| 901 | * storage bit in the device is tested |
| 902 | * as a zero and a one. The base address |
| 903 | * and the size of the region are |
| 904 | * selected by the caller. |
| 905 | * |
| 906 | * Returns: 0 if the test succeeds, 1 if the test fails. |
| 907 | */ |
| 908 | num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1; |
| 909 | |
| 910 | /* |
| 911 | * Fill memory with a known pattern. |
| 912 | */ |
| 913 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 914 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 915 | start[offset] = pattern; |
| 916 | } |
| 917 | |
| 918 | /* |
| 919 | * Check each location and invert it for the second pass. |
| 920 | */ |
| 921 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 922 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 923 | temp = start[offset]; |
| 924 | if (temp != pattern) { |
| 925 | printf ("\nFAILURE (read/write) @ 0x%.8lx:" |
| 926 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
| 927 | (ulong)&start[offset], pattern, temp); |
| 928 | return 1; |
| 929 | } |
| 930 | |
| 931 | anti_pattern = ~pattern; |
| 932 | start[offset] = anti_pattern; |
| 933 | } |
| 934 | |
| 935 | /* |
| 936 | * Check each location for the inverted pattern and zero it. |
| 937 | */ |
| 938 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 939 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 940 | anti_pattern = ~pattern; |
| 941 | temp = start[offset]; |
| 942 | if (temp != anti_pattern) { |
| 943 | printf ("\nFAILURE (read/write): @ 0x%.8lx:" |
| 944 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
| 945 | (ulong)&start[offset], anti_pattern, temp); |
| 946 | return 1; |
| 947 | } |
| 948 | start[offset] = 0; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | #else /* The original, quickie test */ |
| 953 | incr = 1; |
| 954 | for (;;) { |
| 955 | if (ctrlc()) { |
| 956 | putc ('\n'); |
| 957 | return 1; |
| 958 | } |
| 959 | |
| 960 | printf ("\rPattern %08lX Writing..." |
| 961 | "%12s" |
| 962 | "\b\b\b\b\b\b\b\b\b\b", |
| 963 | pattern, ""); |
| 964 | |
| 965 | for (addr=start,val=pattern; addr<end; addr++) { |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 966 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 967 | *addr = val; |
| 968 | val += incr; |
| 969 | } |
| 970 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 971 | puts ("Reading..."); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 972 | |
| 973 | for (addr=start,val=pattern; addr<end; addr++) { |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 974 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 975 | readback = *addr; |
| 976 | if (readback != val) { |
| 977 | printf ("\nMem error @ 0x%08X: " |
| 978 | "found %08lX, expected %08lX\n", |
| 979 | (uint)addr, readback, val); |
| 980 | rcode = 1; |
| 981 | } |
| 982 | val += incr; |
| 983 | } |
| 984 | |
| 985 | /* |
| 986 | * Flip the pattern each time to make lots of zeros and |
| 987 | * then, the next time, lots of ones. We decrement |
| 988 | * the "negative" patterns and increment the "positive" |
| 989 | * patterns to preserve this feature. |
| 990 | */ |
| 991 | if(pattern & 0x80000000) { |
| 992 | pattern = -pattern; /* complement & increment */ |
| 993 | } |
| 994 | else { |
| 995 | pattern = ~pattern; |
| 996 | } |
| 997 | incr = -incr; |
| 998 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 999 | #endif |
Guennadi Liakhovetski | 1f780aa | 2008-02-13 11:19:19 +0100 | [diff] [blame] | 1000 | return rcode; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | |
| 1004 | /* Modify memory. |
| 1005 | * |
| 1006 | * Syntax: |
| 1007 | * mm{.b, .w, .l} {addr} |
| 1008 | * nm{.b, .w, .l} {addr} |
| 1009 | */ |
| 1010 | static int |
| 1011 | mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) |
| 1012 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1013 | ulong addr, i; |
| 1014 | int nbytes, size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1015 | extern char console_buffer[]; |
| 1016 | |
| 1017 | if (argc != 2) { |
| 1018 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 1019 | return 1; |
| 1020 | } |
| 1021 | |
| 1022 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1023 | reset_cmd_timeout(); /* got a good command to get here */ |
| 1024 | #endif |
| 1025 | /* We use the last specified parameters, unless new ones are |
| 1026 | * entered. |
| 1027 | */ |
| 1028 | addr = mm_last_addr; |
| 1029 | size = mm_last_size; |
| 1030 | |
| 1031 | if ((flag & CMD_FLAG_REPEAT) == 0) { |
| 1032 | /* New command specified. Check for a size specification. |
| 1033 | * Defaults to long if no or incorrect specification. |
| 1034 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1035 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 1036 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1037 | |
| 1038 | /* Address is specified since argc > 1 |
| 1039 | */ |
| 1040 | addr = simple_strtoul(argv[1], NULL, 16); |
| 1041 | addr += base_address; |
| 1042 | } |
| 1043 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1044 | #ifdef CONFIG_HAS_DATAFLASH |
| 1045 | if (addr_dataflash(addr)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 1046 | puts ("Can't modify DataFlash in place. Use cp instead.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1047 | return 0; |
| 1048 | } |
| 1049 | #endif |
| 1050 | |
Mike Frysinger | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 1051 | #ifdef CONFIG_BLACKFIN |
| 1052 | if (addr_bfin_on_chip_mem(addr)) { |
| 1053 | puts ("Can't modify L1 instruction in place. Use cp instead.\n\r"); |
| 1054 | return 0; |
| 1055 | } |
| 1056 | #endif |
| 1057 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1058 | /* Print the address, followed by value. Then accept input for |
| 1059 | * the next value. A non-converted value exits. |
| 1060 | */ |
| 1061 | do { |
| 1062 | printf("%08lx:", addr); |
| 1063 | if (size == 4) |
| 1064 | printf(" %08x", *((uint *)addr)); |
| 1065 | else if (size == 2) |
| 1066 | printf(" %04x", *((ushort *)addr)); |
| 1067 | else |
| 1068 | printf(" %02x", *((u_char *)addr)); |
| 1069 | |
| 1070 | nbytes = readline (" ? "); |
| 1071 | if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) { |
| 1072 | /* <CR> pressed as only input, don't modify current |
| 1073 | * location and move to next. "-" pressed will go back. |
| 1074 | */ |
| 1075 | if (incrflag) |
| 1076 | addr += nbytes ? -size : size; |
| 1077 | nbytes = 1; |
| 1078 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1079 | reset_cmd_timeout(); /* good enough to not time out */ |
| 1080 | #endif |
| 1081 | } |
| 1082 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1083 | else if (nbytes == -2) { |
| 1084 | break; /* timed out, exit the command */ |
| 1085 | } |
| 1086 | #endif |
| 1087 | else { |
| 1088 | char *endp; |
| 1089 | i = simple_strtoul(console_buffer, &endp, 16); |
| 1090 | nbytes = endp - console_buffer; |
| 1091 | if (nbytes) { |
| 1092 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1093 | /* good enough to not time out |
| 1094 | */ |
| 1095 | reset_cmd_timeout(); |
| 1096 | #endif |
| 1097 | if (size == 4) |
| 1098 | *((uint *)addr) = i; |
| 1099 | else if (size == 2) |
| 1100 | *((ushort *)addr) = i; |
| 1101 | else |
| 1102 | *((u_char *)addr) = i; |
| 1103 | if (incrflag) |
| 1104 | addr += size; |
| 1105 | } |
| 1106 | } |
| 1107 | } while (nbytes); |
| 1108 | |
| 1109 | mm_last_addr = addr; |
| 1110 | mm_last_size = size; |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1114 | #ifndef CONFIG_CRC32_VERIFY |
| 1115 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1116 | int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 1117 | { |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1118 | ulong addr, length; |
| 1119 | ulong crc; |
| 1120 | ulong *ptr; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1121 | |
| 1122 | if (argc < 3) { |
| 1123 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 1124 | return 1; |
| 1125 | } |
| 1126 | |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1127 | addr = simple_strtoul (argv[1], NULL, 16); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1128 | addr += base_address; |
| 1129 | |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1130 | length = simple_strtoul (argv[2], NULL, 16); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1131 | |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1132 | crc = crc32 (0, (const uchar *) addr, length); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1133 | |
| 1134 | printf ("CRC32 for %08lx ... %08lx ==> %08lx\n", |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1135 | addr, addr + length - 1, crc); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1136 | |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1137 | if (argc > 3) { |
| 1138 | ptr = (ulong *) simple_strtoul (argv[3], NULL, 16); |
| 1139 | *ptr = crc; |
| 1140 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1141 | |
| 1142 | return 0; |
| 1143 | } |
| 1144 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1145 | #else /* CONFIG_CRC32_VERIFY */ |
| 1146 | |
| 1147 | int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 1148 | { |
| 1149 | ulong addr, length; |
| 1150 | ulong crc; |
| 1151 | ulong *ptr; |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 1152 | ulong vcrc; |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1153 | int verify; |
| 1154 | int ac; |
| 1155 | char **av; |
| 1156 | |
| 1157 | if (argc < 3) { |
| 1158 | usage: |
| 1159 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 1160 | return 1; |
| 1161 | } |
| 1162 | |
| 1163 | av = argv + 1; |
| 1164 | ac = argc - 1; |
| 1165 | if (strcmp(*av, "-v") == 0) { |
| 1166 | verify = 1; |
| 1167 | av++; |
| 1168 | ac--; |
| 1169 | if (ac < 3) |
| 1170 | goto usage; |
| 1171 | } else |
| 1172 | verify = 0; |
| 1173 | |
| 1174 | addr = simple_strtoul(*av++, NULL, 16); |
| 1175 | addr += base_address; |
| 1176 | length = simple_strtoul(*av++, NULL, 16); |
| 1177 | |
| 1178 | crc = crc32(0, (const uchar *) addr, length); |
| 1179 | |
| 1180 | if (!verify) { |
| 1181 | printf ("CRC32 for %08lx ... %08lx ==> %08lx\n", |
| 1182 | addr, addr + length - 1, crc); |
| 1183 | if (ac > 2) { |
| 1184 | ptr = (ulong *) simple_strtoul (*av++, NULL, 16); |
| 1185 | *ptr = crc; |
| 1186 | } |
| 1187 | } else { |
| 1188 | vcrc = simple_strtoul(*av++, NULL, 16); |
| 1189 | if (vcrc != crc) { |
| 1190 | printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n", |
| 1191 | addr, addr + length - 1, crc, vcrc); |
| 1192 | return 1; |
| 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | return 0; |
| 1197 | |
| 1198 | } |
| 1199 | #endif /* CONFIG_CRC32_VERIFY */ |
| 1200 | |
Harald Welte | fe2ce55 | 2008-07-06 15:56:38 +0800 | [diff] [blame] | 1201 | |
| 1202 | #ifdef CONFIG_CMD_UNZIP |
| 1203 | int gunzip (void *, int, unsigned char *, unsigned long *); |
| 1204 | |
| 1205 | int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 1206 | { |
| 1207 | unsigned long src, dst; |
| 1208 | unsigned long src_len = ~0UL, dst_len = ~0UL; |
| 1209 | int err; |
| 1210 | |
| 1211 | switch (argc) { |
| 1212 | case 4: |
| 1213 | dst_len = simple_strtoul(argv[3], NULL, 16); |
| 1214 | /* fall through */ |
| 1215 | case 3: |
| 1216 | src = simple_strtoul(argv[1], NULL, 16); |
| 1217 | dst = simple_strtoul(argv[2], NULL, 16); |
| 1218 | break; |
| 1219 | default: |
| 1220 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 1221 | return 1; |
| 1222 | } |
| 1223 | |
| 1224 | return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); |
| 1225 | } |
| 1226 | #endif /* CONFIG_CMD_UNZIP */ |
| 1227 | |
| 1228 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1229 | /**************************************************/ |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1230 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1231 | md, 3, 1, do_mem_md, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1232 | "md - memory display\n", |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1233 | "[.b, .w, .l] address [# of objects]\n - memory display\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1234 | ); |
| 1235 | |
| 1236 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1237 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1238 | mm, 2, 1, do_mem_mm, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1239 | "mm - memory modify (auto-incrementing)\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1240 | "[.b, .w, .l] address\n" " - memory modify, auto increment address\n" |
| 1241 | ); |
| 1242 | |
| 1243 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1244 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1245 | nm, 2, 1, do_mem_nm, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1246 | "nm - memory modify (constant address)\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1247 | "[.b, .w, .l] address\n - memory modify, read and keep address\n" |
| 1248 | ); |
| 1249 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1250 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1251 | mw, 4, 1, do_mem_mw, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1252 | "mw - memory write (fill)\n", |
| 1253 | "[.b, .w, .l] address value [count]\n - write memory\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1254 | ); |
| 1255 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1256 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1257 | cp, 4, 1, do_mem_cp, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1258 | "cp - memory copy\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1259 | "[.b, .w, .l] source target count\n - copy memory\n" |
| 1260 | ); |
| 1261 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1262 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1263 | cmp, 4, 1, do_mem_cmp, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1264 | "cmp - memory compare\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1265 | "[.b, .w, .l] addr1 addr2 count\n - compare memory\n" |
| 1266 | ); |
| 1267 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1268 | #ifndef CONFIG_CRC32_VERIFY |
| 1269 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1270 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1271 | crc32, 4, 1, do_mem_crc, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1272 | "crc32 - checksum calculation\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1273 | "address count [addr]\n - compute CRC32 checksum [save at addr]\n" |
| 1274 | ); |
| 1275 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1276 | #else /* CONFIG_CRC32_VERIFY */ |
| 1277 | |
| 1278 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1279 | crc32, 5, 1, do_mem_crc, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1280 | "crc32 - checksum calculation\n", |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1281 | "address count [addr]\n - compute CRC32 checksum [save at addr]\n" |
| 1282 | "-v address count crc\n - verify crc of memory area\n" |
| 1283 | ); |
| 1284 | |
| 1285 | #endif /* CONFIG_CRC32_VERIFY */ |
| 1286 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1287 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1288 | base, 2, 1, do_mem_base, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1289 | "base - print or set address offset\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1290 | "\n - print address offset for memory commands\n" |
| 1291 | "base off\n - set address offset for memory commands to 'off'\n" |
| 1292 | ); |
| 1293 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1294 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1295 | loop, 3, 1, do_mem_loop, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1296 | "loop - infinite loop on address range\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1297 | "[.b, .w, .l] address number_of_objects\n" |
| 1298 | " - loop on a set of addresses\n" |
| 1299 | ); |
| 1300 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1301 | #ifdef CONFIG_LOOPW |
| 1302 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1303 | loopw, 4, 1, do_mem_loopw, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1304 | "loopw - infinite write loop on address range\n", |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1305 | "[.b, .w, .l] address number_of_objects data_to_write\n" |
| 1306 | " - loop on a set of addresses\n" |
| 1307 | ); |
| 1308 | #endif /* CONFIG_LOOPW */ |
| 1309 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1310 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1311 | mtest, 4, 1, do_mem_mtest, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1312 | "mtest - simple RAM test\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1313 | "[start [end [pattern]]]\n" |
| 1314 | " - simple RAM read/write test\n" |
| 1315 | ); |
| 1316 | |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1317 | #ifdef CONFIG_MX_CYCLIC |
| 1318 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1319 | mdc, 4, 1, do_mem_mdc, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1320 | "mdc - memory display cyclic\n", |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1321 | "[.b, .w, .l] address count delay(ms)\n - memory display cyclic\n" |
| 1322 | ); |
| 1323 | |
| 1324 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1325 | mwc, 4, 1, do_mem_mwc, |
Wolfgang Denk | 19f1014 | 2008-08-26 13:14:34 +0200 | [diff] [blame] | 1326 | "mwc - memory write cyclic\n", |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1327 | "[.b, .w, .l] address value delay(ms)\n - memory write cyclic\n" |
| 1328 | ); |
| 1329 | #endif /* CONFIG_MX_CYCLIC */ |
| 1330 | |
Harald Welte | fe2ce55 | 2008-07-06 15:56:38 +0800 | [diff] [blame] | 1331 | #ifdef CONFIG_CMD_UNZIP |
| 1332 | U_BOOT_CMD( |
| 1333 | unzip, 4, 1, do_unzip, |
| 1334 | "unzip - unzip a memory region\n", |
| 1335 | "srcaddr dstaddr [dstsize]\n" |
| 1336 | ); |
| 1337 | #endif /* CONFIG_CMD_UNZIP */ |
| 1338 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1339 | #endif |