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>
37 #include <linux/compiler.h>
39 DECLARE_GLOBAL_DATA_PTR
;
41 static int mod_mem(cmd_tbl_t
*, int, int, int, char * const []);
43 /* Display values from last command.
44 * Memory modify remembered values are different from display memory.
46 static uint dp_last_addr
, dp_last_size
;
47 static uint dp_last_length
= 0x40;
48 static uint mm_last_addr
, mm_last_size
;
50 static ulong base_address
= 0;
55 * md{.b, .w, .l} {addr} {len}
57 #define DISP_LINE_LEN 16
58 static int do_mem_md(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
61 #if defined(CONFIG_HAS_DATAFLASH)
62 ulong nbytes
, linebytes
;
67 /* We use the last specified parameters, unless new ones are
72 length
= dp_last_length
;
77 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
78 /* New command specified. Check for a size specification.
79 * Defaults to long if no or incorrect specification.
81 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
84 /* Address is specified since argc > 1
86 addr
= simple_strtoul(argv
[1], NULL
, 16);
89 /* If another parameter, it is the length to display.
90 * Length is the number of objects, not number of bytes.
93 length
= simple_strtoul(argv
[2], NULL
, 16);
96 #if defined(CONFIG_HAS_DATAFLASH)
99 * We buffer all read data, so we can make sure data is read only
100 * once, and all accesses are with the specified bus width.
102 nbytes
= length
* size
;
104 char linebuf
[DISP_LINE_LEN
];
106 linebytes
= (nbytes
>DISP_LINE_LEN
)?DISP_LINE_LEN
:nbytes
;
108 rc
= read_dataflash(addr
, (linebytes
/size
)*size
, linebuf
);
109 p
= (rc
== DATAFLASH_OK
) ? linebuf
: (void*)addr
;
110 print_buffer(addr
, p
, size
, linebytes
/size
, DISP_LINE_LEN
/size
);
118 } while (nbytes
> 0);
121 # if defined(CONFIG_BLACKFIN)
122 /* See if we're trying to display L1 inst */
123 if (addr_bfin_on_chip_mem(addr
)) {
124 char linebuf
[DISP_LINE_LEN
];
125 ulong linebytes
, nbytes
= length
* size
;
127 linebytes
= (nbytes
> DISP_LINE_LEN
) ? DISP_LINE_LEN
: nbytes
;
128 memcpy(linebuf
, (void *)addr
, linebytes
);
129 print_buffer(addr
, linebuf
, size
, linebytes
/size
, DISP_LINE_LEN
/size
);
137 } while (nbytes
> 0);
142 ulong bytes
= size
* length
;
143 const void *buf
= map_sysmem(addr
, bytes
);
145 /* Print the lines. */
146 print_buffer(addr
, buf
, size
, length
, DISP_LINE_LEN
/ size
);
153 dp_last_length
= length
;
158 static int do_mem_mm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
160 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
162 static int do_mem_nm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
164 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
167 static int do_mem_mw(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
169 ulong addr
, writeval
, count
;
174 if ((argc
< 3) || (argc
> 4))
175 return CMD_RET_USAGE
;
177 /* Check for size specification.
179 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
182 /* Address is specified since argc > 1
184 addr
= simple_strtoul(argv
[1], NULL
, 16);
185 addr
+= base_address
;
187 /* Get the value to write.
189 writeval
= simple_strtoul(argv
[2], NULL
, 16);
193 count
= simple_strtoul(argv
[3], NULL
, 16);
198 bytes
= size
* count
;
199 buf
= map_sysmem(addr
, bytes
);
200 while (count
-- > 0) {
202 *((ulong
*)buf
) = (ulong
)writeval
;
204 *((ushort
*)buf
) = (ushort
)writeval
;
206 *((u_char
*)buf
) = (u_char
)writeval
;
213 #ifdef CONFIG_MX_CYCLIC
214 int do_mem_mdc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
220 return CMD_RET_USAGE
;
222 count
= simple_strtoul(argv
[3], NULL
, 10);
225 do_mem_md (NULL
, 0, 3, argv
);
227 /* delay for <count> ms... */
228 for (i
=0; i
<count
; i
++)
231 /* check for ctrl-c to abort... */
241 int do_mem_mwc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
247 return CMD_RET_USAGE
;
249 count
= simple_strtoul(argv
[3], NULL
, 10);
252 do_mem_mw (NULL
, 0, 3, argv
);
254 /* delay for <count> ms... */
255 for (i
=0; i
<count
; i
++)
258 /* check for ctrl-c to abort... */
267 #endif /* CONFIG_MX_CYCLIC */
269 static int do_mem_cmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
271 ulong addr1
, addr2
, count
, ngood
, bytes
;
275 const void *buf1
, *buf2
, *base
;
278 return CMD_RET_USAGE
;
280 /* Check for size specification.
282 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
284 type
= size
== 4 ? "word" : size
== 2 ? "halfword" : "byte";
286 addr1
= simple_strtoul(argv
[1], NULL
, 16);
287 addr1
+= base_address
;
289 addr2
= simple_strtoul(argv
[2], NULL
, 16);
290 addr2
+= base_address
;
292 count
= simple_strtoul(argv
[3], NULL
, 16);
294 #ifdef CONFIG_HAS_DATAFLASH
295 if (addr_dataflash(addr1
) | addr_dataflash(addr2
)){
296 puts ("Comparison with DataFlash space not supported.\n\r");
301 #ifdef CONFIG_BLACKFIN
302 if (addr_bfin_on_chip_mem(addr1
) || addr_bfin_on_chip_mem(addr2
)) {
303 puts ("Comparison with L1 instruction memory not supported.\n\r");
308 bytes
= size
* count
;
309 base
= buf1
= map_sysmem(addr1
, bytes
);
310 buf2
= map_sysmem(addr2
, bytes
);
311 for (ngood
= 0; ngood
< count
; ++ngood
) {
314 word1
= *(ulong
*)buf1
;
315 word2
= *(ulong
*)buf2
;
316 } else if (size
== 2) {
317 word1
= *(ushort
*)buf1
;
318 word2
= *(ushort
*)buf2
;
320 word1
= *(u_char
*)buf1
;
321 word2
= *(u_char
*)buf2
;
323 if (word1
!= word2
) {
324 ulong offset
= buf1
- base
;
326 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
327 type
, (ulong
)(addr1
+ offset
), size
, word1
,
328 type
, (ulong
)(addr2
+ offset
), size
, word2
);
336 /* reset watchdog from time to time */
337 if ((ngood
% (64 << 10)) == 0)
343 printf("Total of %ld %s(s) were the same\n", ngood
, type
);
347 static int do_mem_cp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
349 ulong addr
, dest
, count
, bytes
;
355 return CMD_RET_USAGE
;
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 bytes
= size
* count
;
443 buf
= map_sysmem(addr
, bytes
);
444 src
= map_sysmem(addr
, bytes
);
445 while (count
-- > 0) {
447 *((ulong
*)buf
) = *((ulong
*)src
);
449 *((ushort
*)buf
) = *((ushort
*)src
);
451 *((u_char
*)buf
) = *((u_char
*)src
);
455 /* reset watchdog from time to time */
456 if ((count
% (64 << 10)) == 0)
462 static int do_mem_base(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
466 /* Set new base address.
468 base_address
= simple_strtoul(argv
[1], NULL
, 16);
470 /* Print the current base address.
472 printf("Base Address: 0x%08lx\n", base_address
);
476 static int do_mem_loop(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
479 ulong addr
, length
, i
, bytes
;
481 volatile uint
*longp
;
482 volatile ushort
*shortp
;
487 return CMD_RET_USAGE
;
490 * Check for a size specification.
491 * Defaults to long if no or incorrect specification.
493 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
496 /* Address is always specified.
498 addr
= simple_strtoul(argv
[1], NULL
, 16);
500 /* Length is the number of objects, not number of bytes.
502 length
= simple_strtoul(argv
[2], NULL
, 16);
504 bytes
= size
* length
;
505 buf
= map_sysmem(addr
, bytes
);
507 /* We want to optimize the loops to run as fast as possible.
508 * If we have only one object, just run infinite loops.
517 shortp
= (ushort
*)buf
;
536 shortp
= (ushort
*)buf
;
552 int do_mem_loopw (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
554 ulong addr
, length
, i
, data
, bytes
;
556 volatile uint
*longp
;
557 volatile ushort
*shortp
;
562 return CMD_RET_USAGE
;
565 * Check for a size specification.
566 * Defaults to long if no or incorrect specification.
568 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
571 /* Address is always specified.
573 addr
= simple_strtoul(argv
[1], NULL
, 16);
575 /* Length is the number of objects, not number of bytes.
577 length
= simple_strtoul(argv
[2], NULL
, 16);
580 data
= simple_strtoul(argv
[3], NULL
, 16);
582 bytes
= size
* length
;
583 buf
= map_sysmem(addr
, bytes
);
585 /* We want to optimize the loops to run as fast as possible.
586 * If we have only one object, just run infinite loops.
595 shortp
= (ushort
*)buf
;
614 shortp
= (ushort
*)buf
;
627 #endif /* CONFIG_LOOPW */
629 static ulong
mem_test_alt(ulong start_addr
, ulong end_addr
)
631 vu_long
*start
, *end
;
641 vu_long anti_pattern
;
643 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
644 vu_long
*dummy
= (vu_long
*)CONFIG_SYS_MEMTEST_SCRATCH
;
646 vu_long
*dummy
= NULL
; /* yes, this is address 0x0, not NULL */
648 static const ulong bitpattern
[] = {
649 0x00000001, /* single bit */
650 0x00000003, /* two adjacent bits */
651 0x00000007, /* three adjacent bits */
652 0x0000000F, /* four adjacent bits */
653 0x00000005, /* two non-adjacent bits */
654 0x00000015, /* three non-adjacent bits */
655 0x00000055, /* four non-adjacent bits */
656 0xaaaaaaaa, /* alternating 1/0 */
659 start
= (vu_long
*)start_addr
;
660 end
= (vu_long
*)end_addr
;
663 * Data line test: write a pattern to the first
664 * location, write the 1's complement to a 'parking'
665 * address (changes the state of the data bus so a
666 * floating bus doesn't give a false OK), and then
667 * read the value back. Note that we read it back
668 * into a variable because the next time we read it,
669 * it might be right (been there, tough to explain to
670 * the quality guys why it prints a failure when the
671 * "is" and "should be" are obviously the same in the
674 * Rather than exhaustively testing, we test some
675 * patterns by shifting '1' bits through a field of
676 * '0's and '0' bits through a field of '1's (i.e.
677 * pattern and ~pattern).
680 for (j
= 0; j
< sizeof(bitpattern
) / sizeof(bitpattern
[0]); j
++) {
682 for (; val
!= 0; val
<<= 1) {
684 *dummy
= ~val
; /* clear the test data off the bus */
686 if (readback
!= val
) {
687 printf("FAILURE (data line): "
688 "expected %08lx, actual %08lx\n",
697 if (readback
!= ~val
) {
698 printf("FAILURE (data line): "
699 "Is %08lx, should be %08lx\n",
709 * Based on code whose Original Author and Copyright
710 * information follows: Copyright (c) 1998 by Michael
711 * Barr. This software is placed into the public
712 * domain and may be used for any purpose. However,
713 * this notice must not be changed or removed and no
714 * warranty is either expressed or implied by its
715 * publication or distribution.
721 * Description: Test the address bus wiring in a
722 * memory region by performing a walking
723 * 1's test on the relevant bits of the
724 * address and checking for aliasing.
725 * This test will find single-bit
726 * address failures such as stuck-high,
727 * stuck-low, and shorted pins. The base
728 * address and size of the region are
729 * selected by the caller.
731 * Notes: For best results, the selected base
732 * address should have enough LSB 0's to
733 * guarantee single address bit changes.
734 * For example, to test a 64-Kbyte
735 * region, select a base address on a
736 * 64-Kbyte boundary. Also, select the
737 * region size as a power-of-two if at
740 * Returns: 0 if the test succeeds, 1 if the test fails.
742 len
= (end_addr
- start_addr
) / sizeof(vu_long
);
743 pattern
= (vu_long
) 0xaaaaaaaa;
744 anti_pattern
= (vu_long
) 0x55555555;
746 debug("%s:%d: length = 0x%.8lx\n",
747 __func__
, __LINE__
, len
);
749 * Write the default pattern at each of the
750 * power-of-two offsets.
752 for (offset
= 1; offset
< len
; offset
<<= 1)
753 start
[offset
] = pattern
;
756 * Check for address bits stuck high.
759 start
[test_offset
] = anti_pattern
;
761 for (offset
= 1; offset
< len
; offset
<<= 1) {
762 temp
= start
[offset
];
763 if (temp
!= pattern
) {
764 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
765 " expected 0x%.8lx, actual 0x%.8lx\n",
766 (ulong
)&start
[offset
], pattern
, temp
);
772 start
[test_offset
] = pattern
;
776 * Check for addr bits stuck low or shorted.
778 for (test_offset
= 1; test_offset
< len
; test_offset
<<= 1) {
779 start
[test_offset
] = anti_pattern
;
781 for (offset
= 1; offset
< len
; offset
<<= 1) {
782 temp
= start
[offset
];
783 if ((temp
!= pattern
) && (offset
!= test_offset
)) {
784 printf("\nFAILURE: Address bit stuck low or"
785 " shorted @ 0x%.8lx: expected 0x%.8lx,"
787 (ulong
)&start
[offset
], pattern
, temp
);
793 start
[test_offset
] = pattern
;
797 * Description: Test the integrity of a physical
798 * memory device by performing an
799 * increment/decrement test over the
800 * entire region. In the process every
801 * storage bit in the device is tested
802 * as a zero and a one. The base address
803 * and the size of the region are
804 * selected by the caller.
806 * Returns: 0 if the test succeeds, 1 if the test fails.
808 num_words
= ((ulong
)end
- (ulong
)start
)/sizeof(vu_long
) + 1;
811 * Fill memory with a known pattern.
813 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
815 start
[offset
] = pattern
;
819 * Check each location and invert it for the second pass.
821 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
823 temp
= start
[offset
];
824 if (temp
!= pattern
) {
825 printf("\nFAILURE (read/write) @ 0x%.8lx:"
826 " expected 0x%.8lx, actual 0x%.8lx)\n",
827 (ulong
)&start
[offset
], pattern
, temp
);
833 anti_pattern
= ~pattern
;
834 start
[offset
] = anti_pattern
;
838 * Check each location for the inverted pattern and zero it.
840 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
842 anti_pattern
= ~pattern
;
843 temp
= start
[offset
];
844 if (temp
!= anti_pattern
) {
845 printf("\nFAILURE (read/write): @ 0x%.8lx:"
846 " expected 0x%.8lx, actual 0x%.8lx)\n",
847 (ulong
)&start
[offset
], anti_pattern
, temp
);
858 static ulong
mem_test_quick(ulong start_addr
, ulong end_addr
, vu_long pattern
,
861 vu_long
*start
, *end
;
867 /* Alternate the pattern */
872 * Flip the pattern each time to make lots of zeros and
873 * then, the next time, lots of ones. We decrement
874 * the "negative" patterns and increment the "positive"
875 * patterns to preserve this feature.
877 if (pattern
& 0x80000000)
878 pattern
= -pattern
; /* complement & increment */
882 start
= (vu_long
*)start_addr
;
883 end
= (vu_long
*)end_addr
;
884 printf("\rPattern %08lX Writing..."
886 "\b\b\b\b\b\b\b\b\b\b",
889 for (addr
= start
, val
= pattern
; addr
< end
; addr
++) {
897 for (addr
= start
, val
= pattern
; addr
< end
; addr
++) {
900 if (readback
!= val
) {
901 printf("\nMem error @ 0x%08X: "
902 "found %08lX, expected %08lX\n",
903 (uint
)(uintptr_t)addr
, readback
, val
);
915 * Perform a memory test. A more complete alternative test can be
916 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
917 * interrupted by ctrl-c or by a failure of one of the sub-tests.
919 static int do_mem_mtest(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
925 ulong errs
= 0; /* number of errors, or -1 if interrupted */
928 #if defined(CONFIG_SYS_ALT_MEMTEST)
929 const int alt_test
= 1;
931 const int alt_test
= 0;
935 start
= simple_strtoul(argv
[1], NULL
, 16);
937 start
= CONFIG_SYS_MEMTEST_START
;
940 end
= simple_strtoul(argv
[2], NULL
, 16);
942 end
= CONFIG_SYS_MEMTEST_END
;
945 pattern
= (ulong
)simple_strtoul(argv
[3], NULL
, 16);
950 iteration_limit
= (ulong
)simple_strtoul(argv
[4], NULL
, 16);
954 printf("Testing %08x ... %08x:\n", (uint
)start
, (uint
)end
);
955 debug("%s:%d: start %#08lx end %#08lx\n", __func__
, __LINE__
,
959 !iteration_limit
|| iteration
< iteration_limit
;
966 printf("Iteration: %6d\r", iteration
+ 1);
969 errs
= mem_test_alt(start
, end
);
971 errs
= mem_test_quick(start
, end
, pattern
, iteration
);
975 /* Memory test was aborted - write a newline to finish off */
979 printf("Tested %d iteration(s) with %lu errors.\n",
984 return ret
; /* not reached */
991 * mm{.b, .w, .l} {addr}
992 * nm{.b, .w, .l} {addr}
995 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char * const argv
[])
1002 return CMD_RET_USAGE
;
1004 #ifdef CONFIG_BOOT_RETRY_TIME
1005 reset_cmd_timeout(); /* got a good command to get here */
1007 /* We use the last specified parameters, unless new ones are
1010 addr
= mm_last_addr
;
1011 size
= mm_last_size
;
1013 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
1014 /* New command specified. Check for a size specification.
1015 * Defaults to long if no or incorrect specification.
1017 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
1020 /* Address is specified since argc > 1
1022 addr
= simple_strtoul(argv
[1], NULL
, 16);
1023 addr
+= base_address
;
1026 #ifdef CONFIG_HAS_DATAFLASH
1027 if (addr_dataflash(addr
)){
1028 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1033 #ifdef CONFIG_BLACKFIN
1034 if (addr_bfin_on_chip_mem(addr
)) {
1035 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1040 /* Print the address, followed by value. Then accept input for
1041 * the next value. A non-converted value exits.
1044 ptr
= map_sysmem(addr
, size
);
1045 printf("%08lx:", addr
);
1047 printf(" %08x", *((uint
*)ptr
));
1049 printf(" %04x", *((ushort
*)ptr
));
1051 printf(" %02x", *((u_char
*)ptr
));
1053 nbytes
= readline (" ? ");
1054 if (nbytes
== 0 || (nbytes
== 1 && console_buffer
[0] == '-')) {
1055 /* <CR> pressed as only input, don't modify current
1056 * location and move to next. "-" pressed will go back.
1059 addr
+= nbytes
? -size
: size
;
1061 #ifdef CONFIG_BOOT_RETRY_TIME
1062 reset_cmd_timeout(); /* good enough to not time out */
1065 #ifdef CONFIG_BOOT_RETRY_TIME
1066 else if (nbytes
== -2) {
1067 break; /* timed out, exit the command */
1072 i
= simple_strtoul(console_buffer
, &endp
, 16);
1073 nbytes
= endp
- console_buffer
;
1075 #ifdef CONFIG_BOOT_RETRY_TIME
1076 /* good enough to not time out
1078 reset_cmd_timeout();
1083 *((ushort
*)ptr
) = i
;
1085 *((u_char
*)ptr
) = i
;
1094 mm_last_addr
= addr
;
1095 mm_last_size
= size
;
1099 #ifdef CONFIG_CMD_CRC32
1101 #ifndef CONFIG_CRC32_VERIFY
1103 static int do_mem_crc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1110 return CMD_RET_USAGE
;
1112 addr
= simple_strtoul (argv
[1], NULL
, 16);
1113 addr
+= base_address
;
1115 length
= simple_strtoul (argv
[2], NULL
, 16);
1117 crc
= crc32_wd (0, (const uchar
*) addr
, length
, CHUNKSZ_CRC32
);
1119 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1120 addr
, addr
+ length
- 1, crc
);
1123 ptr
= (ulong
*) simple_strtoul (argv
[3], NULL
, 16);
1130 #else /* CONFIG_CRC32_VERIFY */
1132 int do_mem_crc (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1144 return CMD_RET_USAGE
;
1149 if (strcmp(*av
, "-v") == 0) {
1158 addr
= simple_strtoul(*av
++, NULL
, 16);
1159 addr
+= base_address
;
1160 length
= simple_strtoul(*av
++, NULL
, 16);
1162 crc
= crc32_wd (0, (const uchar
*) addr
, length
, CHUNKSZ_CRC32
);
1165 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1166 addr
, addr
+ length
- 1, crc
);
1168 ptr
= (ulong
*) simple_strtoul (*av
++, NULL
, 16);
1172 vcrc
= simple_strtoul(*av
++, NULL
, 16);
1174 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1175 addr
, addr
+ length
- 1, crc
, vcrc
);
1183 #endif /* CONFIG_CRC32_VERIFY */
1187 /**************************************************/
1189 md
, 3, 1, do_mem_md
,
1191 "[.b, .w, .l] address [# of objects]"
1196 mm
, 2, 1, do_mem_mm
,
1197 "memory modify (auto-incrementing address)",
1198 "[.b, .w, .l] address"
1203 nm
, 2, 1, do_mem_nm
,
1204 "memory modify (constant address)",
1205 "[.b, .w, .l] address"
1209 mw
, 4, 1, do_mem_mw
,
1210 "memory write (fill)",
1211 "[.b, .w, .l] address value [count]"
1215 cp
, 4, 1, do_mem_cp
,
1217 "[.b, .w, .l] source target count"
1221 cmp
, 4, 1, do_mem_cmp
,
1223 "[.b, .w, .l] addr1 addr2 count"
1226 #ifdef CONFIG_CMD_CRC32
1228 #ifndef CONFIG_CRC32_VERIFY
1231 crc32
, 4, 1, do_mem_crc
,
1232 "checksum calculation",
1233 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1236 #else /* CONFIG_CRC32_VERIFY */
1239 crc32
, 5, 1, do_mem_crc
,
1240 "checksum calculation",
1241 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1242 "-v address count crc\n - verify crc of memory area"
1245 #endif /* CONFIG_CRC32_VERIFY */
1249 #ifdef CONFIG_CMD_MEMINFO
1250 __weak
void board_show_dram(ulong size
)
1253 print_size(size
, "\n");
1256 static int do_mem_info(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
1257 char * const argv
[])
1259 board_show_dram(gd
->ram_size
);
1266 base
, 2, 1, do_mem_base
,
1267 "print or set address offset",
1268 "\n - print address offset for memory commands\n"
1269 "base off\n - set address offset for memory commands to 'off'"
1273 loop
, 3, 1, do_mem_loop
,
1274 "infinite loop on address range",
1275 "[.b, .w, .l] address number_of_objects"
1280 loopw
, 4, 1, do_mem_loopw
,
1281 "infinite write loop on address range",
1282 "[.b, .w, .l] address number_of_objects data_to_write"
1284 #endif /* CONFIG_LOOPW */
1287 mtest
, 5, 1, do_mem_mtest
,
1288 "simple RAM read/write test",
1289 "[start [end [pattern [iterations]]]]"
1292 #ifdef CONFIG_MX_CYCLIC
1294 mdc
, 4, 1, do_mem_mdc
,
1295 "memory display cyclic",
1296 "[.b, .w, .l] address count delay(ms)"
1300 mwc
, 4, 1, do_mem_mwc
,
1301 "memory write cyclic",
1302 "[.b, .w, .l] address value delay(ms)"
1304 #endif /* CONFIG_MX_CYCLIC */
1306 #ifdef CONFIG_CMD_MEMINFO
1308 meminfo
, 3, 1, do_mem_info
,
1309 "display memory information",