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