blob: cdf8c798ddadaa8ec3fab859e6611af09ef5a06d [file] [log] [blame]
wdenk38635852002-08-27 05:55:31 +00001/*
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>
wdenk2abbe072003-06-16 23:50:08 +000032#ifdef CONFIG_HAS_DATAFLASH
33#include <dataflash.h>
34#endif
Sergei Poselenova6e6fc62008-04-09 16:09:41 +020035#include <watchdog.h>
wdenk38635852002-08-27 05:55:31 +000036
wdenk38635852002-08-27 05:55:31 +000037#ifdef CMD_MEM_DEBUG
38#define PRINTF(fmt,args...) printf (fmt ,##args)
39#else
40#define PRINTF(fmt,args...)
41#endif
42
43static int mod_mem(cmd_tbl_t *, int, int, int, char *[]);
44
45/* Display values from last command.
46 * Memory modify remembered values are different from display memory.
47 */
48uint dp_last_addr, dp_last_size;
49uint dp_last_length = 0x40;
50uint mm_last_addr, mm_last_size;
51
52static 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
60int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
61{
wdenk27b207f2003-07-24 23:38:38 +000062 ulong addr, length;
Grant Likelyc95c4282007-02-20 09:05:00 +010063#if defined(CONFIG_HAS_DATAFLASH)
64 ulong nbytes, linebytes;
65#endif
wdenk27b207f2003-07-24 23:38:38 +000066 int size;
wdenk38635852002-08-27 05:55:31 +000067 int rc = 0;
68
69 /* We use the last specified parameters, unless new ones are
70 * entered.
71 */
72 addr = dp_last_addr;
73 size = dp_last_size;
74 length = dp_last_length;
75
76 if (argc < 2) {
Peter Tyser62c3ae72009-01-27 18:03:10 -060077 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +000078 return 1;
79 }
80
81 if ((flag & CMD_FLAG_REPEAT) == 0) {
82 /* New command specified. Check for a size specification.
83 * Defaults to long if no or incorrect specification.
84 */
wdenk27b207f2003-07-24 23:38:38 +000085 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
86 return 1;
wdenk38635852002-08-27 05:55:31 +000087
88 /* Address is specified since argc > 1
89 */
90 addr = simple_strtoul(argv[1], NULL, 16);
91 addr += base_address;
92
93 /* If another parameter, it is the length to display.
94 * Length is the number of objects, not number of bytes.
95 */
96 if (argc > 2)
97 length = simple_strtoul(argv[2], NULL, 16);
98 }
99
Grant Likelyc95c4282007-02-20 09:05:00 +0100100#if defined(CONFIG_HAS_DATAFLASH)
wdenk38635852002-08-27 05:55:31 +0000101 /* Print the lines.
102 *
103 * We buffer all read data, so we can make sure data is read only
104 * once, and all accesses are with the specified bus width.
105 */
106 nbytes = length * size;
107 do {
108 char linebuf[DISP_LINE_LEN];
Grant Likelyc95c4282007-02-20 09:05:00 +0100109 void* p;
wdenk38635852002-08-27 05:55:31 +0000110 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
wdenk2abbe072003-06-16 23:50:08 +0000111
Grant Likelyc95c4282007-02-20 09:05:00 +0100112 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
113 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
114 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
wdenk8bde7f72003-06-27 21:31:46 +0000115
wdenk38635852002-08-27 05:55:31 +0000116 nbytes -= linebytes;
Grant Likelyc95c4282007-02-20 09:05:00 +0100117 addr += linebytes;
wdenk38635852002-08-27 05:55:31 +0000118 if (ctrlc()) {
119 rc = 1;
120 break;
121 }
122 } while (nbytes > 0);
Grant Likelyc95c4282007-02-20 09:05:00 +0100123#else
Mike Frysinger4c727c72008-02-04 19:26:56 -0500124
125# if defined(CONFIG_BLACKFIN)
126 /* See if we're trying to display L1 inst */
127 if (addr_bfin_on_chip_mem(addr)) {
128 char linebuf[DISP_LINE_LEN];
129 ulong linebytes, nbytes = length * size;
130 do {
131 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
132 memcpy(linebuf, (void *)addr, linebytes);
133 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
134
135 nbytes -= linebytes;
136 addr += linebytes;
137 if (ctrlc()) {
138 rc = 1;
139 break;
140 }
141 } while (nbytes > 0);
142 } else
143# endif
144
145 {
146 /* Print the lines. */
147 print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
148 addr += size*length;
149 }
Grant Likelyc95c4282007-02-20 09:05:00 +0100150#endif
wdenk38635852002-08-27 05:55:31 +0000151
152 dp_last_addr = addr;
153 dp_last_length = length;
154 dp_last_size = size;
155 return (rc);
156}
157
158int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
159{
160 return mod_mem (cmdtp, 1, flag, argc, argv);
161}
162int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
163{
164 return mod_mem (cmdtp, 0, flag, argc, argv);
165}
166
167int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
168{
wdenk27b207f2003-07-24 23:38:38 +0000169 ulong addr, writeval, count;
170 int size;
wdenk38635852002-08-27 05:55:31 +0000171
172 if ((argc < 3) || (argc > 4)) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600173 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +0000174 return 1;
175 }
176
177 /* Check for size specification.
178 */
wdenk27b207f2003-07-24 23:38:38 +0000179 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
180 return 1;
wdenk38635852002-08-27 05:55:31 +0000181
182 /* Address is specified since argc > 1
183 */
184 addr = simple_strtoul(argv[1], NULL, 16);
185 addr += base_address;
186
187 /* Get the value to write.
188 */
189 writeval = simple_strtoul(argv[2], NULL, 16);
190
191 /* Count ? */
192 if (argc == 4) {
193 count = simple_strtoul(argv[3], NULL, 16);
194 } else {
195 count = 1;
196 }
197
198 while (count-- > 0) {
199 if (size == 4)
200 *((ulong *)addr) = (ulong )writeval;
201 else if (size == 2)
202 *((ushort *)addr) = (ushort)writeval;
203 else
204 *((u_char *)addr) = (u_char)writeval;
205 addr += size;
206 }
207 return 0;
208}
209
stroese4aaf29b2004-12-16 17:42:39 +0000210#ifdef CONFIG_MX_CYCLIC
211int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
212{
213 int i;
214 ulong count;
215
216 if (argc < 4) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600217 cmd_usage(cmdtp);
stroese4aaf29b2004-12-16 17:42:39 +0000218 return 1;
219 }
220
221 count = simple_strtoul(argv[3], NULL, 10);
222
223 for (;;) {
224 do_mem_md (NULL, 0, 3, argv);
225
226 /* delay for <count> ms... */
227 for (i=0; i<count; i++)
228 udelay (1000);
229
230 /* check for ctrl-c to abort... */
231 if (ctrlc()) {
232 puts("Abort\n");
233 return 0;
234 }
235 }
236
237 return 0;
238}
239
240int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
241{
242 int i;
243 ulong count;
244
245 if (argc < 4) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600246 cmd_usage(cmdtp);
stroese4aaf29b2004-12-16 17:42:39 +0000247 return 1;
248 }
249
250 count = simple_strtoul(argv[3], NULL, 10);
251
252 for (;;) {
253 do_mem_mw (NULL, 0, 3, argv);
254
255 /* delay for <count> ms... */
256 for (i=0; i<count; i++)
257 udelay (1000);
258
259 /* check for ctrl-c to abort... */
260 if (ctrlc()) {
261 puts("Abort\n");
262 return 0;
263 }
264 }
265
266 return 0;
267}
268#endif /* CONFIG_MX_CYCLIC */
269
wdenk38635852002-08-27 05:55:31 +0000270int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
271{
wdenk27b207f2003-07-24 23:38:38 +0000272 ulong addr1, addr2, count, ngood;
273 int size;
wdenk38635852002-08-27 05:55:31 +0000274 int rcode = 0;
275
276 if (argc != 4) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600277 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +0000278 return 1;
279 }
280
281 /* Check for size specification.
282 */
wdenk27b207f2003-07-24 23:38:38 +0000283 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
284 return 1;
wdenk38635852002-08-27 05:55:31 +0000285
286 addr1 = simple_strtoul(argv[1], NULL, 16);
287 addr1 += base_address;
288
289 addr2 = simple_strtoul(argv[2], NULL, 16);
290 addr2 += base_address;
291
292 count = simple_strtoul(argv[3], NULL, 16);
293
wdenk2abbe072003-06-16 23:50:08 +0000294#ifdef CONFIG_HAS_DATAFLASH
295 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
wdenk4b9206e2004-03-23 22:14:11 +0000296 puts ("Comparison with DataFlash space not supported.\n\r");
wdenk2abbe072003-06-16 23:50:08 +0000297 return 0;
298 }
299#endif
300
Mike Frysinger4c727c72008-02-04 19:26:56 -0500301#ifdef CONFIG_BLACKFIN
302 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
303 puts ("Comparison with L1 instruction memory not supported.\n\r");
304 return 0;
305 }
306#endif
307
wdenk38635852002-08-27 05:55:31 +0000308 ngood = 0;
309
310 while (count-- > 0) {
311 if (size == 4) {
312 ulong word1 = *(ulong *)addr1;
313 ulong word2 = *(ulong *)addr2;
314 if (word1 != word2) {
315 printf("word at 0x%08lx (0x%08lx) "
316 "!= word at 0x%08lx (0x%08lx)\n",
317 addr1, word1, addr2, word2);
318 rcode = 1;
319 break;
320 }
321 }
322 else if (size == 2) {
323 ushort hword1 = *(ushort *)addr1;
324 ushort hword2 = *(ushort *)addr2;
325 if (hword1 != hword2) {
326 printf("halfword at 0x%08lx (0x%04x) "
327 "!= halfword at 0x%08lx (0x%04x)\n",
328 addr1, hword1, addr2, hword2);
329 rcode = 1;
330 break;
331 }
332 }
333 else {
334 u_char byte1 = *(u_char *)addr1;
335 u_char byte2 = *(u_char *)addr2;
336 if (byte1 != byte2) {
337 printf("byte at 0x%08lx (0x%02x) "
338 "!= byte at 0x%08lx (0x%02x)\n",
339 addr1, byte1, addr2, byte2);
340 rcode = 1;
341 break;
342 }
343 }
344 ngood++;
345 addr1 += size;
346 addr2 += size;
347 }
348
349 printf("Total of %ld %s%s were the same\n",
350 ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte",
351 ngood == 1 ? "" : "s");
352 return rcode;
353}
354
355int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
356{
wdenk27b207f2003-07-24 23:38:38 +0000357 ulong addr, dest, count;
358 int size;
wdenk38635852002-08-27 05:55:31 +0000359
360 if (argc != 4) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600361 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +0000362 return 1;
363 }
364
365 /* Check for size specification.
366 */
wdenk27b207f2003-07-24 23:38:38 +0000367 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
368 return 1;
wdenk38635852002-08-27 05:55:31 +0000369
370 addr = simple_strtoul(argv[1], NULL, 16);
371 addr += base_address;
372
373 dest = simple_strtoul(argv[2], NULL, 16);
374 dest += base_address;
375
376 count = simple_strtoul(argv[3], NULL, 16);
377
378 if (count == 0) {
379 puts ("Zero length ???\n");
380 return 1;
381 }
382
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200383#ifndef CONFIG_SYS_NO_FLASH
wdenk38635852002-08-27 05:55:31 +0000384 /* check if we are copying to Flash */
wdenk2abbe072003-06-16 23:50:08 +0000385 if ( (addr2info(dest) != NULL)
386#ifdef CONFIG_HAS_DATAFLASH
Kim B. Heino84d0c2f2008-03-03 10:39:13 +0200387 && (!addr_dataflash(dest))
wdenk2abbe072003-06-16 23:50:08 +0000388#endif
389 ) {
wdenk38635852002-08-27 05:55:31 +0000390 int rc;
391
wdenk4b9206e2004-03-23 22:14:11 +0000392 puts ("Copy to Flash... ");
wdenk38635852002-08-27 05:55:31 +0000393
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200394 rc = flash_write ((char *)addr, dest, count*size);
wdenk38635852002-08-27 05:55:31 +0000395 if (rc != 0) {
396 flash_perror (rc);
397 return (1);
398 }
399 puts ("done\n");
400 return 0;
401 }
402#endif
403
wdenk2abbe072003-06-16 23:50:08 +0000404#ifdef CONFIG_HAS_DATAFLASH
405 /* Check if we are copying from RAM or Flash to DataFlash */
406 if (addr_dataflash(dest) && !addr_dataflash(addr)){
407 int rc;
408
wdenk4b9206e2004-03-23 22:14:11 +0000409 puts ("Copy to DataFlash... ");
wdenk2abbe072003-06-16 23:50:08 +0000410
411 rc = write_dataflash (dest, addr, count*size);
412
413 if (rc != 1) {
414 dataflash_perror (rc);
415 return (1);
416 }
417 puts ("done\n");
418 return 0;
419 }
wdenk8bde7f72003-06-27 21:31:46 +0000420
wdenk2abbe072003-06-16 23:50:08 +0000421 /* Check if we are copying from DataFlash to RAM */
Stelian Pop880cc432008-03-26 22:52:35 +0100422 if (addr_dataflash(addr) && !addr_dataflash(dest)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200423#ifndef CONFIG_SYS_NO_FLASH
Stelian Pop880cc432008-03-26 22:52:35 +0100424 && (addr2info(dest) == NULL)
425#endif
426 ){
wdenk5779d8d2003-12-06 23:55:10 +0000427 int rc;
428 rc = read_dataflash(addr, count * size, (char *) dest);
429 if (rc != 1) {
wdenkd4ca31c2004-01-02 14:00:00 +0000430 dataflash_perror (rc);
431 return (1);
432 }
wdenk2abbe072003-06-16 23:50:08 +0000433 return 0;
434 }
435
436 if (addr_dataflash(addr) && addr_dataflash(dest)){
wdenk4b9206e2004-03-23 22:14:11 +0000437 puts ("Unsupported combination of source/destination.\n\r");
wdenk2abbe072003-06-16 23:50:08 +0000438 return 1;
439 }
440#endif
441
Mike Frysinger4c727c72008-02-04 19:26:56 -0500442#ifdef CONFIG_BLACKFIN
443 /* See if we're copying to/from L1 inst */
444 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
445 memcpy((void *)dest, (void *)addr, count * size);
446 return 0;
447 }
448#endif
449
wdenk38635852002-08-27 05:55:31 +0000450 while (count-- > 0) {
451 if (size == 4)
452 *((ulong *)dest) = *((ulong *)addr);
453 else if (size == 2)
454 *((ushort *)dest) = *((ushort *)addr);
455 else
456 *((u_char *)dest) = *((u_char *)addr);
457 addr += size;
458 dest += size;
459 }
460 return 0;
461}
462
463int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
464{
465 if (argc > 1) {
466 /* Set new base address.
467 */
468 base_address = simple_strtoul(argv[1], NULL, 16);
469 }
470 /* Print the current base address.
471 */
472 printf("Base Address: 0x%08lx\n", base_address);
473 return 0;
474}
475
476int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
477{
wdenk27b207f2003-07-24 23:38:38 +0000478 ulong addr, length, i, junk;
479 int size;
wdenk38635852002-08-27 05:55:31 +0000480 volatile uint *longp;
481 volatile ushort *shortp;
482 volatile u_char *cp;
483
484 if (argc < 3) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600485 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +0000486 return 1;
487 }
488
489 /* Check for a size spefication.
490 * Defaults to long if no or incorrect specification.
491 */
wdenk27b207f2003-07-24 23:38:38 +0000492 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
493 return 1;
wdenk38635852002-08-27 05:55:31 +0000494
495 /* Address is always specified.
496 */
497 addr = simple_strtoul(argv[1], NULL, 16);
498
499 /* Length is the number of objects, not number of bytes.
500 */
501 length = simple_strtoul(argv[2], NULL, 16);
502
503 /* We want to optimize the loops to run as fast as possible.
504 * If we have only one object, just run infinite loops.
505 */
506 if (length == 1) {
507 if (size == 4) {
508 longp = (uint *)addr;
509 for (;;)
510 i = *longp;
511 }
512 if (size == 2) {
513 shortp = (ushort *)addr;
514 for (;;)
515 i = *shortp;
516 }
517 cp = (u_char *)addr;
518 for (;;)
519 i = *cp;
520 }
521
522 if (size == 4) {
523 for (;;) {
524 longp = (uint *)addr;
525 i = length;
526 while (i-- > 0)
527 junk = *longp++;
528 }
529 }
530 if (size == 2) {
531 for (;;) {
532 shortp = (ushort *)addr;
533 i = length;
534 while (i-- > 0)
535 junk = *shortp++;
536 }
537 }
538 for (;;) {
539 cp = (u_char *)addr;
540 i = length;
541 while (i-- > 0)
542 junk = *cp++;
543 }
544}
545
wdenk56523f12004-07-11 17:40:54 +0000546#ifdef CONFIG_LOOPW
547int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
548{
549 ulong addr, length, i, data;
550 int size;
551 volatile uint *longp;
552 volatile ushort *shortp;
553 volatile u_char *cp;
wdenk81050922004-07-11 20:04:51 +0000554
wdenk56523f12004-07-11 17:40:54 +0000555 if (argc < 4) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600556 cmd_usage(cmdtp);
wdenk56523f12004-07-11 17:40:54 +0000557 return 1;
558 }
559
560 /* Check for a size spefication.
561 * Defaults to long if no or incorrect specification.
562 */
563 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
564 return 1;
565
566 /* Address is always specified.
567 */
568 addr = simple_strtoul(argv[1], NULL, 16);
569
570 /* Length is the number of objects, not number of bytes.
571 */
572 length = simple_strtoul(argv[2], NULL, 16);
573
574 /* data to write */
575 data = simple_strtoul(argv[3], NULL, 16);
wdenk81050922004-07-11 20:04:51 +0000576
wdenk56523f12004-07-11 17:40:54 +0000577 /* We want to optimize the loops to run as fast as possible.
578 * If we have only one object, just run infinite loops.
579 */
580 if (length == 1) {
581 if (size == 4) {
582 longp = (uint *)addr;
583 for (;;)
584 *longp = data;
585 }
586 if (size == 2) {
587 shortp = (ushort *)addr;
588 for (;;)
589 *shortp = data;
590 }
591 cp = (u_char *)addr;
592 for (;;)
593 *cp = data;
594 }
595
596 if (size == 4) {
597 for (;;) {
598 longp = (uint *)addr;
599 i = length;
600 while (i-- > 0)
601 *longp++ = data;
602 }
603 }
604 if (size == 2) {
605 for (;;) {
606 shortp = (ushort *)addr;
607 i = length;
608 while (i-- > 0)
609 *shortp++ = data;
610 }
611 }
612 for (;;) {
613 cp = (u_char *)addr;
614 i = length;
615 while (i-- > 0)
616 *cp++ = data;
617 }
618}
619#endif /* CONFIG_LOOPW */
620
wdenk38635852002-08-27 05:55:31 +0000621/*
622 * Perform a memory test. A more complete alternative test can be
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200623 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
wdenk38635852002-08-27 05:55:31 +0000624 * interrupted by ctrl-c or by a failure of one of the sub-tests.
625 */
626int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
627{
628 vu_long *addr, *start, *end;
629 ulong val;
630 ulong readback;
Guennadi Liakhovetski1f780aa2008-02-13 11:19:19 +0100631 int rcode = 0;
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100632 int iterations = 1;
633 int iteration_limit;
wdenk38635852002-08-27 05:55:31 +0000634
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200635#if defined(CONFIG_SYS_ALT_MEMTEST)
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100636 vu_long len;
wdenk38635852002-08-27 05:55:31 +0000637 vu_long offset;
638 vu_long test_offset;
639 vu_long pattern;
640 vu_long temp;
641 vu_long anti_pattern;
642 vu_long num_words;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200643#if defined(CONFIG_SYS_MEMTEST_SCRATCH)
644 vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
wdenk5f535fe2003-09-18 09:21:33 +0000645#else
Wolfgang Denk029b6dc2006-07-21 11:37:40 +0200646 vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */
wdenk5f535fe2003-09-18 09:21:33 +0000647#endif
wdenk38635852002-08-27 05:55:31 +0000648 int j;
wdenk38635852002-08-27 05:55:31 +0000649
650 static const ulong bitpattern[] = {
651 0x00000001, /* single bit */
652 0x00000003, /* two adjacent bits */
653 0x00000007, /* three adjacent bits */
654 0x0000000F, /* four adjacent bits */
655 0x00000005, /* two non-adjacent bits */
656 0x00000015, /* three non-adjacent bits */
657 0x00000055, /* four non-adjacent bits */
658 0xaaaaaaaa, /* alternating 1/0 */
659 };
660#else
661 ulong incr;
662 ulong pattern;
wdenk38635852002-08-27 05:55:31 +0000663#endif
664
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100665 if (argc > 1)
wdenk38635852002-08-27 05:55:31 +0000666 start = (ulong *)simple_strtoul(argv[1], NULL, 16);
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100667 else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200668 start = (ulong *)CONFIG_SYS_MEMTEST_START;
wdenk38635852002-08-27 05:55:31 +0000669
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100670 if (argc > 2)
wdenk38635852002-08-27 05:55:31 +0000671 end = (ulong *)simple_strtoul(argv[2], NULL, 16);
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100672 else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200673 end = (ulong *)(CONFIG_SYS_MEMTEST_END);
wdenk38635852002-08-27 05:55:31 +0000674
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100675 if (argc > 3)
wdenk38635852002-08-27 05:55:31 +0000676 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100677 else
wdenk38635852002-08-27 05:55:31 +0000678 pattern = 0;
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100679
680 if (argc > 4)
681 iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
682 else
683 iteration_limit = 0;
wdenk38635852002-08-27 05:55:31 +0000684
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200685#if defined(CONFIG_SYS_ALT_MEMTEST)
wdenk38635852002-08-27 05:55:31 +0000686 printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
687 PRINTF("%s:%d: start 0x%p end 0x%p\n",
688 __FUNCTION__, __LINE__, start, end);
689
690 for (;;) {
691 if (ctrlc()) {
692 putc ('\n');
693 return 1;
694 }
695
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100696
697 if (iteration_limit && iterations > iteration_limit) {
698 printf("Tested %d iteration(s) without errors.\n",
699 iterations-1);
700 return 0;
701 }
702
wdenk38635852002-08-27 05:55:31 +0000703 printf("Iteration: %6d\r", iterations);
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100704 PRINTF("\n");
wdenk38635852002-08-27 05:55:31 +0000705 iterations++;
706
707 /*
708 * Data line test: write a pattern to the first
709 * location, write the 1's complement to a 'parking'
710 * address (changes the state of the data bus so a
711 * floating bus doen't give a false OK), and then
712 * read the value back. Note that we read it back
713 * into a variable because the next time we read it,
714 * it might be right (been there, tough to explain to
715 * the quality guys why it prints a failure when the
716 * "is" and "should be" are obviously the same in the
717 * error message).
718 *
719 * Rather than exhaustively testing, we test some
720 * patterns by shifting '1' bits through a field of
721 * '0's and '0' bits through a field of '1's (i.e.
722 * pattern and ~pattern).
723 */
724 addr = start;
725 for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
726 val = bitpattern[j];
727 for(; val != 0; val <<= 1) {
728 *addr = val;
729 *dummy = ~val; /* clear the test data off of the bus */
730 readback = *addr;
731 if(readback != val) {
732 printf ("FAILURE (data line): "
733 "expected %08lx, actual %08lx\n",
734 val, readback);
735 }
736 *addr = ~val;
737 *dummy = val;
738 readback = *addr;
739 if(readback != ~val) {
740 printf ("FAILURE (data line): "
741 "Is %08lx, should be %08lx\n",
wdenke1599e82004-10-10 23:27:33 +0000742 readback, ~val);
wdenk38635852002-08-27 05:55:31 +0000743 }
744 }
745 }
746
747 /*
748 * Based on code whose Original Author and Copyright
749 * information follows: Copyright (c) 1998 by Michael
750 * Barr. This software is placed into the public
751 * domain and may be used for any purpose. However,
752 * this notice must not be changed or removed and no
753 * warranty is either expressed or implied by its
754 * publication or distribution.
755 */
756
757 /*
758 * Address line test
759 *
760 * Description: Test the address bus wiring in a
761 * memory region by performing a walking
762 * 1's test on the relevant bits of the
763 * address and checking for aliasing.
764 * This test will find single-bit
765 * address failures such as stuck -high,
766 * stuck-low, and shorted pins. The base
767 * address and size of the region are
768 * selected by the caller.
769 *
770 * Notes: For best results, the selected base
771 * address should have enough LSB 0's to
772 * guarantee single address bit changes.
773 * For example, to test a 64-Kbyte
774 * region, select a base address on a
775 * 64-Kbyte boundary. Also, select the
776 * region size as a power-of-two if at
777 * all possible.
778 *
779 * Returns: 0 if the test succeeds, 1 if the test fails.
wdenk38635852002-08-27 05:55:31 +0000780 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100781 len = ((ulong)end - (ulong)start)/sizeof(vu_long);
wdenk38635852002-08-27 05:55:31 +0000782 pattern = (vu_long) 0xaaaaaaaa;
783 anti_pattern = (vu_long) 0x55555555;
784
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100785 PRINTF("%s:%d: length = 0x%.8lx\n",
wdenk38635852002-08-27 05:55:31 +0000786 __FUNCTION__, __LINE__,
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100787 len);
wdenk38635852002-08-27 05:55:31 +0000788 /*
789 * Write the default pattern at each of the
790 * power-of-two offsets.
791 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100792 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000793 start[offset] = pattern;
794 }
795
796 /*
797 * Check for address bits stuck high.
798 */
799 test_offset = 0;
800 start[test_offset] = anti_pattern;
801
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100802 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000803 temp = start[offset];
804 if (temp != pattern) {
805 printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
806 " expected 0x%.8lx, actual 0x%.8lx\n",
807 (ulong)&start[offset], pattern, temp);
808 return 1;
809 }
810 }
811 start[test_offset] = pattern;
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200812 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000813
814 /*
815 * Check for addr bits stuck low or shorted.
816 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100817 for (test_offset = 1; test_offset < len; test_offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000818 start[test_offset] = anti_pattern;
819
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100820 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000821 temp = start[offset];
822 if ((temp != pattern) && (offset != test_offset)) {
823 printf ("\nFAILURE: Address bit stuck low or shorted @"
824 " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
825 (ulong)&start[offset], pattern, temp);
826 return 1;
827 }
828 }
829 start[test_offset] = pattern;
830 }
831
832 /*
833 * Description: Test the integrity of a physical
834 * memory device by performing an
835 * increment/decrement test over the
836 * entire region. In the process every
837 * storage bit in the device is tested
838 * as a zero and a one. The base address
839 * and the size of the region are
840 * selected by the caller.
841 *
842 * Returns: 0 if the test succeeds, 1 if the test fails.
843 */
844 num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
845
846 /*
847 * Fill memory with a known pattern.
848 */
849 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200850 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000851 start[offset] = pattern;
852 }
853
854 /*
855 * Check each location and invert it for the second pass.
856 */
857 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200858 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000859 temp = start[offset];
860 if (temp != pattern) {
861 printf ("\nFAILURE (read/write) @ 0x%.8lx:"
862 " expected 0x%.8lx, actual 0x%.8lx)\n",
863 (ulong)&start[offset], pattern, temp);
864 return 1;
865 }
866
867 anti_pattern = ~pattern;
868 start[offset] = anti_pattern;
869 }
870
871 /*
872 * Check each location for the inverted pattern and zero it.
873 */
874 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200875 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000876 anti_pattern = ~pattern;
877 temp = start[offset];
878 if (temp != anti_pattern) {
879 printf ("\nFAILURE (read/write): @ 0x%.8lx:"
880 " expected 0x%.8lx, actual 0x%.8lx)\n",
881 (ulong)&start[offset], anti_pattern, temp);
882 return 1;
883 }
884 start[offset] = 0;
885 }
886 }
887
888#else /* The original, quickie test */
889 incr = 1;
890 for (;;) {
891 if (ctrlc()) {
892 putc ('\n');
893 return 1;
894 }
895
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +0100896 if (iteration_limit && iterations > iteration_limit) {
897 printf("Tested %d iteration(s) without errors.\n",
898 iterations-1);
899 return 0;
900 }
901 ++iterations;
902
wdenk38635852002-08-27 05:55:31 +0000903 printf ("\rPattern %08lX Writing..."
904 "%12s"
905 "\b\b\b\b\b\b\b\b\b\b",
906 pattern, "");
907
908 for (addr=start,val=pattern; addr<end; addr++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200909 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000910 *addr = val;
911 val += incr;
912 }
913
wdenk4b9206e2004-03-23 22:14:11 +0000914 puts ("Reading...");
wdenk38635852002-08-27 05:55:31 +0000915
916 for (addr=start,val=pattern; addr<end; addr++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200917 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000918 readback = *addr;
919 if (readback != val) {
920 printf ("\nMem error @ 0x%08X: "
921 "found %08lX, expected %08lX\n",
922 (uint)addr, readback, val);
923 rcode = 1;
924 }
925 val += incr;
926 }
927
928 /*
929 * Flip the pattern each time to make lots of zeros and
930 * then, the next time, lots of ones. We decrement
931 * the "negative" patterns and increment the "positive"
932 * patterns to preserve this feature.
933 */
934 if(pattern & 0x80000000) {
935 pattern = -pattern; /* complement & increment */
936 }
937 else {
938 pattern = ~pattern;
939 }
940 incr = -incr;
941 }
wdenk38635852002-08-27 05:55:31 +0000942#endif
Guennadi Liakhovetski1f780aa2008-02-13 11:19:19 +0100943 return rcode;
wdenk38635852002-08-27 05:55:31 +0000944}
945
946
947/* Modify memory.
948 *
949 * Syntax:
950 * mm{.b, .w, .l} {addr}
951 * nm{.b, .w, .l} {addr}
952 */
953static int
954mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
955{
wdenk27b207f2003-07-24 23:38:38 +0000956 ulong addr, i;
957 int nbytes, size;
wdenk38635852002-08-27 05:55:31 +0000958 extern char console_buffer[];
959
960 if (argc != 2) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600961 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +0000962 return 1;
963 }
964
965#ifdef CONFIG_BOOT_RETRY_TIME
966 reset_cmd_timeout(); /* got a good command to get here */
967#endif
968 /* We use the last specified parameters, unless new ones are
969 * entered.
970 */
971 addr = mm_last_addr;
972 size = mm_last_size;
973
974 if ((flag & CMD_FLAG_REPEAT) == 0) {
975 /* New command specified. Check for a size specification.
976 * Defaults to long if no or incorrect specification.
977 */
wdenk27b207f2003-07-24 23:38:38 +0000978 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
979 return 1;
wdenk38635852002-08-27 05:55:31 +0000980
981 /* Address is specified since argc > 1
982 */
983 addr = simple_strtoul(argv[1], NULL, 16);
984 addr += base_address;
985 }
986
wdenk2abbe072003-06-16 23:50:08 +0000987#ifdef CONFIG_HAS_DATAFLASH
988 if (addr_dataflash(addr)){
wdenk4b9206e2004-03-23 22:14:11 +0000989 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
wdenk2abbe072003-06-16 23:50:08 +0000990 return 0;
991 }
992#endif
993
Mike Frysinger4c727c72008-02-04 19:26:56 -0500994#ifdef CONFIG_BLACKFIN
995 if (addr_bfin_on_chip_mem(addr)) {
996 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
997 return 0;
998 }
999#endif
1000
wdenk38635852002-08-27 05:55:31 +00001001 /* Print the address, followed by value. Then accept input for
1002 * the next value. A non-converted value exits.
1003 */
1004 do {
1005 printf("%08lx:", addr);
1006 if (size == 4)
1007 printf(" %08x", *((uint *)addr));
1008 else if (size == 2)
1009 printf(" %04x", *((ushort *)addr));
1010 else
1011 printf(" %02x", *((u_char *)addr));
1012
1013 nbytes = readline (" ? ");
1014 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1015 /* <CR> pressed as only input, don't modify current
1016 * location and move to next. "-" pressed will go back.
1017 */
1018 if (incrflag)
1019 addr += nbytes ? -size : size;
1020 nbytes = 1;
1021#ifdef CONFIG_BOOT_RETRY_TIME
1022 reset_cmd_timeout(); /* good enough to not time out */
1023#endif
1024 }
1025#ifdef CONFIG_BOOT_RETRY_TIME
1026 else if (nbytes == -2) {
1027 break; /* timed out, exit the command */
1028 }
1029#endif
1030 else {
1031 char *endp;
1032 i = simple_strtoul(console_buffer, &endp, 16);
1033 nbytes = endp - console_buffer;
1034 if (nbytes) {
1035#ifdef CONFIG_BOOT_RETRY_TIME
1036 /* good enough to not time out
1037 */
1038 reset_cmd_timeout();
1039#endif
1040 if (size == 4)
1041 *((uint *)addr) = i;
1042 else if (size == 2)
1043 *((ushort *)addr) = i;
1044 else
1045 *((u_char *)addr) = i;
1046 if (incrflag)
1047 addr += size;
1048 }
1049 }
1050 } while (nbytes);
1051
1052 mm_last_addr = addr;
1053 mm_last_size = size;
1054 return 0;
1055}
1056
wdenkc26e4542004-04-18 10:13:26 +00001057#ifndef CONFIG_CRC32_VERIFY
1058
wdenk38635852002-08-27 05:55:31 +00001059int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1060{
wdenk71f95112003-06-15 22:40:42 +00001061 ulong addr, length;
1062 ulong crc;
1063 ulong *ptr;
wdenk38635852002-08-27 05:55:31 +00001064
1065 if (argc < 3) {
Peter Tyser62c3ae72009-01-27 18:03:10 -06001066 cmd_usage(cmdtp);
wdenk38635852002-08-27 05:55:31 +00001067 return 1;
1068 }
1069
wdenk71f95112003-06-15 22:40:42 +00001070 addr = simple_strtoul (argv[1], NULL, 16);
wdenk38635852002-08-27 05:55:31 +00001071 addr += base_address;
1072
wdenk71f95112003-06-15 22:40:42 +00001073 length = simple_strtoul (argv[2], NULL, 16);
wdenk38635852002-08-27 05:55:31 +00001074
wdenk71f95112003-06-15 22:40:42 +00001075 crc = crc32 (0, (const uchar *) addr, length);
wdenk38635852002-08-27 05:55:31 +00001076
1077 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
wdenk71f95112003-06-15 22:40:42 +00001078 addr, addr + length - 1, crc);
wdenk38635852002-08-27 05:55:31 +00001079
wdenk71f95112003-06-15 22:40:42 +00001080 if (argc > 3) {
1081 ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
1082 *ptr = crc;
1083 }
wdenk38635852002-08-27 05:55:31 +00001084
1085 return 0;
1086}
1087
wdenkc26e4542004-04-18 10:13:26 +00001088#else /* CONFIG_CRC32_VERIFY */
1089
1090int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1091{
1092 ulong addr, length;
1093 ulong crc;
1094 ulong *ptr;
wdenk6e592382004-04-18 17:39:38 +00001095 ulong vcrc;
wdenkc26e4542004-04-18 10:13:26 +00001096 int verify;
1097 int ac;
1098 char **av;
1099
1100 if (argc < 3) {
1101 usage:
Peter Tyser62c3ae72009-01-27 18:03:10 -06001102 cmd_usage(cmdtp);
wdenkc26e4542004-04-18 10:13:26 +00001103 return 1;
1104 }
1105
1106 av = argv + 1;
1107 ac = argc - 1;
1108 if (strcmp(*av, "-v") == 0) {
1109 verify = 1;
1110 av++;
1111 ac--;
1112 if (ac < 3)
1113 goto usage;
1114 } else
1115 verify = 0;
1116
1117 addr = simple_strtoul(*av++, NULL, 16);
1118 addr += base_address;
1119 length = simple_strtoul(*av++, NULL, 16);
1120
1121 crc = crc32(0, (const uchar *) addr, length);
1122
1123 if (!verify) {
1124 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1125 addr, addr + length - 1, crc);
1126 if (ac > 2) {
1127 ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
1128 *ptr = crc;
1129 }
1130 } else {
1131 vcrc = simple_strtoul(*av++, NULL, 16);
1132 if (vcrc != crc) {
1133 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1134 addr, addr + length - 1, crc, vcrc);
1135 return 1;
1136 }
1137 }
1138
1139 return 0;
1140
1141}
1142#endif /* CONFIG_CRC32_VERIFY */
1143
Harald Weltefe2ce552008-07-06 15:56:38 +08001144
1145#ifdef CONFIG_CMD_UNZIP
1146int gunzip (void *, int, unsigned char *, unsigned long *);
1147
1148int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1149{
1150 unsigned long src, dst;
1151 unsigned long src_len = ~0UL, dst_len = ~0UL;
Harald Weltefe2ce552008-07-06 15:56:38 +08001152
1153 switch (argc) {
1154 case 4:
1155 dst_len = simple_strtoul(argv[3], NULL, 16);
1156 /* fall through */
1157 case 3:
1158 src = simple_strtoul(argv[1], NULL, 16);
1159 dst = simple_strtoul(argv[2], NULL, 16);
1160 break;
1161 default:
Peter Tyser62c3ae72009-01-27 18:03:10 -06001162 cmd_usage(cmdtp);
Harald Weltefe2ce552008-07-06 15:56:38 +08001163 return 1;
1164 }
1165
1166 return !!gunzip((void *) dst, dst_len, (void *) src, &src_len);
1167}
1168#endif /* CONFIG_CMD_UNZIP */
1169
1170
wdenk8bde7f72003-06-27 21:31:46 +00001171/**************************************************/
wdenk0d498392003-07-01 21:06:45 +00001172U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001173 md, 3, 1, do_mem_md,
Peter Tyser2fb26042009-01-27 18:03:12 -06001174 "memory display",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001175 "[.b, .w, .l] address [# of objects]"
wdenk8bde7f72003-06-27 21:31:46 +00001176);
1177
1178
wdenk0d498392003-07-01 21:06:45 +00001179U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001180 mm, 2, 1, do_mem_mm,
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001181 "memory modify (auto-incrementing address)",
1182 "[.b, .w, .l] address"
wdenk8bde7f72003-06-27 21:31:46 +00001183);
1184
1185
wdenk0d498392003-07-01 21:06:45 +00001186U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001187 nm, 2, 1, do_mem_nm,
Peter Tyser2fb26042009-01-27 18:03:12 -06001188 "memory modify (constant address)",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001189 "[.b, .w, .l] address"
wdenk8bde7f72003-06-27 21:31:46 +00001190);
1191
wdenk0d498392003-07-01 21:06:45 +00001192U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001193 mw, 4, 1, do_mem_mw,
Peter Tyser2fb26042009-01-27 18:03:12 -06001194 "memory write (fill)",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001195 "[.b, .w, .l] address value [count]"
wdenk8bde7f72003-06-27 21:31:46 +00001196);
1197
wdenk0d498392003-07-01 21:06:45 +00001198U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001199 cp, 4, 1, do_mem_cp,
Peter Tyser2fb26042009-01-27 18:03:12 -06001200 "memory copy",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001201 "[.b, .w, .l] source target count"
wdenk8bde7f72003-06-27 21:31:46 +00001202);
1203
wdenk0d498392003-07-01 21:06:45 +00001204U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001205 cmp, 4, 1, do_mem_cmp,
Peter Tyser2fb26042009-01-27 18:03:12 -06001206 "memory compare",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001207 "[.b, .w, .l] addr1 addr2 count"
wdenk8bde7f72003-06-27 21:31:46 +00001208);
1209
wdenkc26e4542004-04-18 10:13:26 +00001210#ifndef CONFIG_CRC32_VERIFY
1211
wdenk0d498392003-07-01 21:06:45 +00001212U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001213 crc32, 4, 1, do_mem_crc,
Peter Tyser2fb26042009-01-27 18:03:12 -06001214 "checksum calculation",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001215 "address count [addr]\n - compute CRC32 checksum [save at addr]"
wdenk8bde7f72003-06-27 21:31:46 +00001216);
1217
wdenkc26e4542004-04-18 10:13:26 +00001218#else /* CONFIG_CRC32_VERIFY */
1219
1220U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001221 crc32, 5, 1, do_mem_crc,
Peter Tyser2fb26042009-01-27 18:03:12 -06001222 "checksum calculation",
wdenkc26e4542004-04-18 10:13:26 +00001223 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001224 "-v address count crc\n - verify crc of memory area"
wdenkc26e4542004-04-18 10:13:26 +00001225);
1226
1227#endif /* CONFIG_CRC32_VERIFY */
1228
wdenk0d498392003-07-01 21:06:45 +00001229U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001230 base, 2, 1, do_mem_base,
Peter Tyser2fb26042009-01-27 18:03:12 -06001231 "print or set address offset",
wdenk8bde7f72003-06-27 21:31:46 +00001232 "\n - print address offset for memory commands\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001233 "base off\n - set address offset for memory commands to 'off'"
wdenk8bde7f72003-06-27 21:31:46 +00001234);
1235
wdenk0d498392003-07-01 21:06:45 +00001236U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001237 loop, 3, 1, do_mem_loop,
Peter Tyser2fb26042009-01-27 18:03:12 -06001238 "infinite loop on address range",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001239 "[.b, .w, .l] address number_of_objects"
wdenk8bde7f72003-06-27 21:31:46 +00001240);
1241
wdenk56523f12004-07-11 17:40:54 +00001242#ifdef CONFIG_LOOPW
1243U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001244 loopw, 4, 1, do_mem_loopw,
Peter Tyser2fb26042009-01-27 18:03:12 -06001245 "infinite write loop on address range",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001246 "[.b, .w, .l] address number_of_objects data_to_write"
wdenk56523f12004-07-11 17:40:54 +00001247);
1248#endif /* CONFIG_LOOPW */
1249
wdenk0d498392003-07-01 21:06:45 +00001250U_BOOT_CMD(
Dirk Eibachb6fc6fd2008-12-16 14:51:56 +01001251 mtest, 5, 1, do_mem_mtest,
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001252 "simple RAM read/write test",
1253 "[start [end [pattern [iterations]]]]"
wdenk8bde7f72003-06-27 21:31:46 +00001254);
1255
stroese4aaf29b2004-12-16 17:42:39 +00001256#ifdef CONFIG_MX_CYCLIC
1257U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001258 mdc, 4, 1, do_mem_mdc,
Peter Tyser2fb26042009-01-27 18:03:12 -06001259 "memory display cyclic",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001260 "[.b, .w, .l] address count delay(ms)"
stroese4aaf29b2004-12-16 17:42:39 +00001261);
1262
1263U_BOOT_CMD(
Wolfgang Denk53677ef2008-05-20 16:00:29 +02001264 mwc, 4, 1, do_mem_mwc,
Peter Tyser2fb26042009-01-27 18:03:12 -06001265 "memory write cyclic",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001266 "[.b, .w, .l] address value delay(ms)"
stroese4aaf29b2004-12-16 17:42:39 +00001267);
1268#endif /* CONFIG_MX_CYCLIC */
1269
Harald Weltefe2ce552008-07-06 15:56:38 +08001270#ifdef CONFIG_CMD_UNZIP
1271U_BOOT_CMD(
1272 unzip, 4, 1, do_unzip,
Peter Tyser2fb26042009-01-27 18:03:12 -06001273 "unzip a memory region",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001274 "srcaddr dstaddr [dstsize]"
Harald Weltefe2ce552008-07-06 15:56:38 +08001275);
1276#endif /* CONFIG_CMD_UNZIP */