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