3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
16 #include <bootretry.h>
20 #ifdef CONFIG_HAS_DATAFLASH
21 #include <dataflash.h>
28 #include <linux/compiler.h>
30 DECLARE_GLOBAL_DATA_PTR
;
32 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
33 #define CONFIG_SYS_MEMTEST_SCRATCH 0
36 static int mod_mem(cmd_tbl_t
*, int, int, int, char * const []);
38 /* Display values from last command.
39 * Memory modify remembered values are different from display memory.
41 static ulong dp_last_addr
, dp_last_size
;
42 static ulong dp_last_length
= 0x40;
43 static ulong mm_last_addr
, mm_last_size
;
45 static ulong base_address
= 0;
50 * md{.b, .w, .l, .q} {addr} {len}
52 #define DISP_LINE_LEN 16
53 static int do_mem_md(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
56 #if defined(CONFIG_HAS_DATAFLASH)
57 ulong nbytes
, linebytes
;
62 /* We use the last specified parameters, unless new ones are
67 length
= dp_last_length
;
72 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
73 /* New command specified. Check for a size specification.
74 * Defaults to long if no or incorrect specification.
76 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
79 /* Address is specified since argc > 1
81 addr
= simple_strtoul(argv
[1], NULL
, 16);
84 /* If another parameter, it is the length to display.
85 * Length is the number of objects, not number of bytes.
88 length
= simple_strtoul(argv
[2], NULL
, 16);
91 #if defined(CONFIG_HAS_DATAFLASH)
94 * We buffer all read data, so we can make sure data is read only
95 * once, and all accesses are with the specified bus width.
97 nbytes
= length
* size
;
99 char linebuf
[DISP_LINE_LEN
];
101 linebytes
= (nbytes
>DISP_LINE_LEN
)?DISP_LINE_LEN
:nbytes
;
103 rc
= read_dataflash(addr
, (linebytes
/size
)*size
, linebuf
);
104 p
= (rc
== DATAFLASH_OK
) ? linebuf
: (void*)addr
;
105 print_buffer(addr
, p
, size
, linebytes
/size
, DISP_LINE_LEN
/size
);
113 } while (nbytes
> 0);
116 ulong bytes
= size
* length
;
117 const void *buf
= map_sysmem(addr
, bytes
);
119 /* Print the lines. */
120 print_buffer(addr
, buf
, size
, length
, DISP_LINE_LEN
/ size
);
127 dp_last_length
= length
;
132 static int do_mem_mm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
134 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
136 static int do_mem_nm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
138 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
141 static int do_mem_mw(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
143 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
153 if ((argc
< 3) || (argc
> 4))
154 return CMD_RET_USAGE
;
156 /* Check for size specification.
158 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
161 /* Address is specified since argc > 1
163 addr
= simple_strtoul(argv
[1], NULL
, 16);
164 addr
+= base_address
;
166 /* Get the value to write.
168 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
169 writeval
= simple_strtoull(argv
[2], NULL
, 16);
171 writeval
= simple_strtoul(argv
[2], NULL
, 16);
176 count
= simple_strtoul(argv
[3], NULL
, 16);
181 bytes
= size
* count
;
182 start
= map_sysmem(addr
, bytes
);
184 while (count
-- > 0) {
186 *((u32
*)buf
) = (u32
)writeval
;
187 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
189 *((u64
*)buf
) = (u64
)writeval
;
192 *((u16
*)buf
) = (u16
)writeval
;
194 *((u8
*)buf
) = (u8
)writeval
;
201 #ifdef CONFIG_MX_CYCLIC
202 static int do_mem_mdc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
208 return CMD_RET_USAGE
;
210 count
= simple_strtoul(argv
[3], NULL
, 10);
213 do_mem_md (NULL
, 0, 3, argv
);
215 /* delay for <count> ms... */
216 for (i
=0; i
<count
; i
++)
219 /* check for ctrl-c to abort... */
229 static int do_mem_mwc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
235 return CMD_RET_USAGE
;
237 count
= simple_strtoul(argv
[3], NULL
, 10);
240 do_mem_mw (NULL
, 0, 3, argv
);
242 /* delay for <count> ms... */
243 for (i
=0; i
<count
; i
++)
246 /* check for ctrl-c to abort... */
255 #endif /* CONFIG_MX_CYCLIC */
257 static int do_mem_cmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
259 ulong addr1
, addr2
, count
, ngood
, bytes
;
263 const void *buf1
, *buf2
, *base
;
264 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
271 return CMD_RET_USAGE
;
273 /* Check for size specification.
275 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
277 type
= size
== 8 ? "double word" :
279 size
== 2 ? "halfword" : "byte";
281 addr1
= simple_strtoul(argv
[1], NULL
, 16);
282 addr1
+= base_address
;
284 addr2
= simple_strtoul(argv
[2], NULL
, 16);
285 addr2
+= base_address
;
287 count
= simple_strtoul(argv
[3], NULL
, 16);
289 #ifdef CONFIG_HAS_DATAFLASH
290 if (addr_dataflash(addr1
) | addr_dataflash(addr2
)){
291 puts ("Comparison with DataFlash space not supported.\n\r");
296 bytes
= size
* count
;
297 base
= buf1
= map_sysmem(addr1
, bytes
);
298 buf2
= map_sysmem(addr2
, bytes
);
299 for (ngood
= 0; ngood
< count
; ++ngood
) {
301 word1
= *(u32
*)buf1
;
302 word2
= *(u32
*)buf2
;
303 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
304 } else if (size
== 8) {
305 word1
= *(u64
*)buf1
;
306 word2
= *(u64
*)buf2
;
308 } else if (size
== 2) {
309 word1
= *(u16
*)buf1
;
310 word2
= *(u16
*)buf2
;
315 if (word1
!= word2
) {
316 ulong offset
= buf1
- base
;
317 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
318 printf("%s at 0x%p (%#0*"PRIx64
") != %s at 0x%p (%#0*"
320 type
, (void *)(addr1
+ offset
), size
, word1
,
321 type
, (void *)(addr2
+ offset
), size
, word2
);
323 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
324 type
, (ulong
)(addr1
+ offset
), size
, word1
,
325 type
, (ulong
)(addr2
+ offset
), size
, word2
);
334 /* reset watchdog from time to time */
335 if ((ngood
% (64 << 10)) == 0)
341 printf("Total of %ld %s(s) were the same\n", ngood
, type
);
345 static int do_mem_cp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
347 ulong addr
, dest
, count
;
351 return CMD_RET_USAGE
;
353 /* Check for size specification.
355 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
358 addr
= simple_strtoul(argv
[1], NULL
, 16);
359 addr
+= base_address
;
361 dest
= simple_strtoul(argv
[2], NULL
, 16);
362 dest
+= base_address
;
364 count
= simple_strtoul(argv
[3], NULL
, 16);
367 puts ("Zero length ???\n");
371 #ifdef CONFIG_MTD_NOR_FLASH
372 /* check if we are copying to Flash */
373 if ( (addr2info(dest
) != NULL
)
374 #ifdef CONFIG_HAS_DATAFLASH
375 && (!addr_dataflash(dest
))
380 puts ("Copy to Flash... ");
382 rc
= flash_write ((char *)addr
, dest
, count
*size
);
392 #ifdef CONFIG_HAS_DATAFLASH
393 /* Check if we are copying from RAM or Flash to DataFlash */
394 if (addr_dataflash(dest
) && !addr_dataflash(addr
)){
397 puts ("Copy to DataFlash... ");
399 rc
= write_dataflash (dest
, addr
, count
*size
);
402 dataflash_perror (rc
);
409 /* Check if we are copying from DataFlash to RAM */
410 if (addr_dataflash(addr
) && !addr_dataflash(dest
)
411 #ifdef CONFIG_MTD_NOR_FLASH
412 && (addr2info(dest
) == NULL
)
416 rc
= read_dataflash(addr
, count
* size
, (char *) dest
);
418 dataflash_perror (rc
);
424 if (addr_dataflash(addr
) && addr_dataflash(dest
)){
425 puts ("Unsupported combination of source/destination.\n\r");
430 memcpy((void *)dest
, (void *)addr
, count
* size
);
435 static int do_mem_base(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
439 /* Set new base address.
441 base_address
= simple_strtoul(argv
[1], NULL
, 16);
443 /* Print the current base address.
445 printf("Base Address: 0x%08lx\n", base_address
);
449 static int do_mem_loop(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
452 ulong addr
, length
, i
, bytes
;
454 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
458 volatile u16
*shortp
;
463 return CMD_RET_USAGE
;
466 * Check for a size specification.
467 * Defaults to long if no or incorrect specification.
469 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
472 /* Address is always specified.
474 addr
= simple_strtoul(argv
[1], NULL
, 16);
476 /* Length is the number of objects, not number of bytes.
478 length
= simple_strtoul(argv
[2], NULL
, 16);
480 bytes
= size
* length
;
481 buf
= map_sysmem(addr
, bytes
);
483 /* We want to optimize the loops to run as fast as possible.
484 * If we have only one object, just run infinite loops.
487 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
509 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
547 static int do_mem_loopw(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
550 ulong addr
, length
, i
, bytes
;
552 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
559 volatile u16
*shortp
;
564 return CMD_RET_USAGE
;
567 * Check for a size specification.
568 * Defaults to long if no or incorrect specification.
570 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
573 /* Address is always specified.
575 addr
= simple_strtoul(argv
[1], NULL
, 16);
577 /* Length is the number of objects, not number of bytes.
579 length
= simple_strtoul(argv
[2], NULL
, 16);
582 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
583 data
= simple_strtoull(argv
[3], NULL
, 16);
585 data
= simple_strtoul(argv
[3], NULL
, 16);
588 bytes
= size
* length
;
589 buf
= map_sysmem(addr
, bytes
);
591 /* We want to optimize the loops to run as fast as possible.
592 * If we have only one object, just run infinite loops.
595 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
617 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
650 #endif /* CONFIG_LOOPW */
652 #ifdef CONFIG_CMD_MEMTEST
653 static ulong
mem_test_alt(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
664 vu_long anti_pattern
;
666 static const ulong bitpattern
[] = {
667 0x00000001, /* single bit */
668 0x00000003, /* two adjacent bits */
669 0x00000007, /* three adjacent bits */
670 0x0000000F, /* four adjacent bits */
671 0x00000005, /* two non-adjacent bits */
672 0x00000015, /* three non-adjacent bits */
673 0x00000055, /* four non-adjacent bits */
674 0xaaaaaaaa, /* alternating 1/0 */
677 num_words
= (end_addr
- start_addr
) / sizeof(vu_long
);
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 doesn'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
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).
697 for (j
= 0; j
< sizeof(bitpattern
) / sizeof(bitpattern
[0]); j
++) {
699 for (; val
!= 0; val
<<= 1) {
701 *dummy
= ~val
; /* clear the test data off the bus */
703 if (readback
!= val
) {
704 printf("FAILURE (data line): "
705 "expected %08lx, actual %08lx\n",
714 if (readback
!= ~val
) {
715 printf("FAILURE (data line): "
716 "Is %08lx, should be %08lx\n",
726 * Based on code whose Original Author and Copyright
727 * information follows: Copyright (c) 1998 by Michael
728 * Barr. This software is placed into the public
729 * domain and may be used for any purpose. However,
730 * this notice must not be changed or removed and no
731 * warranty is either expressed or implied by its
732 * publication or distribution.
738 * Description: Test the address bus wiring in a
739 * memory region by performing a walking
740 * 1's test on the relevant bits of the
741 * address and checking for aliasing.
742 * This test will find single-bit
743 * address failures such as stuck-high,
744 * stuck-low, and shorted pins. The base
745 * address and size of the region are
746 * selected by the caller.
748 * Notes: For best results, the selected base
749 * address should have enough LSB 0's to
750 * guarantee single address bit changes.
751 * For example, to test a 64-Kbyte
752 * region, select a base address on a
753 * 64-Kbyte boundary. Also, select the
754 * region size as a power-of-two if at
757 * Returns: 0 if the test succeeds, 1 if the test fails.
759 pattern
= (vu_long
) 0xaaaaaaaa;
760 anti_pattern
= (vu_long
) 0x55555555;
762 debug("%s:%d: length = 0x%.8lx\n", __func__
, __LINE__
, num_words
);
764 * Write the default pattern at each of the
765 * power-of-two offsets.
767 for (offset
= 1; offset
< num_words
; offset
<<= 1)
768 addr
[offset
] = pattern
;
771 * Check for address bits stuck high.
774 addr
[test_offset
] = anti_pattern
;
776 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
778 if (temp
!= pattern
) {
779 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
780 " expected 0x%.8lx, actual 0x%.8lx\n",
781 start_addr
+ offset
*sizeof(vu_long
),
788 addr
[test_offset
] = pattern
;
792 * Check for addr bits stuck low or shorted.
794 for (test_offset
= 1; test_offset
< num_words
; test_offset
<<= 1) {
795 addr
[test_offset
] = anti_pattern
;
797 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
799 if ((temp
!= pattern
) && (offset
!= test_offset
)) {
800 printf("\nFAILURE: Address bit stuck low or"
801 " shorted @ 0x%.8lx: expected 0x%.8lx,"
803 start_addr
+ offset
*sizeof(vu_long
),
810 addr
[test_offset
] = pattern
;
814 * Description: Test the integrity of a physical
815 * memory device by performing an
816 * increment/decrement test over the
817 * entire region. In the process every
818 * storage bit in the device is tested
819 * as a zero and a one. The base address
820 * and the size of the region are
821 * selected by the caller.
823 * Returns: 0 if the test succeeds, 1 if the test fails.
828 * Fill memory with a known pattern.
830 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
832 addr
[offset
] = pattern
;
836 * Check each location and invert it for the second pass.
838 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
841 if (temp
!= pattern
) {
842 printf("\nFAILURE (read/write) @ 0x%.8lx:"
843 " expected 0x%.8lx, actual 0x%.8lx)\n",
844 start_addr
+ offset
*sizeof(vu_long
),
851 anti_pattern
= ~pattern
;
852 addr
[offset
] = anti_pattern
;
856 * Check each location for the inverted pattern and zero it.
858 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
860 anti_pattern
= ~pattern
;
862 if (temp
!= anti_pattern
) {
863 printf("\nFAILURE (read/write): @ 0x%.8lx:"
864 " expected 0x%.8lx, actual 0x%.8lx)\n",
865 start_addr
+ offset
*sizeof(vu_long
),
877 static ulong
mem_test_quick(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
878 vu_long pattern
, int iteration
)
886 /* Alternate the pattern */
891 * Flip the pattern each time to make lots of zeros and
892 * then, the next time, lots of ones. We decrement
893 * the "negative" patterns and increment the "positive"
894 * patterns to preserve this feature.
896 if (pattern
& 0x80000000)
897 pattern
= -pattern
; /* complement & increment */
901 length
= (end_addr
- start_addr
) / sizeof(ulong
);
903 printf("\rPattern %08lX Writing..."
905 "\b\b\b\b\b\b\b\b\b\b",
908 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
916 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
919 if (readback
!= val
) {
920 ulong offset
= addr
- buf
;
922 printf("\nMem error @ 0x%08X: "
923 "found %08lX, expected %08lX\n",
924 (uint
)(uintptr_t)(start_addr
+ offset
*sizeof(vu_long
)),
937 * Perform a memory test. A more complete alternative test can be
938 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
939 * interrupted by ctrl-c or by a failure of one of the sub-tests.
941 static int do_mem_mtest(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
945 vu_long
*buf
, *dummy
;
946 ulong iteration_limit
= 0;
948 ulong errs
= 0; /* number of errors, or -1 if interrupted */
951 #if defined(CONFIG_SYS_ALT_MEMTEST)
952 const int alt_test
= 1;
954 const int alt_test
= 0;
957 start
= CONFIG_SYS_MEMTEST_START
;
958 end
= CONFIG_SYS_MEMTEST_END
;
961 if (strict_strtoul(argv
[1], 16, &start
) < 0)
962 return CMD_RET_USAGE
;
965 if (strict_strtoul(argv
[2], 16, &end
) < 0)
966 return CMD_RET_USAGE
;
969 if (strict_strtoul(argv
[3], 16, &pattern
) < 0)
970 return CMD_RET_USAGE
;
973 if (strict_strtoul(argv
[4], 16, &iteration_limit
) < 0)
974 return CMD_RET_USAGE
;
977 printf("Refusing to do empty test\n");
981 printf("Testing %08lx ... %08lx:\n", start
, end
);
982 debug("%s:%d: start %#08lx end %#08lx\n", __func__
, __LINE__
,
985 buf
= map_sysmem(start
, end
- start
);
986 dummy
= map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH
, sizeof(vu_long
));
988 !iteration_limit
|| iteration
< iteration_limit
;
995 printf("Iteration: %6d\r", iteration
+ 1);
998 errs
= mem_test_alt(buf
, start
, end
, dummy
);
1000 errs
= mem_test_quick(buf
, start
, end
, pattern
,
1008 * Work-around for eldk-4.2 which gives this warning if we try to
1009 * case in the unmap_sysmem() call:
1010 * warning: initialization discards qualifiers from pointer target type
1013 void *vbuf
= (void *)buf
;
1014 void *vdummy
= (void *)dummy
;
1017 unmap_sysmem(vdummy
);
1021 /* Memory test was aborted - write a newline to finish off */
1025 printf("Tested %d iteration(s) with %lu errors.\n",
1032 #endif /* CONFIG_CMD_MEMTEST */
1037 * mm{.b, .w, .l, .q} {addr}
1038 * nm{.b, .w, .l, .q} {addr}
1041 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char * const argv
[])
1044 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1053 return CMD_RET_USAGE
;
1055 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1056 /* We use the last specified parameters, unless new ones are
1059 addr
= mm_last_addr
;
1060 size
= mm_last_size
;
1062 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
1063 /* New command specified. Check for a size specification.
1064 * Defaults to long if no or incorrect specification.
1066 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
1069 /* Address is specified since argc > 1
1071 addr
= simple_strtoul(argv
[1], NULL
, 16);
1072 addr
+= base_address
;
1075 #ifdef CONFIG_HAS_DATAFLASH
1076 if (addr_dataflash(addr
)){
1077 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1082 /* Print the address, followed by value. Then accept input for
1083 * the next value. A non-converted value exits.
1086 ptr
= map_sysmem(addr
, size
);
1087 printf("%08lx:", addr
);
1089 printf(" %08x", *((u32
*)ptr
));
1090 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1092 printf(" %016" PRIx64
, *((u64
*)ptr
));
1095 printf(" %04x", *((u16
*)ptr
));
1097 printf(" %02x", *((u8
*)ptr
));
1099 nbytes
= cli_readline(" ? ");
1100 if (nbytes
== 0 || (nbytes
== 1 && console_buffer
[0] == '-')) {
1101 /* <CR> pressed as only input, don't modify current
1102 * location and move to next. "-" pressed will go back.
1105 addr
+= nbytes
? -size
: size
;
1107 /* good enough to not time out */
1108 bootretry_reset_cmd_timeout();
1110 #ifdef CONFIG_BOOT_RETRY_TIME
1111 else if (nbytes
== -2) {
1112 break; /* timed out, exit the command */
1117 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1118 i
= simple_strtoull(console_buffer
, &endp
, 16);
1120 i
= simple_strtoul(console_buffer
, &endp
, 16);
1122 nbytes
= endp
- console_buffer
;
1124 /* good enough to not time out
1126 bootretry_reset_cmd_timeout();
1129 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1145 mm_last_addr
= addr
;
1146 mm_last_size
= size
;
1150 #ifdef CONFIG_CMD_CRC32
1152 static int do_mem_crc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1159 return CMD_RET_USAGE
;
1163 #ifdef CONFIG_CRC32_VERIFY
1164 if (strcmp(*av
, "-v") == 0) {
1165 flags
|= HASH_FLAG_VERIFY
| HASH_FLAG_ENV
;
1171 return hash_command("crc32", flags
, cmdtp
, flag
, ac
, av
);
1176 /**************************************************/
1178 md
, 3, 1, do_mem_md
,
1180 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1181 "[.b, .w, .l, .q] address [# of objects]"
1183 "[.b, .w, .l] address [# of objects]"
1189 mm
, 2, 1, do_mem_mm
,
1190 "memory modify (auto-incrementing address)",
1191 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1192 "[.b, .w, .l, .q] address"
1194 "[.b, .w, .l] address"
1200 nm
, 2, 1, do_mem_nm
,
1201 "memory modify (constant address)",
1202 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1203 "[.b, .w, .l, .q] address"
1205 "[.b, .w, .l] address"
1210 mw
, 4, 1, do_mem_mw
,
1211 "memory write (fill)",
1212 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1213 "[.b, .w, .l, .q] address value [count]"
1215 "[.b, .w, .l] address value [count]"
1220 cp
, 4, 1, do_mem_cp
,
1222 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1223 "[.b, .w, .l, .q] source target count"
1225 "[.b, .w, .l] source target count"
1230 cmp
, 4, 1, do_mem_cmp
,
1232 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1233 "[.b, .w, .l, .q] addr1 addr2 count"
1235 "[.b, .w, .l] addr1 addr2 count"
1239 #ifdef CONFIG_CMD_CRC32
1241 #ifndef CONFIG_CRC32_VERIFY
1244 crc32
, 4, 1, do_mem_crc
,
1245 "checksum calculation",
1246 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1249 #else /* CONFIG_CRC32_VERIFY */
1252 crc32
, 5, 1, do_mem_crc
,
1253 "checksum calculation",
1254 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1255 "-v address count crc\n - verify crc of memory area"
1258 #endif /* CONFIG_CRC32_VERIFY */
1262 #ifdef CONFIG_CMD_MEMINFO
1263 __weak
void board_show_dram(phys_size_t size
)
1266 print_size(size
, "\n");
1269 static int do_mem_info(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
1270 char * const argv
[])
1272 board_show_dram(gd
->ram_size
);
1279 base
, 2, 1, do_mem_base
,
1280 "print or set address offset",
1281 "\n - print address offset for memory commands\n"
1282 "base off\n - set address offset for memory commands to 'off'"
1286 loop
, 3, 1, do_mem_loop
,
1287 "infinite loop on address range",
1288 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1289 "[.b, .w, .l, .q] address number_of_objects"
1291 "[.b, .w, .l] address number_of_objects"
1297 loopw
, 4, 1, do_mem_loopw
,
1298 "infinite write loop on address range",
1299 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1300 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1302 "[.b, .w, .l] address number_of_objects data_to_write"
1305 #endif /* CONFIG_LOOPW */
1307 #ifdef CONFIG_CMD_MEMTEST
1309 mtest
, 5, 1, do_mem_mtest
,
1310 "simple RAM read/write test",
1311 "[start [end [pattern [iterations]]]]"
1313 #endif /* CONFIG_CMD_MEMTEST */
1315 #ifdef CONFIG_MX_CYCLIC
1317 mdc
, 4, 1, do_mem_mdc
,
1318 "memory display cyclic",
1319 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1320 "[.b, .w, .l, .q] address count delay(ms)"
1322 "[.b, .w, .l] address count delay(ms)"
1327 mwc
, 4, 1, do_mem_mwc
,
1328 "memory write cyclic",
1329 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1330 "[.b, .w, .l, .q] address value delay(ms)"
1332 "[.b, .w, .l] address value delay(ms)"
1335 #endif /* CONFIG_MX_CYCLIC */
1337 #ifdef CONFIG_CMD_MEMINFO
1339 meminfo
, 3, 1, do_mem_info
,
1340 "display memory information",