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/compiler.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
31 #define CONFIG_SYS_MEMTEST_SCRATCH 0
34 static int mod_mem(struct cmd_tbl *, int, int, int, char * const []);
36 /* Display values from last command.
37 * Memory modify remembered values are different from display memory.
39 static ulong dp_last_addr, dp_last_size;
40 static ulong dp_last_length = 0x40;
41 static ulong mm_last_addr, mm_last_size;
43 static ulong base_address = 0;
48 * md{.b, .w, .l, .q} {addr} {len}
50 #define DISP_LINE_LEN 16
51 static int do_mem_md(struct cmd_tbl *cmdtp, int flag, int argc,
54 ulong addr, length, bytes;
59 /* We use the last specified parameters, unless new ones are
64 length = dp_last_length;
69 if ((flag & CMD_FLAG_REPEAT) == 0) {
70 /* New command specified. Check for a size specification.
71 * Defaults to long if no or incorrect specification.
73 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
76 /* Address is specified since argc > 1
78 addr = simple_strtoul(argv[1], NULL, 16);
81 /* If another parameter, it is the length to display.
82 * Length is the number of objects, not number of bytes.
85 length = simple_strtoul(argv[2], NULL, 16);
88 bytes = size * length;
89 buf = map_sysmem(addr, bytes);
91 /* Print the lines. */
92 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
97 dp_last_length = length;
102 static int do_mem_mm(struct cmd_tbl *cmdtp, int flag, int argc,
105 return mod_mem (cmdtp, 1, flag, argc, argv);
108 static int do_mem_nm(struct cmd_tbl *cmdtp, int flag, int argc,
111 return mod_mem (cmdtp, 0, flag, argc, argv);
114 static int do_mem_mw(struct cmd_tbl *cmdtp, int flag, int argc,
117 #ifdef MEM_SUPPORT_64BIT_DATA
127 if ((argc < 3) || (argc > 4))
128 return CMD_RET_USAGE;
130 /* Check for size specification.
132 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
135 /* Address is specified since argc > 1
137 addr = simple_strtoul(argv[1], NULL, 16);
138 addr += base_address;
140 /* Get the value to write.
142 #ifdef MEM_SUPPORT_64BIT_DATA
143 writeval = simple_strtoull(argv[2], NULL, 16);
145 writeval = simple_strtoul(argv[2], NULL, 16);
150 count = simple_strtoul(argv[3], NULL, 16);
155 bytes = size * count;
156 start = map_sysmem(addr, bytes);
158 while (count-- > 0) {
160 *((u32 *)buf) = (u32)writeval;
161 #ifdef MEM_SUPPORT_64BIT_DATA
163 *((u64 *)buf) = (u64)writeval;
166 *((u16 *)buf) = (u16)writeval;
168 *((u8 *)buf) = (u8)writeval;
175 #ifdef CONFIG_CMD_MX_CYCLIC
176 static int do_mem_mdc(struct cmd_tbl *cmdtp, int flag, int argc,
183 return CMD_RET_USAGE;
185 count = simple_strtoul(argv[3], NULL, 10);
188 do_mem_md (NULL, 0, 3, argv);
190 /* delay for <count> ms... */
191 for (i=0; i<count; i++)
194 /* check for ctrl-c to abort... */
204 static int do_mem_mwc(struct cmd_tbl *cmdtp, int flag, int argc,
211 return CMD_RET_USAGE;
213 count = simple_strtoul(argv[3], NULL, 10);
216 do_mem_mw (NULL, 0, 3, argv);
218 /* delay for <count> ms... */
219 for (i=0; i<count; i++)
222 /* check for ctrl-c to abort... */
231 #endif /* CONFIG_CMD_MX_CYCLIC */
233 static int do_mem_cmp(struct cmd_tbl *cmdtp, int flag, int argc,
236 ulong addr1, addr2, count, ngood, bytes;
240 const void *buf1, *buf2, *base;
241 #ifdef MEM_SUPPORT_64BIT_DATA
248 return CMD_RET_USAGE;
250 /* Check for size specification.
252 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
254 type = size == 8 ? "double word" :
256 size == 2 ? "halfword" : "byte";
258 addr1 = simple_strtoul(argv[1], NULL, 16);
259 addr1 += base_address;
261 addr2 = simple_strtoul(argv[2], NULL, 16);
262 addr2 += base_address;
264 count = simple_strtoul(argv[3], NULL, 16);
266 bytes = size * count;
267 base = buf1 = map_sysmem(addr1, bytes);
268 buf2 = map_sysmem(addr2, bytes);
269 for (ngood = 0; ngood < count; ++ngood) {
271 word1 = *(u32 *)buf1;
272 word2 = *(u32 *)buf2;
273 #ifdef MEM_SUPPORT_64BIT_DATA
274 } else if (size == 8) {
275 word1 = *(u64 *)buf1;
276 word2 = *(u64 *)buf2;
278 } else if (size == 2) {
279 word1 = *(u16 *)buf1;
280 word2 = *(u16 *)buf2;
285 if (word1 != word2) {
286 ulong offset = buf1 - base;
287 #ifdef MEM_SUPPORT_64BIT_DATA
288 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
289 type, (void *)(addr1 + offset), size, word1,
290 type, (void *)(addr2 + offset), size, word2);
292 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
293 type, (ulong)(addr1 + offset), size, word1,
294 type, (ulong)(addr2 + offset), size, word2);
303 /* reset watchdog from time to time */
304 if ((ngood % (64 << 10)) == 0)
310 printf("Total of %ld %s(s) were the same\n", ngood, type);
314 static int do_mem_cp(struct cmd_tbl *cmdtp, int flag, int argc,
317 ulong addr, dest, count;
322 return CMD_RET_USAGE;
324 /* Check for size specification.
326 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
329 addr = simple_strtoul(argv[1], NULL, 16);
330 addr += base_address;
332 dest = simple_strtoul(argv[2], NULL, 16);
333 dest += base_address;
335 count = simple_strtoul(argv[3], NULL, 16);
338 puts ("Zero length ???\n");
342 src = map_sysmem(addr, count * size);
343 dst = map_sysmem(dest, count * size);
345 #ifdef CONFIG_MTD_NOR_FLASH
346 /* check if we are copying to Flash */
347 if (addr2info((ulong)dst)) {
350 puts ("Copy to Flash... ");
352 rc = flash_write((char *)src, (ulong)dst, count * size);
366 memcpy(dst, src, count * size);
373 static int do_mem_base(struct cmd_tbl *cmdtp, int flag, int argc,
377 /* Set new base address.
379 base_address = simple_strtoul(argv[1], NULL, 16);
381 /* Print the current base address.
383 printf("Base Address: 0x%08lx\n", base_address);
387 static int do_mem_loop(struct cmd_tbl *cmdtp, int flag, int argc,
390 ulong addr, length, i, bytes;
392 #ifdef MEM_SUPPORT_64BIT_DATA
396 volatile u16 *shortp;
401 return CMD_RET_USAGE;
404 * Check for a size specification.
405 * Defaults to long if no or incorrect specification.
407 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
410 /* Address is always specified.
412 addr = simple_strtoul(argv[1], NULL, 16);
414 /* Length is the number of objects, not number of bytes.
416 length = simple_strtoul(argv[2], NULL, 16);
418 bytes = size * length;
419 buf = map_sysmem(addr, bytes);
421 /* We want to optimize the loops to run as fast as possible.
422 * If we have only one object, just run infinite loops.
425 #ifdef MEM_SUPPORT_64BIT_DATA
447 #ifdef MEM_SUPPORT_64BIT_DATA
485 static int do_mem_loopw(struct cmd_tbl *cmdtp, int flag, int argc,
488 ulong addr, length, i, bytes;
490 #ifdef MEM_SUPPORT_64BIT_DATA
497 volatile u16 *shortp;
502 return CMD_RET_USAGE;
505 * Check for a size specification.
506 * Defaults to long if no or incorrect specification.
508 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
511 /* Address is always specified.
513 addr = simple_strtoul(argv[1], NULL, 16);
515 /* Length is the number of objects, not number of bytes.
517 length = simple_strtoul(argv[2], NULL, 16);
520 #ifdef MEM_SUPPORT_64BIT_DATA
521 data = simple_strtoull(argv[3], NULL, 16);
523 data = simple_strtoul(argv[3], NULL, 16);
526 bytes = size * length;
527 buf = map_sysmem(addr, bytes);
529 /* We want to optimize the loops to run as fast as possible.
530 * If we have only one object, just run infinite loops.
533 #ifdef MEM_SUPPORT_64BIT_DATA
555 #ifdef MEM_SUPPORT_64BIT_DATA
588 #endif /* CONFIG_LOOPW */
590 #ifdef CONFIG_CMD_MEMTEST
591 static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
602 vu_long anti_pattern;
604 static const ulong bitpattern[] = {
605 0x00000001, /* single bit */
606 0x00000003, /* two adjacent bits */
607 0x00000007, /* three adjacent bits */
608 0x0000000F, /* four adjacent bits */
609 0x00000005, /* two non-adjacent bits */
610 0x00000015, /* three non-adjacent bits */
611 0x00000055, /* four non-adjacent bits */
612 0xaaaaaaaa, /* alternating 1/0 */
615 num_words = (end_addr - start_addr) / sizeof(vu_long);
618 * Data line test: write a pattern to the first
619 * location, write the 1's complement to a 'parking'
620 * address (changes the state of the data bus so a
621 * floating bus doesn't give a false OK), and then
622 * read the value back. Note that we read it back
623 * into a variable because the next time we read it,
624 * it might be right (been there, tough to explain to
625 * the quality guys why it prints a failure when the
626 * "is" and "should be" are obviously the same in the
629 * Rather than exhaustively testing, we test some
630 * patterns by shifting '1' bits through a field of
631 * '0's and '0' bits through a field of '1's (i.e.
632 * pattern and ~pattern).
635 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
637 for (; val != 0; val <<= 1) {
639 *dummy = ~val; /* clear the test data off the bus */
641 if (readback != val) {
642 printf("FAILURE (data line): "
643 "expected %08lx, actual %08lx\n",
652 if (readback != ~val) {
653 printf("FAILURE (data line): "
654 "Is %08lx, should be %08lx\n",
664 * Based on code whose Original Author and Copyright
665 * information follows: Copyright (c) 1998 by Michael
666 * Barr. This software is placed into the public
667 * domain and may be used for any purpose. However,
668 * this notice must not be changed or removed and no
669 * warranty is either expressed or implied by its
670 * publication or distribution.
676 * Description: Test the address bus wiring in a
677 * memory region by performing a walking
678 * 1's test on the relevant bits of the
679 * address and checking for aliasing.
680 * This test will find single-bit
681 * address failures such as stuck-high,
682 * stuck-low, and shorted pins. The base
683 * address and size of the region are
684 * selected by the caller.
686 * Notes: For best results, the selected base
687 * address should have enough LSB 0's to
688 * guarantee single address bit changes.
689 * For example, to test a 64-Kbyte
690 * region, select a base address on a
691 * 64-Kbyte boundary. Also, select the
692 * region size as a power-of-two if at
695 * Returns: 0 if the test succeeds, 1 if the test fails.
697 pattern = (vu_long) 0xaaaaaaaa;
698 anti_pattern = (vu_long) 0x55555555;
700 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
702 * Write the default pattern at each of the
703 * power-of-two offsets.
705 for (offset = 1; offset < num_words; offset <<= 1)
706 addr[offset] = pattern;
709 * Check for address bits stuck high.
712 addr[test_offset] = anti_pattern;
714 for (offset = 1; offset < num_words; offset <<= 1) {
716 if (temp != pattern) {
717 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
718 " expected 0x%.8lx, actual 0x%.8lx\n",
719 start_addr + offset*sizeof(vu_long),
726 addr[test_offset] = pattern;
730 * Check for addr bits stuck low or shorted.
732 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
733 addr[test_offset] = anti_pattern;
735 for (offset = 1; offset < num_words; offset <<= 1) {
737 if ((temp != pattern) && (offset != test_offset)) {
738 printf("\nFAILURE: Address bit stuck low or"
739 " shorted @ 0x%.8lx: expected 0x%.8lx,"
741 start_addr + offset*sizeof(vu_long),
748 addr[test_offset] = pattern;
752 * Description: Test the integrity of a physical
753 * memory device by performing an
754 * increment/decrement test over the
755 * entire region. In the process every
756 * storage bit in the device is tested
757 * as a zero and a one. The base address
758 * and the size of the region are
759 * selected by the caller.
761 * Returns: 0 if the test succeeds, 1 if the test fails.
766 * Fill memory with a known pattern.
768 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
770 addr[offset] = pattern;
774 * Check each location and invert it for the second pass.
776 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
779 if (temp != pattern) {
780 printf("\nFAILURE (read/write) @ 0x%.8lx:"
781 " expected 0x%.8lx, actual 0x%.8lx)\n",
782 start_addr + offset*sizeof(vu_long),
789 anti_pattern = ~pattern;
790 addr[offset] = anti_pattern;
794 * Check each location for the inverted pattern and zero it.
796 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
798 anti_pattern = ~pattern;
800 if (temp != anti_pattern) {
801 printf("\nFAILURE (read/write): @ 0x%.8lx:"
802 " expected 0x%.8lx, actual 0x%.8lx)\n",
803 start_addr + offset*sizeof(vu_long),
815 static int compare_regions(volatile unsigned long *bufa,
816 volatile unsigned long *bufb, size_t count)
818 volatile unsigned long *p1 = bufa;
819 volatile unsigned long *p2 = bufb;
823 for (i = 0; i < count; i++, p1++, p2++) {
825 printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
826 (unsigned long)*p1, (unsigned long)*p2,
827 *p1 ^ *p2, __ffs(*p1 ^ *p2),
828 (unsigned long)(i * sizeof(unsigned long)));
836 static ulong test_bitflip_comparison(volatile unsigned long *bufa,
837 volatile unsigned long *bufb, size_t count)
839 volatile unsigned long *p1 = bufa;
840 volatile unsigned long *p2 = bufb;
847 max = sizeof(unsigned long) * 8;
848 for (k = 0; k < max; k++) {
849 q = 0x00000001L << k;
850 for (j = 0; j < 8; j++) {
853 p1 = (volatile unsigned long *)bufa;
854 p2 = (volatile unsigned long *)bufb;
855 for (i = 0; i < count; i++)
856 *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
858 errs += compare_regions(bufa, bufb, count);
868 static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
869 vu_long pattern, int iteration)
877 /* Alternate the pattern */
882 * Flip the pattern each time to make lots of zeros and
883 * then, the next time, lots of ones. We decrement
884 * the "negative" patterns and increment the "positive"
885 * patterns to preserve this feature.
887 if (pattern & 0x80000000)
888 pattern = -pattern; /* complement & increment */
892 length = (end_addr - start_addr) / sizeof(ulong);
894 printf("\rPattern %08lX Writing..."
896 "\b\b\b\b\b\b\b\b\b\b",
899 for (addr = buf, val = pattern; addr < end; addr++) {
907 for (addr = buf, val = pattern; addr < end; addr++) {
910 if (readback != val) {
911 ulong offset = addr - buf;
913 printf("\nMem error @ 0x%08X: "
914 "found %08lX, expected %08lX\n",
915 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
928 * Perform a memory test. A more complete alternative test can be
929 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
930 * interrupted by ctrl-c or by a failure of one of the sub-tests.
932 static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc,
936 vu_long scratch_space;
937 vu_long *buf, *dummy = &scratch_space;
938 ulong iteration_limit = 0;
940 ulong errs = 0; /* number of errors, or -1 if interrupted */
944 start = CONFIG_SYS_MEMTEST_START;
945 end = CONFIG_SYS_MEMTEST_END;
948 if (strict_strtoul(argv[1], 16, &start) < 0)
949 return CMD_RET_USAGE;
952 if (strict_strtoul(argv[2], 16, &end) < 0)
953 return CMD_RET_USAGE;
956 if (strict_strtoul(argv[3], 16, &pattern) < 0)
957 return CMD_RET_USAGE;
960 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
961 return CMD_RET_USAGE;
964 printf("Refusing to do empty test\n");
968 printf("Testing %08lx ... %08lx:\n", start, end);
969 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
972 buf = map_sysmem(start, end - start);
974 !iteration_limit || iteration < iteration_limit;
981 printf("Iteration: %6d\r", iteration + 1);
983 if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
984 errs = mem_test_alt(buf, start, end, dummy);
988 errs = test_bitflip_comparison(buf,
989 buf + (end - start) / 2,
991 sizeof(unsigned long));
993 errs = mem_test_quick(buf, start, end, pattern,
1001 unmap_sysmem((void *)buf);
1004 /* Memory test was aborted - write a newline to finish off */
1007 printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
1011 #endif /* CONFIG_CMD_MEMTEST */
1016 * mm{.b, .w, .l, .q} {addr}
1017 * nm{.b, .w, .l, .q} {addr}
1020 mod_mem(struct cmd_tbl *cmdtp, int incrflag, int flag, int argc,
1024 #ifdef MEM_SUPPORT_64BIT_DATA
1033 return CMD_RET_USAGE;
1035 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1036 /* We use the last specified parameters, unless new ones are
1039 addr = mm_last_addr;
1040 size = mm_last_size;
1042 if ((flag & CMD_FLAG_REPEAT) == 0) {
1043 /* New command specified. Check for a size specification.
1044 * Defaults to long if no or incorrect specification.
1046 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1049 /* Address is specified since argc > 1
1051 addr = simple_strtoul(argv[1], NULL, 16);
1052 addr += base_address;
1055 /* Print the address, followed by value. Then accept input for
1056 * the next value. A non-converted value exits.
1059 ptr = map_sysmem(addr, size);
1060 printf("%08lx:", addr);
1062 printf(" %08x", *((u32 *)ptr));
1063 #ifdef MEM_SUPPORT_64BIT_DATA
1065 printf(" %016llx", *((u64 *)ptr));
1068 printf(" %04x", *((u16 *)ptr));
1070 printf(" %02x", *((u8 *)ptr));
1072 nbytes = cli_readline(" ? ");
1073 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1074 /* <CR> pressed as only input, don't modify current
1075 * location and move to next. "-" pressed will go back.
1078 addr += nbytes ? -size : size;
1080 /* good enough to not time out */
1081 bootretry_reset_cmd_timeout();
1083 #ifdef CONFIG_BOOT_RETRY_TIME
1084 else if (nbytes == -2) {
1085 break; /* timed out, exit the command */
1090 #ifdef MEM_SUPPORT_64BIT_DATA
1091 i = simple_strtoull(console_buffer, &endp, 16);
1093 i = simple_strtoul(console_buffer, &endp, 16);
1095 nbytes = endp - console_buffer;
1097 /* good enough to not time out
1099 bootretry_reset_cmd_timeout();
1102 #ifdef MEM_SUPPORT_64BIT_DATA
1118 mm_last_addr = addr;
1119 mm_last_size = size;
1123 #ifdef CONFIG_CMD_CRC32
1125 static int do_mem_crc(struct cmd_tbl *cmdtp, int flag, int argc,
1133 return CMD_RET_USAGE;
1137 #ifdef CONFIG_CRC32_VERIFY
1138 if (strcmp(*av, "-v") == 0) {
1139 flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
1145 return hash_command("crc32", flags, cmdtp, flag, ac, av);
1150 #ifdef CONFIG_CMD_RANDOM
1151 static int do_random(struct cmd_tbl *cmdtp, int flag, int argc,
1154 unsigned long addr, len;
1155 unsigned long seed; // NOT INITIALIZED ON PURPOSE
1156 unsigned int *buf, *start;
1157 unsigned char *buf8;
1160 if (argc < 3 || argc > 4)
1161 return CMD_RET_USAGE;
1163 len = simple_strtoul(argv[2], NULL, 16);
1164 addr = simple_strtoul(argv[1], NULL, 16);
1167 seed = simple_strtoul(argv[3], NULL, 16);
1169 printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
1173 seed = get_timer(0) ^ rand();
1177 start = map_sysmem(addr, len);
1179 for (i = 0; i < (len / 4); i++)
1182 buf8 = (unsigned char *)buf;
1183 for (i = 0; i < (len % 4); i++)
1184 *buf8++ = rand() & 0xFF;
1186 unmap_sysmem(start);
1187 printf("%lu bytes filled with random data\n", len);
1189 return CMD_RET_SUCCESS;
1193 /**************************************************/
1195 md, 3, 1, do_mem_md,
1197 #ifdef MEM_SUPPORT_64BIT_DATA
1198 "[.b, .w, .l, .q] address [# of objects]"
1200 "[.b, .w, .l] address [# of objects]"
1206 mm, 2, 1, do_mem_mm,
1207 "memory modify (auto-incrementing address)",
1208 #ifdef MEM_SUPPORT_64BIT_DATA
1209 "[.b, .w, .l, .q] address"
1211 "[.b, .w, .l] address"
1217 nm, 2, 1, do_mem_nm,
1218 "memory modify (constant address)",
1219 #ifdef MEM_SUPPORT_64BIT_DATA
1220 "[.b, .w, .l, .q] address"
1222 "[.b, .w, .l] address"
1227 mw, 4, 1, do_mem_mw,
1228 "memory write (fill)",
1229 #ifdef MEM_SUPPORT_64BIT_DATA
1230 "[.b, .w, .l, .q] address value [count]"
1232 "[.b, .w, .l] address value [count]"
1237 cp, 4, 1, do_mem_cp,
1239 #ifdef MEM_SUPPORT_64BIT_DATA
1240 "[.b, .w, .l, .q] source target count"
1242 "[.b, .w, .l] source target count"
1247 cmp, 4, 1, do_mem_cmp,
1249 #ifdef MEM_SUPPORT_64BIT_DATA
1250 "[.b, .w, .l, .q] addr1 addr2 count"
1252 "[.b, .w, .l] addr1 addr2 count"
1256 #ifdef CONFIG_CMD_CRC32
1258 #ifndef CONFIG_CRC32_VERIFY
1261 crc32, 4, 1, do_mem_crc,
1262 "checksum calculation",
1263 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1266 #else /* CONFIG_CRC32_VERIFY */
1269 crc32, 5, 1, do_mem_crc,
1270 "checksum calculation",
1271 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1272 "-v address count crc\n - verify crc of memory area"
1275 #endif /* CONFIG_CRC32_VERIFY */
1279 #ifdef CONFIG_CMD_MEMINFO
1280 static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
1284 print_size(gd->ram_size, "\n");
1291 base, 2, 1, do_mem_base,
1292 "print or set address offset",
1293 "\n - print address offset for memory commands\n"
1294 "base off\n - set address offset for memory commands to 'off'"
1298 loop, 3, 1, do_mem_loop,
1299 "infinite loop on address range",
1300 #ifdef MEM_SUPPORT_64BIT_DATA
1301 "[.b, .w, .l, .q] address number_of_objects"
1303 "[.b, .w, .l] address number_of_objects"
1309 loopw, 4, 1, do_mem_loopw,
1310 "infinite write loop on address range",
1311 #ifdef MEM_SUPPORT_64BIT_DATA
1312 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1314 "[.b, .w, .l] address number_of_objects data_to_write"
1317 #endif /* CONFIG_LOOPW */
1319 #ifdef CONFIG_CMD_MEMTEST
1321 mtest, 5, 1, do_mem_mtest,
1322 "simple RAM read/write test",
1323 "[start [end [pattern [iterations]]]]"
1325 #endif /* CONFIG_CMD_MEMTEST */
1327 #ifdef CONFIG_CMD_MX_CYCLIC
1329 mdc, 4, 1, do_mem_mdc,
1330 "memory display cyclic",
1331 #ifdef MEM_SUPPORT_64BIT_DATA
1332 "[.b, .w, .l, .q] address count delay(ms)"
1334 "[.b, .w, .l] address count delay(ms)"
1339 mwc, 4, 1, do_mem_mwc,
1340 "memory write cyclic",
1341 #ifdef MEM_SUPPORT_64BIT_DATA
1342 "[.b, .w, .l, .q] address value delay(ms)"
1344 "[.b, .w, .l] address value delay(ms)"
1347 #endif /* CONFIG_CMD_MX_CYCLIC */
1349 #ifdef CONFIG_CMD_MEMINFO
1351 meminfo, 3, 1, do_mem_info,
1352 "display memory information",
1357 #ifdef CONFIG_CMD_RANDOM
1359 random, 4, 0, do_random,
1360 "fill memory with random pattern",
1361 "<addr> <len> [<seed>]\n"
1362 " - Fill 'len' bytes of memory starting at 'addr' with random data\n"