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