3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
27 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
32 #ifdef CONFIG_HAS_DATAFLASH
33 #include <dataflash.h>
38 #define PRINTF(fmt,args...) printf (fmt ,##args)
40 #define PRINTF(fmt,args...)
43 static int mod_mem(cmd_tbl_t
*, int, int, int, char * const []);
45 /* Display values from last command.
46 * Memory modify remembered values are different from display memory.
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
;
52 static ulong base_address
= 0;
57 * md{.b, .w, .l} {addr} {len}
59 #define DISP_LINE_LEN 16
60 int do_mem_md ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
63 #if defined(CONFIG_HAS_DATAFLASH)
64 ulong nbytes
, linebytes
;
69 /* We use the last specified parameters, unless new ones are
74 length
= dp_last_length
;
77 return cmd_usage(cmdtp
);
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.
83 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
86 /* Address is specified since argc > 1
88 addr
= simple_strtoul(argv
[1], NULL
, 16);
91 /* If another parameter, it is the length to display.
92 * Length is the number of objects, not number of bytes.
95 length
= simple_strtoul(argv
[2], NULL
, 16);
98 #if defined(CONFIG_HAS_DATAFLASH)
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.
104 nbytes
= length
* size
;
106 char linebuf
[DISP_LINE_LEN
];
108 linebytes
= (nbytes
>DISP_LINE_LEN
)?DISP_LINE_LEN
:nbytes
;
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
);
120 } while (nbytes
> 0);
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
;
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
);
139 } while (nbytes
> 0);
144 /* Print the lines. */
145 print_buffer(addr
, (void*)addr
, size
, length
, DISP_LINE_LEN
/size
);
151 dp_last_length
= length
;
156 int do_mem_mm ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
158 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
160 int do_mem_nm ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
162 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
165 int do_mem_mw ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
167 ulong addr
, writeval
, count
;
170 if ((argc
< 3) || (argc
> 4))
171 return cmd_usage(cmdtp
);
173 /* Check for size specification.
175 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
178 /* Address is specified since argc > 1
180 addr
= simple_strtoul(argv
[1], NULL
, 16);
181 addr
+= base_address
;
183 /* Get the value to write.
185 writeval
= simple_strtoul(argv
[2], NULL
, 16);
189 count
= simple_strtoul(argv
[3], NULL
, 16);
194 while (count
-- > 0) {
196 *((ulong
*)addr
) = (ulong
)writeval
;
198 *((ushort
*)addr
) = (ushort
)writeval
;
200 *((u_char
*)addr
) = (u_char
)writeval
;
206 #ifdef CONFIG_MX_CYCLIC
207 int do_mem_mdc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
213 return cmd_usage(cmdtp
);
215 count
= simple_strtoul(argv
[3], NULL
, 10);
218 do_mem_md (NULL
, 0, 3, argv
);
220 /* delay for <count> ms... */
221 for (i
=0; i
<count
; i
++)
224 /* check for ctrl-c to abort... */
234 int do_mem_mwc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
240 return cmd_usage(cmdtp
);
242 count
= simple_strtoul(argv
[3], NULL
, 10);
245 do_mem_mw (NULL
, 0, 3, argv
);
247 /* delay for <count> ms... */
248 for (i
=0; i
<count
; i
++)
251 /* check for ctrl-c to abort... */
260 #endif /* CONFIG_MX_CYCLIC */
262 int do_mem_cmp (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
264 ulong addr1
, addr2
, count
, ngood
;
269 return cmd_usage(cmdtp
);
271 /* Check for size specification.
273 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
276 addr1
= simple_strtoul(argv
[1], NULL
, 16);
277 addr1
+= base_address
;
279 addr2
= simple_strtoul(argv
[2], NULL
, 16);
280 addr2
+= base_address
;
282 count
= simple_strtoul(argv
[3], NULL
, 16);
284 #ifdef CONFIG_HAS_DATAFLASH
285 if (addr_dataflash(addr1
) | addr_dataflash(addr2
)){
286 puts ("Comparison with DataFlash space not supported.\n\r");
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");
300 while (count
-- > 0) {
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
);
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
);
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
);
338 /* reset watchdog from time to time */
339 if ((count
% (64 << 10)) == 0)
343 printf("Total of %ld %s%s were the same\n",
344 ngood
, size
== 4 ? "word" : size
== 2 ? "halfword" : "byte",
345 ngood
== 1 ? "" : "s");
349 int do_mem_cp ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
351 ulong addr
, dest
, count
;
355 return cmd_usage(cmdtp
);
357 /* Check for size specification.
359 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
362 addr
= simple_strtoul(argv
[1], NULL
, 16);
363 addr
+= base_address
;
365 dest
= simple_strtoul(argv
[2], NULL
, 16);
366 dest
+= base_address
;
368 count
= simple_strtoul(argv
[3], NULL
, 16);
371 puts ("Zero length ???\n");
375 #ifndef CONFIG_SYS_NO_FLASH
376 /* check if we are copying to Flash */
377 if ( (addr2info(dest
) != NULL
)
378 #ifdef CONFIG_HAS_DATAFLASH
379 && (!addr_dataflash(dest
))
384 puts ("Copy to Flash... ");
386 rc
= flash_write ((char *)addr
, dest
, count
*size
);
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
)){
401 puts ("Copy to DataFlash... ");
403 rc
= write_dataflash (dest
, addr
, count
*size
);
406 dataflash_perror (rc
);
413 /* Check if we are copying from DataFlash to RAM */
414 if (addr_dataflash(addr
) && !addr_dataflash(dest
)
415 #ifndef CONFIG_SYS_NO_FLASH
416 && (addr2info(dest
) == NULL
)
420 rc
= read_dataflash(addr
, count
* size
, (char *) dest
);
422 dataflash_perror (rc
);
428 if (addr_dataflash(addr
) && addr_dataflash(dest
)){
429 puts ("Unsupported combination of source/destination.\n\r");
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
);
442 while (count
-- > 0) {
444 *((ulong
*)dest
) = *((ulong
*)addr
);
446 *((ushort
*)dest
) = *((ushort
*)addr
);
448 *((u_char
*)dest
) = *((u_char
*)addr
);
452 /* reset watchdog from time to time */
453 if ((count
% (64 << 10)) == 0)
459 int do_mem_base (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
462 /* Set new base address.
464 base_address
= simple_strtoul(argv
[1], NULL
, 16);
466 /* Print the current base address.
468 printf("Base Address: 0x%08lx\n", base_address
);
472 int do_mem_loop (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
474 ulong addr
, length
, i
;
476 volatile uint
*longp
;
477 volatile ushort
*shortp
;
481 return cmd_usage(cmdtp
);
483 /* Check for a size spefication.
484 * Defaults to long if no or incorrect specification.
486 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
489 /* Address is always specified.
491 addr
= simple_strtoul(argv
[1], NULL
, 16);
493 /* Length is the number of objects, not number of bytes.
495 length
= simple_strtoul(argv
[2], NULL
, 16);
497 /* We want to optimize the loops to run as fast as possible.
498 * If we have only one object, just run infinite loops.
502 longp
= (uint
*)addr
;
507 shortp
= (ushort
*)addr
;
518 longp
= (uint
*)addr
;
526 shortp
= (ushort
*)addr
;
541 int do_mem_loopw (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
543 ulong addr
, length
, i
, data
;
545 volatile uint
*longp
;
546 volatile ushort
*shortp
;
550 return cmd_usage(cmdtp
);
552 /* Check for a size spefication.
553 * Defaults to long if no or incorrect specification.
555 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
558 /* Address is always specified.
560 addr
= simple_strtoul(argv
[1], NULL
, 16);
562 /* Length is the number of objects, not number of bytes.
564 length
= simple_strtoul(argv
[2], NULL
, 16);
567 data
= simple_strtoul(argv
[3], NULL
, 16);
569 /* We want to optimize the loops to run as fast as possible.
570 * If we have only one object, just run infinite loops.
574 longp
= (uint
*)addr
;
579 shortp
= (ushort
*)addr
;
590 longp
= (uint
*)addr
;
598 shortp
= (ushort
*)addr
;
611 #endif /* CONFIG_LOOPW */
614 * Perform a memory test. A more complete alternative test can be
615 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
616 * interrupted by ctrl-c or by a failure of one of the sub-tests.
618 int do_mem_mtest (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
620 vu_long
*addr
, *start
, *end
;
627 #if defined(CONFIG_SYS_ALT_MEMTEST)
633 vu_long anti_pattern
;
635 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
636 vu_long
*dummy
= (vu_long
*)CONFIG_SYS_MEMTEST_SCRATCH
;
638 vu_long
*dummy
= 0; /* yes, this is address 0x0, not NULL */
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 */
658 start
= (ulong
*)simple_strtoul(argv
[1], NULL
, 16);
660 start
= (ulong
*)CONFIG_SYS_MEMTEST_START
;
663 end
= (ulong
*)simple_strtoul(argv
[2], NULL
, 16);
665 end
= (ulong
*)(CONFIG_SYS_MEMTEST_END
);
668 pattern
= (ulong
)simple_strtoul(argv
[3], NULL
, 16);
673 iteration_limit
= (ulong
)simple_strtoul(argv
[4], NULL
, 16);
677 #if defined(CONFIG_SYS_ALT_MEMTEST)
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
);
689 if (iteration_limit
&& iterations
> iteration_limit
) {
690 printf("Tested %d iteration(s) with %lu errors.\n",
695 printf("Iteration: %6d\r", iterations
);
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
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).
717 for (j
= 0; j
< sizeof(bitpattern
)/sizeof(bitpattern
[0]); j
++) {
719 for(; val
!= 0; val
<<= 1) {
721 *dummy
= ~val
; /* clear the test data off of the bus */
723 if(readback
!= val
) {
724 printf ("FAILURE (data line): "
725 "expected %08lx, actual %08lx\n",
736 if(readback
!= ~val
) {
737 printf ("FAILURE (data line): "
738 "Is %08lx, should be %08lx\n",
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.
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.
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
781 * Returns: 0 if the test succeeds, 1 if the test fails.
783 len
= ((ulong
)end
- (ulong
)start
)/sizeof(vu_long
);
784 pattern
= (vu_long
) 0xaaaaaaaa;
785 anti_pattern
= (vu_long
) 0x55555555;
787 PRINTF("%s:%d: length = 0x%.8lx\n",
788 __FUNCTION__
, __LINE__
,
791 * Write the default pattern at each of the
792 * power-of-two offsets.
794 for (offset
= 1; offset
< len
; offset
<<= 1) {
795 start
[offset
] = pattern
;
799 * Check for address bits stuck high.
802 start
[test_offset
] = anti_pattern
;
804 for (offset
= 1; offset
< len
; offset
<<= 1) {
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
);
817 start
[test_offset
] = pattern
;
821 * Check for addr bits stuck low or shorted.
823 for (test_offset
= 1; test_offset
< len
; test_offset
<<= 1) {
824 start
[test_offset
] = anti_pattern
;
826 for (offset
= 1; offset
< len
; offset
<<= 1) {
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
);
839 start
[test_offset
] = pattern
;
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.
852 * Returns: 0 if the test succeeds, 1 if the test fails.
854 num_words
= ((ulong
)end
- (ulong
)start
)/sizeof(vu_long
) + 1;
857 * Fill memory with a known pattern.
859 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
861 start
[offset
] = pattern
;
865 * Check each location and invert it for the second pass.
867 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
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
);
881 anti_pattern
= ~pattern
;
882 start
[offset
] = anti_pattern
;
886 * Check each location for the inverted pattern and zero it.
888 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
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
);
906 #else /* The original, quickie test */
914 if (iteration_limit
&& iterations
> iteration_limit
) {
915 printf("Tested %d iteration(s) with %lu errors.\n",
921 printf ("\rPattern %08lX Writing..."
923 "\b\b\b\b\b\b\b\b\b\b",
926 for (addr
=start
,val
=pattern
; addr
<end
; addr
++) {
934 for (addr
=start
,val
=pattern
; addr
<end
; addr
++) {
937 if (readback
!= val
) {
938 printf ("\nMem error @ 0x%08X: "
939 "found %08lX, expected %08lX\n",
940 (uint
)(uintptr_t)addr
, readback
, val
);
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.
956 if(pattern
& 0x80000000) {
957 pattern
= -pattern
; /* complement & increment */
965 return 0; /* not reached */
972 * mm{.b, .w, .l} {addr}
973 * nm{.b, .w, .l} {addr}
976 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char * const argv
[])
982 return cmd_usage(cmdtp
);
984 #ifdef CONFIG_BOOT_RETRY_TIME
985 reset_cmd_timeout(); /* got a good command to get here */
987 /* We use the last specified parameters, unless new ones are
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.
997 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
1000 /* Address is specified since argc > 1
1002 addr
= simple_strtoul(argv
[1], NULL
, 16);
1003 addr
+= base_address
;
1006 #ifdef CONFIG_HAS_DATAFLASH
1007 if (addr_dataflash(addr
)){
1008 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
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");
1020 /* Print the address, followed by value. Then accept input for
1021 * the next value. A non-converted value exits.
1024 printf("%08lx:", addr
);
1026 printf(" %08x", *((uint
*)addr
));
1028 printf(" %04x", *((ushort
*)addr
));
1030 printf(" %02x", *((u_char
*)addr
));
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.
1038 addr
+= nbytes
? -size
: size
;
1040 #ifdef CONFIG_BOOT_RETRY_TIME
1041 reset_cmd_timeout(); /* good enough to not time out */
1044 #ifdef CONFIG_BOOT_RETRY_TIME
1045 else if (nbytes
== -2) {
1046 break; /* timed out, exit the command */
1051 i
= simple_strtoul(console_buffer
, &endp
, 16);
1052 nbytes
= endp
- console_buffer
;
1054 #ifdef CONFIG_BOOT_RETRY_TIME
1055 /* good enough to not time out
1057 reset_cmd_timeout();
1060 *((uint
*)addr
) = i
;
1062 *((ushort
*)addr
) = i
;
1064 *((u_char
*)addr
) = i
;
1071 mm_last_addr
= addr
;
1072 mm_last_size
= size
;
1076 #ifdef CONFIG_CMD_CRC32
1078 #ifndef CONFIG_CRC32_VERIFY
1080 int do_mem_crc (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1087 return cmd_usage(cmdtp
);
1089 addr
= simple_strtoul (argv
[1], NULL
, 16);
1090 addr
+= base_address
;
1092 length
= simple_strtoul (argv
[2], NULL
, 16);
1094 crc
= crc32_wd (0, (const uchar
*) addr
, length
, CHUNKSZ_CRC32
);
1096 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1097 addr
, addr
+ length
- 1, crc
);
1100 ptr
= (ulong
*) simple_strtoul (argv
[3], NULL
, 16);
1107 #else /* CONFIG_CRC32_VERIFY */
1109 int do_mem_crc (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1121 return cmd_usage(cmdtp
);
1126 if (strcmp(*av
, "-v") == 0) {
1135 addr
= simple_strtoul(*av
++, NULL
, 16);
1136 addr
+= base_address
;
1137 length
= simple_strtoul(*av
++, NULL
, 16);
1139 crc
= crc32_wd (0, (const uchar
*) addr
, length
, CHUNKSZ_CRC32
);
1142 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1143 addr
, addr
+ length
- 1, crc
);
1145 ptr
= (ulong
*) simple_strtoul (*av
++, NULL
, 16);
1149 vcrc
= simple_strtoul(*av
++, NULL
, 16);
1151 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1152 addr
, addr
+ length
- 1, crc
, vcrc
);
1160 #endif /* CONFIG_CRC32_VERIFY */
1164 /**************************************************/
1166 md
, 3, 1, do_mem_md
,
1168 "[.b, .w, .l] address [# of objects]"
1173 mm
, 2, 1, do_mem_mm
,
1174 "memory modify (auto-incrementing address)",
1175 "[.b, .w, .l] address"
1180 nm
, 2, 1, do_mem_nm
,
1181 "memory modify (constant address)",
1182 "[.b, .w, .l] address"
1186 mw
, 4, 1, do_mem_mw
,
1187 "memory write (fill)",
1188 "[.b, .w, .l] address value [count]"
1192 cp
, 4, 1, do_mem_cp
,
1194 "[.b, .w, .l] source target count"
1198 cmp
, 4, 1, do_mem_cmp
,
1200 "[.b, .w, .l] addr1 addr2 count"
1203 #ifdef CONFIG_CMD_CRC32
1205 #ifndef CONFIG_CRC32_VERIFY
1208 crc32
, 4, 1, do_mem_crc
,
1209 "checksum calculation",
1210 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1213 #else /* CONFIG_CRC32_VERIFY */
1216 crc32
, 5, 1, do_mem_crc
,
1217 "checksum calculation",
1218 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1219 "-v address count crc\n - verify crc of memory area"
1222 #endif /* CONFIG_CRC32_VERIFY */
1227 base
, 2, 1, do_mem_base
,
1228 "print or set address offset",
1229 "\n - print address offset for memory commands\n"
1230 "base off\n - set address offset for memory commands to 'off'"
1234 loop
, 3, 1, do_mem_loop
,
1235 "infinite loop on address range",
1236 "[.b, .w, .l] address number_of_objects"
1241 loopw
, 4, 1, do_mem_loopw
,
1242 "infinite write loop on address range",
1243 "[.b, .w, .l] address number_of_objects data_to_write"
1245 #endif /* CONFIG_LOOPW */
1248 mtest
, 5, 1, do_mem_mtest
,
1249 "simple RAM read/write test",
1250 "[start [end [pattern [iterations]]]]"
1253 #ifdef CONFIG_MX_CYCLIC
1255 mdc
, 4, 1, do_mem_mdc
,
1256 "memory display cyclic",
1257 "[.b, .w, .l] address count delay(ms)"
1261 mwc
, 4, 1, do_mem_mwc
,
1262 "memory write cyclic",
1263 "[.b, .w, .l] address value delay(ms)"
1265 #endif /* CONFIG_MX_CYCLIC */