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>
24 #include <linux/compiler.h>
26 DECLARE_GLOBAL_DATA_PTR;
28 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
29 #define CONFIG_SYS_MEMTEST_SCRATCH 0
32 static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
34 /* Display values from last command.
35 * Memory modify remembered values are different from display memory.
37 static ulong dp_last_addr, dp_last_size;
38 static ulong dp_last_length = 0x40;
39 static ulong mm_last_addr, mm_last_size;
41 static ulong base_address = 0;
46 * md{.b, .w, .l, .q} {addr} {len}
48 #define DISP_LINE_LEN 16
49 static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
51 ulong addr, length, bytes;
56 /* We use the last specified parameters, unless new ones are
61 length = dp_last_length;
66 if ((flag & CMD_FLAG_REPEAT) == 0) {
67 /* New command specified. Check for a size specification.
68 * Defaults to long if no or incorrect specification.
70 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
73 /* Address is specified since argc > 1
75 addr = simple_strtoul(argv[1], NULL, 16);
78 /* If another parameter, it is the length to display.
79 * Length is the number of objects, not number of bytes.
82 length = simple_strtoul(argv[2], NULL, 16);
85 bytes = size * length;
86 buf = map_sysmem(addr, bytes);
88 /* Print the lines. */
89 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
94 dp_last_length = length;
99 static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
101 return mod_mem (cmdtp, 1, flag, argc, argv);
103 static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
105 return mod_mem (cmdtp, 0, flag, argc, argv);
108 static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
110 #ifdef MEM_SUPPORT_64BIT_DATA
120 if ((argc < 3) || (argc > 4))
121 return CMD_RET_USAGE;
123 /* Check for size specification.
125 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
128 /* Address is specified since argc > 1
130 addr = simple_strtoul(argv[1], NULL, 16);
131 addr += base_address;
133 /* Get the value to write.
135 #ifdef MEM_SUPPORT_64BIT_DATA
136 writeval = simple_strtoull(argv[2], NULL, 16);
138 writeval = simple_strtoul(argv[2], NULL, 16);
143 count = simple_strtoul(argv[3], NULL, 16);
148 bytes = size * count;
149 start = map_sysmem(addr, bytes);
151 while (count-- > 0) {
153 *((u32 *)buf) = (u32)writeval;
154 #ifdef MEM_SUPPORT_64BIT_DATA
156 *((u64 *)buf) = (u64)writeval;
159 *((u16 *)buf) = (u16)writeval;
161 *((u8 *)buf) = (u8)writeval;
168 #ifdef CONFIG_CMD_MX_CYCLIC
169 static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
175 return CMD_RET_USAGE;
177 count = simple_strtoul(argv[3], NULL, 10);
180 do_mem_md (NULL, 0, 3, argv);
182 /* delay for <count> ms... */
183 for (i=0; i<count; i++)
186 /* check for ctrl-c to abort... */
196 static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
202 return CMD_RET_USAGE;
204 count = simple_strtoul(argv[3], NULL, 10);
207 do_mem_mw (NULL, 0, 3, argv);
209 /* delay for <count> ms... */
210 for (i=0; i<count; i++)
213 /* check for ctrl-c to abort... */
222 #endif /* CONFIG_CMD_MX_CYCLIC */
224 static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
226 ulong addr1, addr2, count, ngood, bytes;
230 const void *buf1, *buf2, *base;
231 #ifdef MEM_SUPPORT_64BIT_DATA
238 return CMD_RET_USAGE;
240 /* Check for size specification.
242 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
244 type = size == 8 ? "double word" :
246 size == 2 ? "halfword" : "byte";
248 addr1 = simple_strtoul(argv[1], NULL, 16);
249 addr1 += base_address;
251 addr2 = simple_strtoul(argv[2], NULL, 16);
252 addr2 += base_address;
254 count = simple_strtoul(argv[3], NULL, 16);
256 bytes = size * count;
257 base = buf1 = map_sysmem(addr1, bytes);
258 buf2 = map_sysmem(addr2, bytes);
259 for (ngood = 0; ngood < count; ++ngood) {
261 word1 = *(u32 *)buf1;
262 word2 = *(u32 *)buf2;
263 #ifdef MEM_SUPPORT_64BIT_DATA
264 } else if (size == 8) {
265 word1 = *(u64 *)buf1;
266 word2 = *(u64 *)buf2;
268 } else if (size == 2) {
269 word1 = *(u16 *)buf1;
270 word2 = *(u16 *)buf2;
275 if (word1 != word2) {
276 ulong offset = buf1 - base;
277 #ifdef MEM_SUPPORT_64BIT_DATA
278 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
279 type, (void *)(addr1 + offset), size, word1,
280 type, (void *)(addr2 + offset), size, word2);
282 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
283 type, (ulong)(addr1 + offset), size, word1,
284 type, (ulong)(addr2 + offset), size, word2);
293 /* reset watchdog from time to time */
294 if ((ngood % (64 << 10)) == 0)
300 printf("Total of %ld %s(s) were the same\n", ngood, type);
304 static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
306 ulong addr, dest, count;
311 return CMD_RET_USAGE;
313 /* Check for size specification.
315 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
318 addr = simple_strtoul(argv[1], NULL, 16);
319 addr += base_address;
321 dest = simple_strtoul(argv[2], NULL, 16);
322 dest += base_address;
324 count = simple_strtoul(argv[3], NULL, 16);
327 puts ("Zero length ???\n");
331 src = map_sysmem(addr, count * size);
332 dst = map_sysmem(dest, count * size);
334 #ifdef CONFIG_MTD_NOR_FLASH
335 /* check if we are copying to Flash */
336 if (addr2info((ulong)dst)) {
339 puts ("Copy to Flash... ");
341 rc = flash_write((char *)src, (ulong)dst, count * size);
355 memcpy(dst, src, count * size);
362 static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
366 /* Set new base address.
368 base_address = simple_strtoul(argv[1], NULL, 16);
370 /* Print the current base address.
372 printf("Base Address: 0x%08lx\n", base_address);
376 static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
379 ulong addr, length, i, bytes;
381 #ifdef MEM_SUPPORT_64BIT_DATA
385 volatile u16 *shortp;
390 return CMD_RET_USAGE;
393 * Check for a size specification.
394 * Defaults to long if no or incorrect specification.
396 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
399 /* Address is always specified.
401 addr = simple_strtoul(argv[1], NULL, 16);
403 /* Length is the number of objects, not number of bytes.
405 length = simple_strtoul(argv[2], NULL, 16);
407 bytes = size * length;
408 buf = map_sysmem(addr, bytes);
410 /* We want to optimize the loops to run as fast as possible.
411 * If we have only one object, just run infinite loops.
414 #ifdef MEM_SUPPORT_64BIT_DATA
436 #ifdef MEM_SUPPORT_64BIT_DATA
474 static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc,
477 ulong addr, length, i, bytes;
479 #ifdef MEM_SUPPORT_64BIT_DATA
486 volatile u16 *shortp;
491 return CMD_RET_USAGE;
494 * Check for a size specification.
495 * Defaults to long if no or incorrect specification.
497 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
500 /* Address is always specified.
502 addr = simple_strtoul(argv[1], NULL, 16);
504 /* Length is the number of objects, not number of bytes.
506 length = simple_strtoul(argv[2], NULL, 16);
509 #ifdef MEM_SUPPORT_64BIT_DATA
510 data = simple_strtoull(argv[3], NULL, 16);
512 data = simple_strtoul(argv[3], NULL, 16);
515 bytes = size * length;
516 buf = map_sysmem(addr, bytes);
518 /* We want to optimize the loops to run as fast as possible.
519 * If we have only one object, just run infinite loops.
522 #ifdef MEM_SUPPORT_64BIT_DATA
544 #ifdef MEM_SUPPORT_64BIT_DATA
577 #endif /* CONFIG_LOOPW */
579 #ifdef CONFIG_CMD_MEMTEST
580 static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
591 vu_long anti_pattern;
593 static const ulong bitpattern[] = {
594 0x00000001, /* single bit */
595 0x00000003, /* two adjacent bits */
596 0x00000007, /* three adjacent bits */
597 0x0000000F, /* four adjacent bits */
598 0x00000005, /* two non-adjacent bits */
599 0x00000015, /* three non-adjacent bits */
600 0x00000055, /* four non-adjacent bits */
601 0xaaaaaaaa, /* alternating 1/0 */
604 num_words = (end_addr - start_addr) / sizeof(vu_long);
607 * Data line test: write a pattern to the first
608 * location, write the 1's complement to a 'parking'
609 * address (changes the state of the data bus so a
610 * floating bus doesn't give a false OK), and then
611 * read the value back. Note that we read it back
612 * into a variable because the next time we read it,
613 * it might be right (been there, tough to explain to
614 * the quality guys why it prints a failure when the
615 * "is" and "should be" are obviously the same in the
618 * Rather than exhaustively testing, we test some
619 * patterns by shifting '1' bits through a field of
620 * '0's and '0' bits through a field of '1's (i.e.
621 * pattern and ~pattern).
624 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
626 for (; val != 0; val <<= 1) {
628 *dummy = ~val; /* clear the test data off the bus */
630 if (readback != val) {
631 printf("FAILURE (data line): "
632 "expected %08lx, actual %08lx\n",
641 if (readback != ~val) {
642 printf("FAILURE (data line): "
643 "Is %08lx, should be %08lx\n",
653 * Based on code whose Original Author and Copyright
654 * information follows: Copyright (c) 1998 by Michael
655 * Barr. This software is placed into the public
656 * domain and may be used for any purpose. However,
657 * this notice must not be changed or removed and no
658 * warranty is either expressed or implied by its
659 * publication or distribution.
665 * Description: Test the address bus wiring in a
666 * memory region by performing a walking
667 * 1's test on the relevant bits of the
668 * address and checking for aliasing.
669 * This test will find single-bit
670 * address failures such as stuck-high,
671 * stuck-low, and shorted pins. The base
672 * address and size of the region are
673 * selected by the caller.
675 * Notes: For best results, the selected base
676 * address should have enough LSB 0's to
677 * guarantee single address bit changes.
678 * For example, to test a 64-Kbyte
679 * region, select a base address on a
680 * 64-Kbyte boundary. Also, select the
681 * region size as a power-of-two if at
684 * Returns: 0 if the test succeeds, 1 if the test fails.
686 pattern = (vu_long) 0xaaaaaaaa;
687 anti_pattern = (vu_long) 0x55555555;
689 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
691 * Write the default pattern at each of the
692 * power-of-two offsets.
694 for (offset = 1; offset < num_words; offset <<= 1)
695 addr[offset] = pattern;
698 * Check for address bits stuck high.
701 addr[test_offset] = anti_pattern;
703 for (offset = 1; offset < num_words; offset <<= 1) {
705 if (temp != pattern) {
706 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
707 " expected 0x%.8lx, actual 0x%.8lx\n",
708 start_addr + offset*sizeof(vu_long),
715 addr[test_offset] = pattern;
719 * Check for addr bits stuck low or shorted.
721 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
722 addr[test_offset] = anti_pattern;
724 for (offset = 1; offset < num_words; offset <<= 1) {
726 if ((temp != pattern) && (offset != test_offset)) {
727 printf("\nFAILURE: Address bit stuck low or"
728 " shorted @ 0x%.8lx: expected 0x%.8lx,"
730 start_addr + offset*sizeof(vu_long),
737 addr[test_offset] = pattern;
741 * Description: Test the integrity of a physical
742 * memory device by performing an
743 * increment/decrement test over the
744 * entire region. In the process every
745 * storage bit in the device is tested
746 * as a zero and a one. The base address
747 * and the size of the region are
748 * selected by the caller.
750 * Returns: 0 if the test succeeds, 1 if the test fails.
755 * Fill memory with a known pattern.
757 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
759 addr[offset] = pattern;
763 * Check each location and invert it for the second pass.
765 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
768 if (temp != pattern) {
769 printf("\nFAILURE (read/write) @ 0x%.8lx:"
770 " expected 0x%.8lx, actual 0x%.8lx)\n",
771 start_addr + offset*sizeof(vu_long),
778 anti_pattern = ~pattern;
779 addr[offset] = anti_pattern;
783 * Check each location for the inverted pattern and zero it.
785 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
787 anti_pattern = ~pattern;
789 if (temp != anti_pattern) {
790 printf("\nFAILURE (read/write): @ 0x%.8lx:"
791 " expected 0x%.8lx, actual 0x%.8lx)\n",
792 start_addr + offset*sizeof(vu_long),
804 static int compare_regions(volatile unsigned long *bufa,
805 volatile unsigned long *bufb, size_t count)
807 volatile unsigned long *p1 = bufa;
808 volatile unsigned long *p2 = bufb;
812 for (i = 0; i < count; i++, p1++, p2++) {
814 printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
815 (unsigned long)*p1, (unsigned long)*p2,
816 *p1 ^ *p2, __ffs(*p1 ^ *p2),
817 (unsigned long)(i * sizeof(unsigned long)));
825 static ulong test_bitflip_comparison(volatile unsigned long *bufa,
826 volatile unsigned long *bufb, size_t count)
828 volatile unsigned long *p1 = bufa;
829 volatile unsigned long *p2 = bufb;
836 max = sizeof(unsigned long) * 8;
837 for (k = 0; k < max; k++) {
838 q = 0x00000001L << k;
839 for (j = 0; j < 8; j++) {
842 p1 = (volatile unsigned long *)bufa;
843 p2 = (volatile unsigned long *)bufb;
844 for (i = 0; i < count; i++)
845 *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
847 errs += compare_regions(bufa, bufb, count);
857 static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
858 vu_long pattern, int iteration)
866 /* Alternate the pattern */
871 * Flip the pattern each time to make lots of zeros and
872 * then, the next time, lots of ones. We decrement
873 * the "negative" patterns and increment the "positive"
874 * patterns to preserve this feature.
876 if (pattern & 0x80000000)
877 pattern = -pattern; /* complement & increment */
881 length = (end_addr - start_addr) / sizeof(ulong);
883 printf("\rPattern %08lX Writing..."
885 "\b\b\b\b\b\b\b\b\b\b",
888 for (addr = buf, val = pattern; addr < end; addr++) {
896 for (addr = buf, val = pattern; addr < end; addr++) {
899 if (readback != val) {
900 ulong offset = addr - buf;
902 printf("\nMem error @ 0x%08X: "
903 "found %08lX, expected %08lX\n",
904 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
917 * Perform a memory test. A more complete alternative test can be
918 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
919 * interrupted by ctrl-c or by a failure of one of the sub-tests.
921 static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
925 vu_long *buf, *dummy;
926 ulong iteration_limit = 0;
928 ulong errs = 0; /* number of errors, or -1 if interrupted */
932 start = CONFIG_SYS_MEMTEST_START;
933 end = CONFIG_SYS_MEMTEST_END;
936 if (strict_strtoul(argv[1], 16, &start) < 0)
937 return CMD_RET_USAGE;
940 if (strict_strtoul(argv[2], 16, &end) < 0)
941 return CMD_RET_USAGE;
944 if (strict_strtoul(argv[3], 16, &pattern) < 0)
945 return CMD_RET_USAGE;
948 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
949 return CMD_RET_USAGE;
952 printf("Refusing to do empty test\n");
956 printf("Testing %08lx ... %08lx:\n", start, end);
957 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
960 buf = map_sysmem(start, end - start);
961 dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
963 !iteration_limit || iteration < iteration_limit;
970 printf("Iteration: %6d\r", iteration + 1);
972 if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
973 errs = mem_test_alt(buf, start, end, dummy);
977 errs = test_bitflip_comparison(buf,
978 buf + (end - start) / 2,
980 sizeof(unsigned long));
982 errs = mem_test_quick(buf, start, end, pattern,
990 unmap_sysmem((void *)buf);
991 unmap_sysmem((void *)dummy);
994 /* Memory test was aborted - write a newline to finish off */
997 printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
1001 #endif /* CONFIG_CMD_MEMTEST */
1006 * mm{.b, .w, .l, .q} {addr}
1007 * nm{.b, .w, .l, .q} {addr}
1010 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
1013 #ifdef MEM_SUPPORT_64BIT_DATA
1022 return CMD_RET_USAGE;
1024 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1025 /* We use the last specified parameters, unless new ones are
1028 addr = mm_last_addr;
1029 size = mm_last_size;
1031 if ((flag & CMD_FLAG_REPEAT) == 0) {
1032 /* New command specified. Check for a size specification.
1033 * Defaults to long if no or incorrect specification.
1035 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1038 /* Address is specified since argc > 1
1040 addr = simple_strtoul(argv[1], NULL, 16);
1041 addr += base_address;
1044 /* Print the address, followed by value. Then accept input for
1045 * the next value. A non-converted value exits.
1048 ptr = map_sysmem(addr, size);
1049 printf("%08lx:", addr);
1051 printf(" %08x", *((u32 *)ptr));
1052 #ifdef MEM_SUPPORT_64BIT_DATA
1054 printf(" %016llx", *((u64 *)ptr));
1057 printf(" %04x", *((u16 *)ptr));
1059 printf(" %02x", *((u8 *)ptr));
1061 nbytes = cli_readline(" ? ");
1062 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1063 /* <CR> pressed as only input, don't modify current
1064 * location and move to next. "-" pressed will go back.
1067 addr += nbytes ? -size : size;
1069 /* good enough to not time out */
1070 bootretry_reset_cmd_timeout();
1072 #ifdef CONFIG_BOOT_RETRY_TIME
1073 else if (nbytes == -2) {
1074 break; /* timed out, exit the command */
1079 #ifdef MEM_SUPPORT_64BIT_DATA
1080 i = simple_strtoull(console_buffer, &endp, 16);
1082 i = simple_strtoul(console_buffer, &endp, 16);
1084 nbytes = endp - console_buffer;
1086 /* good enough to not time out
1088 bootretry_reset_cmd_timeout();
1091 #ifdef MEM_SUPPORT_64BIT_DATA
1107 mm_last_addr = addr;
1108 mm_last_size = size;
1112 #ifdef CONFIG_CMD_CRC32
1114 static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1121 return CMD_RET_USAGE;
1125 #ifdef CONFIG_CRC32_VERIFY
1126 if (strcmp(*av, "-v") == 0) {
1127 flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
1133 return hash_command("crc32", flags, cmdtp, flag, ac, av);
1138 #ifdef CONFIG_CMD_RANDOM
1139 static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1141 unsigned long addr, len;
1142 unsigned long seed; // NOT INITIALIZED ON PURPOSE
1143 unsigned int *buf, *start;
1144 unsigned char *buf8;
1147 if (argc < 3 || argc > 4) {
1148 printf("usage: %s <addr> <len> [<seed>]\n", argv[0]);
1152 len = simple_strtoul(argv[2], NULL, 16);
1153 addr = simple_strtoul(argv[1], NULL, 16);
1156 seed = simple_strtoul(argv[3], NULL, 16);
1158 printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
1162 seed = get_timer(0) ^ rand();
1166 start = map_sysmem(addr, len);
1168 for (i = 0; i < (len / 4); i++)
1171 buf8 = (unsigned char *)buf;
1172 for (i = 0; i < (len % 4); i++)
1173 *buf8++ = rand() & 0xFF;
1175 unmap_sysmem(start);
1176 printf("%lu bytes filled with random data\n", len);
1181 /**************************************************/
1183 md, 3, 1, do_mem_md,
1185 #ifdef MEM_SUPPORT_64BIT_DATA
1186 "[.b, .w, .l, .q] address [# of objects]"
1188 "[.b, .w, .l] address [# of objects]"
1194 mm, 2, 1, do_mem_mm,
1195 "memory modify (auto-incrementing address)",
1196 #ifdef MEM_SUPPORT_64BIT_DATA
1197 "[.b, .w, .l, .q] address"
1199 "[.b, .w, .l] address"
1205 nm, 2, 1, do_mem_nm,
1206 "memory modify (constant address)",
1207 #ifdef MEM_SUPPORT_64BIT_DATA
1208 "[.b, .w, .l, .q] address"
1210 "[.b, .w, .l] address"
1215 mw, 4, 1, do_mem_mw,
1216 "memory write (fill)",
1217 #ifdef MEM_SUPPORT_64BIT_DATA
1218 "[.b, .w, .l, .q] address value [count]"
1220 "[.b, .w, .l] address value [count]"
1225 cp, 4, 1, do_mem_cp,
1227 #ifdef MEM_SUPPORT_64BIT_DATA
1228 "[.b, .w, .l, .q] source target count"
1230 "[.b, .w, .l] source target count"
1235 cmp, 4, 1, do_mem_cmp,
1237 #ifdef MEM_SUPPORT_64BIT_DATA
1238 "[.b, .w, .l, .q] addr1 addr2 count"
1240 "[.b, .w, .l] addr1 addr2 count"
1244 #ifdef CONFIG_CMD_CRC32
1246 #ifndef CONFIG_CRC32_VERIFY
1249 crc32, 4, 1, do_mem_crc,
1250 "checksum calculation",
1251 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1254 #else /* CONFIG_CRC32_VERIFY */
1257 crc32, 5, 1, do_mem_crc,
1258 "checksum calculation",
1259 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1260 "-v address count crc\n - verify crc of memory area"
1263 #endif /* CONFIG_CRC32_VERIFY */
1267 #ifdef CONFIG_CMD_MEMINFO
1268 static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
1269 char * const argv[])
1272 print_size(gd->ram_size, "\n");
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 MEM_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 MEM_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_CMD_MX_CYCLIC
1317 mdc, 4, 1, do_mem_mdc,
1318 "memory display cyclic",
1319 #ifdef MEM_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 MEM_SUPPORT_64BIT_DATA
1330 "[.b, .w, .l, .q] address value delay(ms)"
1332 "[.b, .w, .l] address value delay(ms)"
1335 #endif /* CONFIG_CMD_MX_CYCLIC */
1337 #ifdef CONFIG_CMD_MEMINFO
1339 meminfo, 3, 1, do_mem_info,
1340 "display memory information",
1345 #ifdef CONFIG_CMD_RANDOM
1347 random, 4, 0, do_random,
1348 "fill memory with random pattern",
1349 "<addr> <len> [<seed>]\n"
1350 " - Fill 'len' bytes of memory starting at 'addr' with random data\n"