1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
15 #include <bootretry.h>
26 #include <linux/bitops.h>
27 #include <linux/compiler.h>
28 #include <linux/delay.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
33 #define CONFIG_SYS_MEMTEST_SCRATCH 0
36 static int mod_mem(struct cmd_tbl *, 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(struct cmd_tbl *cmdtp, int flag, int argc,
56 ulong addr, length, bytes;
61 /* We use the last specified parameters, unless new ones are
66 length = dp_last_length;
71 if ((flag & CMD_FLAG_REPEAT) == 0) {
72 /* New command specified. Check for a size specification.
73 * Defaults to long if no or incorrect specification.
75 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
78 /* Address is specified since argc > 1
80 addr = simple_strtoul(argv[1], NULL, 16);
83 /* If another parameter, it is the length to display.
84 * Length is the number of objects, not number of bytes.
87 length = simple_strtoul(argv[2], NULL, 16);
90 bytes = size * length;
91 buf = map_sysmem(addr, bytes);
93 /* Print the lines. */
94 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
99 dp_last_length = length;
104 static int do_mem_mm(struct cmd_tbl *cmdtp, int flag, int argc,
107 return mod_mem (cmdtp, 1, flag, argc, argv);
110 static int do_mem_nm(struct cmd_tbl *cmdtp, int flag, int argc,
113 return mod_mem (cmdtp, 0, flag, argc, argv);
116 static int do_mem_mw(struct cmd_tbl *cmdtp, int flag, int argc,
119 #ifdef MEM_SUPPORT_64BIT_DATA
129 if ((argc < 3) || (argc > 4))
130 return CMD_RET_USAGE;
132 /* Check for size specification.
134 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
137 /* Address is specified since argc > 1
139 addr = simple_strtoul(argv[1], NULL, 16);
140 addr += base_address;
142 /* Get the value to write.
144 #ifdef MEM_SUPPORT_64BIT_DATA
145 writeval = simple_strtoull(argv[2], NULL, 16);
147 writeval = simple_strtoul(argv[2], NULL, 16);
152 count = simple_strtoul(argv[3], NULL, 16);
157 bytes = size * count;
158 start = map_sysmem(addr, bytes);
160 while (count-- > 0) {
162 *((u32 *)buf) = (u32)writeval;
163 #ifdef MEM_SUPPORT_64BIT_DATA
165 *((u64 *)buf) = (u64)writeval;
168 *((u16 *)buf) = (u16)writeval;
170 *((u8 *)buf) = (u8)writeval;
177 #ifdef CONFIG_CMD_MX_CYCLIC
178 static int do_mem_mdc(struct cmd_tbl *cmdtp, int flag, int argc,
185 return CMD_RET_USAGE;
187 count = simple_strtoul(argv[3], NULL, 10);
190 do_mem_md (NULL, 0, 3, argv);
192 /* delay for <count> ms... */
193 for (i=0; i<count; i++)
196 /* check for ctrl-c to abort... */
206 static int do_mem_mwc(struct cmd_tbl *cmdtp, int flag, int argc,
213 return CMD_RET_USAGE;
215 count = simple_strtoul(argv[3], NULL, 10);
218 do_mem_mw (NULL, 0, 3, argv);
220 /* delay for <count> ms... */
221 for (i=0; i<count; i++)
224 /* check for ctrl-c to abort... */
233 #endif /* CONFIG_CMD_MX_CYCLIC */
235 static int do_mem_cmp(struct cmd_tbl *cmdtp, int flag, int argc,
238 ulong addr1, addr2, count, ngood, bytes;
242 const void *buf1, *buf2, *base;
243 #ifdef MEM_SUPPORT_64BIT_DATA
250 return CMD_RET_USAGE;
252 /* Check for size specification.
254 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
256 type = size == 8 ? "double word" :
258 size == 2 ? "halfword" : "byte";
260 addr1 = simple_strtoul(argv[1], NULL, 16);
261 addr1 += base_address;
263 addr2 = simple_strtoul(argv[2], NULL, 16);
264 addr2 += base_address;
266 count = simple_strtoul(argv[3], NULL, 16);
268 bytes = size * count;
269 base = buf1 = map_sysmem(addr1, bytes);
270 buf2 = map_sysmem(addr2, bytes);
271 for (ngood = 0; ngood < count; ++ngood) {
273 word1 = *(u32 *)buf1;
274 word2 = *(u32 *)buf2;
275 #ifdef MEM_SUPPORT_64BIT_DATA
276 } else if (size == 8) {
277 word1 = *(u64 *)buf1;
278 word2 = *(u64 *)buf2;
280 } else if (size == 2) {
281 word1 = *(u16 *)buf1;
282 word2 = *(u16 *)buf2;
287 if (word1 != word2) {
288 ulong offset = buf1 - base;
289 #ifdef MEM_SUPPORT_64BIT_DATA
290 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
291 type, (void *)(addr1 + offset), size, word1,
292 type, (void *)(addr2 + offset), size, word2);
294 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
295 type, (ulong)(addr1 + offset), size, word1,
296 type, (ulong)(addr2 + offset), size, word2);
305 /* reset watchdog from time to time */
306 if ((ngood % (64 << 10)) == 0)
312 printf("Total of %ld %s(s) were the same\n", ngood, type);
316 static int do_mem_cp(struct cmd_tbl *cmdtp, int flag, int argc,
319 ulong addr, dest, count;
324 return CMD_RET_USAGE;
326 /* Check for size specification.
328 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
331 addr = simple_strtoul(argv[1], NULL, 16);
332 addr += base_address;
334 dest = simple_strtoul(argv[2], NULL, 16);
335 dest += base_address;
337 count = simple_strtoul(argv[3], NULL, 16);
340 puts ("Zero length ???\n");
344 src = map_sysmem(addr, count * size);
345 dst = map_sysmem(dest, count * size);
347 #ifdef CONFIG_MTD_NOR_FLASH
348 /* check if we are copying to Flash */
349 if (addr2info((ulong)dst)) {
352 puts ("Copy to Flash... ");
354 rc = flash_write((char *)src, (ulong)dst, count * size);
368 memcpy(dst, src, count * size);
375 static int do_mem_base(struct cmd_tbl *cmdtp, int flag, int argc,
379 /* Set new base address.
381 base_address = simple_strtoul(argv[1], NULL, 16);
383 /* Print the current base address.
385 printf("Base Address: 0x%08lx\n", base_address);
389 static int do_mem_loop(struct cmd_tbl *cmdtp, int flag, int argc,
392 ulong addr, length, i, bytes;
394 #ifdef MEM_SUPPORT_64BIT_DATA
398 volatile u16 *shortp;
403 return CMD_RET_USAGE;
406 * Check for a size specification.
407 * Defaults to long if no or incorrect specification.
409 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
412 /* Address is always specified.
414 addr = simple_strtoul(argv[1], NULL, 16);
416 /* Length is the number of objects, not number of bytes.
418 length = simple_strtoul(argv[2], NULL, 16);
420 bytes = size * length;
421 buf = map_sysmem(addr, bytes);
423 /* We want to optimize the loops to run as fast as possible.
424 * If we have only one object, just run infinite loops.
427 #ifdef MEM_SUPPORT_64BIT_DATA
449 #ifdef MEM_SUPPORT_64BIT_DATA
487 static int do_mem_loopw(struct cmd_tbl *cmdtp, int flag, int argc,
490 ulong addr, length, i, bytes;
492 #ifdef MEM_SUPPORT_64BIT_DATA
499 volatile u16 *shortp;
504 return CMD_RET_USAGE;
507 * Check for a size specification.
508 * Defaults to long if no or incorrect specification.
510 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
513 /* Address is always specified.
515 addr = simple_strtoul(argv[1], NULL, 16);
517 /* Length is the number of objects, not number of bytes.
519 length = simple_strtoul(argv[2], NULL, 16);
522 #ifdef MEM_SUPPORT_64BIT_DATA
523 data = simple_strtoull(argv[3], NULL, 16);
525 data = simple_strtoul(argv[3], NULL, 16);
528 bytes = size * length;
529 buf = map_sysmem(addr, bytes);
531 /* We want to optimize the loops to run as fast as possible.
532 * If we have only one object, just run infinite loops.
535 #ifdef MEM_SUPPORT_64BIT_DATA
557 #ifdef MEM_SUPPORT_64BIT_DATA
590 #endif /* CONFIG_LOOPW */
592 #ifdef CONFIG_CMD_MEMTEST
593 static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
604 vu_long anti_pattern;
606 static const ulong bitpattern[] = {
607 0x00000001, /* single bit */
608 0x00000003, /* two adjacent bits */
609 0x00000007, /* three adjacent bits */
610 0x0000000F, /* four adjacent bits */
611 0x00000005, /* two non-adjacent bits */
612 0x00000015, /* three non-adjacent bits */
613 0x00000055, /* four non-adjacent bits */
614 0xaaaaaaaa, /* alternating 1/0 */
617 num_words = (end_addr - start_addr) / sizeof(vu_long);
620 * Data line test: write a pattern to the first
621 * location, write the 1's complement to a 'parking'
622 * address (changes the state of the data bus so a
623 * floating bus doesn't give a false OK), and then
624 * read the value back. Note that we read it back
625 * into a variable because the next time we read it,
626 * it might be right (been there, tough to explain to
627 * the quality guys why it prints a failure when the
628 * "is" and "should be" are obviously the same in the
631 * Rather than exhaustively testing, we test some
632 * patterns by shifting '1' bits through a field of
633 * '0's and '0' bits through a field of '1's (i.e.
634 * pattern and ~pattern).
637 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
639 for (; val != 0; val <<= 1) {
641 *dummy = ~val; /* clear the test data off the bus */
643 if (readback != val) {
644 printf("FAILURE (data line): "
645 "expected %08lx, actual %08lx\n",
654 if (readback != ~val) {
655 printf("FAILURE (data line): "
656 "Is %08lx, should be %08lx\n",
666 * Based on code whose Original Author and Copyright
667 * information follows: Copyright (c) 1998 by Michael
668 * Barr. This software is placed into the public
669 * domain and may be used for any purpose. However,
670 * this notice must not be changed or removed and no
671 * warranty is either expressed or implied by its
672 * publication or distribution.
678 * Description: Test the address bus wiring in a
679 * memory region by performing a walking
680 * 1's test on the relevant bits of the
681 * address and checking for aliasing.
682 * This test will find single-bit
683 * address failures such as stuck-high,
684 * stuck-low, and shorted pins. The base
685 * address and size of the region are
686 * selected by the caller.
688 * Notes: For best results, the selected base
689 * address should have enough LSB 0's to
690 * guarantee single address bit changes.
691 * For example, to test a 64-Kbyte
692 * region, select a base address on a
693 * 64-Kbyte boundary. Also, select the
694 * region size as a power-of-two if at
697 * Returns: 0 if the test succeeds, 1 if the test fails.
699 pattern = (vu_long) 0xaaaaaaaa;
700 anti_pattern = (vu_long) 0x55555555;
702 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
704 * Write the default pattern at each of the
705 * power-of-two offsets.
707 for (offset = 1; offset < num_words; offset <<= 1)
708 addr[offset] = pattern;
711 * Check for address bits stuck high.
714 addr[test_offset] = anti_pattern;
716 for (offset = 1; offset < num_words; offset <<= 1) {
718 if (temp != pattern) {
719 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
720 " expected 0x%.8lx, actual 0x%.8lx\n",
721 start_addr + offset*sizeof(vu_long),
728 addr[test_offset] = pattern;
732 * Check for addr bits stuck low or shorted.
734 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
735 addr[test_offset] = anti_pattern;
737 for (offset = 1; offset < num_words; offset <<= 1) {
739 if ((temp != pattern) && (offset != test_offset)) {
740 printf("\nFAILURE: Address bit stuck low or"
741 " shorted @ 0x%.8lx: expected 0x%.8lx,"
743 start_addr + offset*sizeof(vu_long),
750 addr[test_offset] = pattern;
754 * Description: Test the integrity of a physical
755 * memory device by performing an
756 * increment/decrement test over the
757 * entire region. In the process every
758 * storage bit in the device is tested
759 * as a zero and a one. The base address
760 * and the size of the region are
761 * selected by the caller.
763 * Returns: 0 if the test succeeds, 1 if the test fails.
768 * Fill memory with a known pattern.
770 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
772 addr[offset] = pattern;
776 * Check each location and invert it for the second pass.
778 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
781 if (temp != pattern) {
782 printf("\nFAILURE (read/write) @ 0x%.8lx:"
783 " expected 0x%.8lx, actual 0x%.8lx)\n",
784 start_addr + offset*sizeof(vu_long),
791 anti_pattern = ~pattern;
792 addr[offset] = anti_pattern;
796 * Check each location for the inverted pattern and zero it.
798 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
800 anti_pattern = ~pattern;
802 if (temp != anti_pattern) {
803 printf("\nFAILURE (read/write): @ 0x%.8lx:"
804 " expected 0x%.8lx, actual 0x%.8lx)\n",
805 start_addr + offset*sizeof(vu_long),
817 static int compare_regions(volatile unsigned long *bufa,
818 volatile unsigned long *bufb, size_t count)
820 volatile unsigned long *p1 = bufa;
821 volatile unsigned long *p2 = bufb;
825 for (i = 0; i < count; i++, p1++, p2++) {
827 printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
828 (unsigned long)*p1, (unsigned long)*p2,
829 *p1 ^ *p2, __ffs(*p1 ^ *p2),
830 (unsigned long)(i * sizeof(unsigned long)));
838 static ulong test_bitflip_comparison(volatile unsigned long *bufa,
839 volatile unsigned long *bufb, size_t count)
841 volatile unsigned long *p1 = bufa;
842 volatile unsigned long *p2 = bufb;
849 max = sizeof(unsigned long) * 8;
850 for (k = 0; k < max; k++) {
851 q = 0x00000001L << k;
852 for (j = 0; j < 8; j++) {
855 p1 = (volatile unsigned long *)bufa;
856 p2 = (volatile unsigned long *)bufb;
857 for (i = 0; i < count; i++)
858 *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
860 errs += compare_regions(bufa, bufb, count);
870 static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
871 vu_long pattern, int iteration)
879 /* Alternate the pattern */
884 * Flip the pattern each time to make lots of zeros and
885 * then, the next time, lots of ones. We decrement
886 * the "negative" patterns and increment the "positive"
887 * patterns to preserve this feature.
889 if (pattern & 0x80000000)
890 pattern = -pattern; /* complement & increment */
894 length = (end_addr - start_addr) / sizeof(ulong);
896 printf("\rPattern %08lX Writing..."
898 "\b\b\b\b\b\b\b\b\b\b",
901 for (addr = buf, val = pattern; addr < end; addr++) {
909 for (addr = buf, val = pattern; addr < end; addr++) {
912 if (readback != val) {
913 ulong offset = addr - buf;
915 printf("\nMem error @ 0x%08X: "
916 "found %08lX, expected %08lX\n",
917 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
930 * Perform a memory test. A more complete alternative test can be
931 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
932 * interrupted by ctrl-c or by a failure of one of the sub-tests.
934 static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc,
938 vu_long scratch_space;
939 vu_long *buf, *dummy = &scratch_space;
940 ulong iteration_limit = 0;
942 ulong errs = 0; /* number of errors, or -1 if interrupted */
946 start = CONFIG_SYS_MEMTEST_START;
947 end = CONFIG_SYS_MEMTEST_END;
950 if (strict_strtoul(argv[1], 16, &start) < 0)
951 return CMD_RET_USAGE;
954 if (strict_strtoul(argv[2], 16, &end) < 0)
955 return CMD_RET_USAGE;
958 if (strict_strtoul(argv[3], 16, &pattern) < 0)
959 return CMD_RET_USAGE;
962 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
963 return CMD_RET_USAGE;
966 printf("Refusing to do empty test\n");
970 printf("Testing %08lx ... %08lx:\n", start, end);
971 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
974 buf = map_sysmem(start, end - start);
976 !iteration_limit || iteration < iteration_limit;
983 printf("Iteration: %6d\r", iteration + 1);
985 if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
986 errs = mem_test_alt(buf, start, end, dummy);
990 errs = test_bitflip_comparison(buf,
991 buf + (end - start) / 2,
993 sizeof(unsigned long));
995 errs = mem_test_quick(buf, start, end, pattern,
1003 unmap_sysmem((void *)buf);
1006 /* Memory test was aborted - write a newline to finish off */
1009 printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
1013 #endif /* CONFIG_CMD_MEMTEST */
1018 * mm{.b, .w, .l, .q} {addr}
1019 * nm{.b, .w, .l, .q} {addr}
1022 mod_mem(struct cmd_tbl *cmdtp, int incrflag, int flag, int argc,
1026 #ifdef MEM_SUPPORT_64BIT_DATA
1035 return CMD_RET_USAGE;
1037 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1038 /* We use the last specified parameters, unless new ones are
1041 addr = mm_last_addr;
1042 size = mm_last_size;
1044 if ((flag & CMD_FLAG_REPEAT) == 0) {
1045 /* New command specified. Check for a size specification.
1046 * Defaults to long if no or incorrect specification.
1048 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1051 /* Address is specified since argc > 1
1053 addr = simple_strtoul(argv[1], NULL, 16);
1054 addr += base_address;
1057 /* Print the address, followed by value. Then accept input for
1058 * the next value. A non-converted value exits.
1061 ptr = map_sysmem(addr, size);
1062 printf("%08lx:", addr);
1064 printf(" %08x", *((u32 *)ptr));
1065 #ifdef MEM_SUPPORT_64BIT_DATA
1067 printf(" %016llx", *((u64 *)ptr));
1070 printf(" %04x", *((u16 *)ptr));
1072 printf(" %02x", *((u8 *)ptr));
1074 nbytes = cli_readline(" ? ");
1075 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1076 /* <CR> pressed as only input, don't modify current
1077 * location and move to next. "-" pressed will go back.
1080 addr += nbytes ? -size : size;
1082 /* good enough to not time out */
1083 bootretry_reset_cmd_timeout();
1085 #ifdef CONFIG_BOOT_RETRY_TIME
1086 else if (nbytes == -2) {
1087 break; /* timed out, exit the command */
1092 #ifdef MEM_SUPPORT_64BIT_DATA
1093 i = simple_strtoull(console_buffer, &endp, 16);
1095 i = simple_strtoul(console_buffer, &endp, 16);
1097 nbytes = endp - console_buffer;
1099 /* good enough to not time out
1101 bootretry_reset_cmd_timeout();
1104 #ifdef MEM_SUPPORT_64BIT_DATA
1120 mm_last_addr = addr;
1121 mm_last_size = size;
1125 #ifdef CONFIG_CMD_CRC32
1127 static int do_mem_crc(struct cmd_tbl *cmdtp, int flag, int argc,
1135 return CMD_RET_USAGE;
1139 #ifdef CONFIG_CRC32_VERIFY
1140 if (strcmp(*av, "-v") == 0) {
1141 flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
1147 return hash_command("crc32", flags, cmdtp, flag, ac, av);
1152 #ifdef CONFIG_CMD_RANDOM
1153 static int do_random(struct cmd_tbl *cmdtp, int flag, int argc,
1156 unsigned long addr, len;
1157 unsigned long seed; // NOT INITIALIZED ON PURPOSE
1158 unsigned int *buf, *start;
1159 unsigned char *buf8;
1162 if (argc < 3 || argc > 4)
1163 return CMD_RET_USAGE;
1165 len = simple_strtoul(argv[2], NULL, 16);
1166 addr = simple_strtoul(argv[1], NULL, 16);
1169 seed = simple_strtoul(argv[3], NULL, 16);
1171 printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
1175 seed = get_timer(0) ^ rand();
1179 start = map_sysmem(addr, len);
1181 for (i = 0; i < (len / 4); i++)
1184 buf8 = (unsigned char *)buf;
1185 for (i = 0; i < (len % 4); i++)
1186 *buf8++ = rand() & 0xFF;
1188 unmap_sysmem(start);
1189 printf("%lu bytes filled with random data\n", len);
1191 return CMD_RET_SUCCESS;
1195 /**************************************************/
1197 md, 3, 1, do_mem_md,
1199 #ifdef MEM_SUPPORT_64BIT_DATA
1200 "[.b, .w, .l, .q] address [# of objects]"
1202 "[.b, .w, .l] address [# of objects]"
1208 mm, 2, 1, do_mem_mm,
1209 "memory modify (auto-incrementing address)",
1210 #ifdef MEM_SUPPORT_64BIT_DATA
1211 "[.b, .w, .l, .q] address"
1213 "[.b, .w, .l] address"
1219 nm, 2, 1, do_mem_nm,
1220 "memory modify (constant address)",
1221 #ifdef MEM_SUPPORT_64BIT_DATA
1222 "[.b, .w, .l, .q] address"
1224 "[.b, .w, .l] address"
1229 mw, 4, 1, do_mem_mw,
1230 "memory write (fill)",
1231 #ifdef MEM_SUPPORT_64BIT_DATA
1232 "[.b, .w, .l, .q] address value [count]"
1234 "[.b, .w, .l] address value [count]"
1239 cp, 4, 1, do_mem_cp,
1241 #ifdef MEM_SUPPORT_64BIT_DATA
1242 "[.b, .w, .l, .q] source target count"
1244 "[.b, .w, .l] source target count"
1249 cmp, 4, 1, do_mem_cmp,
1251 #ifdef MEM_SUPPORT_64BIT_DATA
1252 "[.b, .w, .l, .q] addr1 addr2 count"
1254 "[.b, .w, .l] addr1 addr2 count"
1258 #ifdef CONFIG_CMD_CRC32
1260 #ifndef CONFIG_CRC32_VERIFY
1263 crc32, 4, 1, do_mem_crc,
1264 "checksum calculation",
1265 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1268 #else /* CONFIG_CRC32_VERIFY */
1271 crc32, 5, 1, do_mem_crc,
1272 "checksum calculation",
1273 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1274 "-v address count crc\n - verify crc of memory area"
1277 #endif /* CONFIG_CRC32_VERIFY */
1281 #ifdef CONFIG_CMD_MEMINFO
1282 static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
1286 print_size(gd->ram_size, "\n");
1293 base, 2, 1, do_mem_base,
1294 "print or set address offset",
1295 "\n - print address offset for memory commands\n"
1296 "base off\n - set address offset for memory commands to 'off'"
1300 loop, 3, 1, do_mem_loop,
1301 "infinite loop on address range",
1302 #ifdef MEM_SUPPORT_64BIT_DATA
1303 "[.b, .w, .l, .q] address number_of_objects"
1305 "[.b, .w, .l] address number_of_objects"
1311 loopw, 4, 1, do_mem_loopw,
1312 "infinite write loop on address range",
1313 #ifdef MEM_SUPPORT_64BIT_DATA
1314 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1316 "[.b, .w, .l] address number_of_objects data_to_write"
1319 #endif /* CONFIG_LOOPW */
1321 #ifdef CONFIG_CMD_MEMTEST
1323 mtest, 5, 1, do_mem_mtest,
1324 "simple RAM read/write test",
1325 "[start [end [pattern [iterations]]]]"
1327 #endif /* CONFIG_CMD_MEMTEST */
1329 #ifdef CONFIG_CMD_MX_CYCLIC
1331 mdc, 4, 1, do_mem_mdc,
1332 "memory display cyclic",
1333 #ifdef MEM_SUPPORT_64BIT_DATA
1334 "[.b, .w, .l, .q] address count delay(ms)"
1336 "[.b, .w, .l] address count delay(ms)"
1341 mwc, 4, 1, do_mem_mwc,
1342 "memory write cyclic",
1343 #ifdef MEM_SUPPORT_64BIT_DATA
1344 "[.b, .w, .l, .q] address value delay(ms)"
1346 "[.b, .w, .l] address value delay(ms)"
1349 #endif /* CONFIG_CMD_MX_CYCLIC */
1351 #ifdef CONFIG_CMD_MEMINFO
1353 meminfo, 3, 1, do_mem_info,
1354 "display memory information",
1359 #ifdef CONFIG_CMD_RANDOM
1361 random, 4, 0, do_random,
1362 "fill memory with random pattern",
1363 "<addr> <len> [<seed>]\n"
1364 " - Fill 'len' bytes of memory starting at 'addr' with random data\n"