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)
15 #include <bootretry.h>
18 #ifdef CONFIG_HAS_DATAFLASH
19 #include <dataflash.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 uint dp_last_addr, dp_last_size;
38 static uint dp_last_length = 0x40;
39 static uint 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[])
52 #if defined(CONFIG_HAS_DATAFLASH)
53 ulong nbytes, linebytes;
58 /* We use the last specified parameters, unless new ones are
63 length = dp_last_length;
68 if ((flag & CMD_FLAG_REPEAT) == 0) {
69 /* New command specified. Check for a size specification.
70 * Defaults to long if no or incorrect specification.
72 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
75 /* Address is specified since argc > 1
77 addr = simple_strtoul(argv[1], NULL, 16);
80 /* If another parameter, it is the length to display.
81 * Length is the number of objects, not number of bytes.
84 length = simple_strtoul(argv[2], NULL, 16);
87 #if defined(CONFIG_HAS_DATAFLASH)
90 * We buffer all read data, so we can make sure data is read only
91 * once, and all accesses are with the specified bus width.
93 nbytes = length * size;
95 char linebuf[DISP_LINE_LEN];
97 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
99 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
100 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
101 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
109 } while (nbytes > 0);
112 # if defined(CONFIG_BLACKFIN)
113 /* See if we're trying to display L1 inst */
114 if (addr_bfin_on_chip_mem(addr)) {
115 char linebuf[DISP_LINE_LEN];
116 ulong linebytes, nbytes = length * size;
118 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
119 memcpy(linebuf, (void *)addr, linebytes);
120 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
128 } while (nbytes > 0);
133 ulong bytes = size * length;
134 const void *buf = map_sysmem(addr, bytes);
136 /* Print the lines. */
137 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
144 dp_last_length = length;
149 static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
151 return mod_mem (cmdtp, 1, flag, argc, argv);
153 static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
155 return mod_mem (cmdtp, 0, flag, argc, argv);
158 static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
160 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
170 if ((argc < 3) || (argc > 4))
171 return CMD_RET_USAGE;
173 /* Check for size specification.
175 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
178 /* Address is specified since argc > 1
180 addr = simple_strtoul(argv[1], NULL, 16);
181 addr += base_address;
183 /* Get the value to write.
185 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
186 writeval = simple_strtoull(argv[2], NULL, 16);
188 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 *((u32 *)buf) = (u32)writeval;
203 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
205 *((u64 *)buf) = (u64)writeval;
208 *((u16 *)buf) = (u16)writeval;
210 *((u8 *)buf) = (u8)writeval;
217 #ifdef CONFIG_MX_CYCLIC
218 static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
224 return CMD_RET_USAGE;
226 count = simple_strtoul(argv[3], NULL, 10);
229 do_mem_md (NULL, 0, 3, argv);
231 /* delay for <count> ms... */
232 for (i=0; i<count; i++)
235 /* check for ctrl-c to abort... */
245 static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
251 return CMD_RET_USAGE;
253 count = simple_strtoul(argv[3], NULL, 10);
256 do_mem_mw (NULL, 0, 3, argv);
258 /* delay for <count> ms... */
259 for (i=0; i<count; i++)
262 /* check for ctrl-c to abort... */
271 #endif /* CONFIG_MX_CYCLIC */
273 static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
275 ulong addr1, addr2, count, ngood, bytes;
279 const void *buf1, *buf2, *base;
280 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
287 return CMD_RET_USAGE;
289 /* Check for size specification.
291 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
293 type = size == 8 ? "double word" :
295 size == 2 ? "halfword" : "byte";
297 addr1 = simple_strtoul(argv[1], NULL, 16);
298 addr1 += base_address;
300 addr2 = simple_strtoul(argv[2], NULL, 16);
301 addr2 += base_address;
303 count = simple_strtoul(argv[3], NULL, 16);
305 #ifdef CONFIG_HAS_DATAFLASH
306 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
307 puts ("Comparison with DataFlash space not supported.\n\r");
312 #ifdef CONFIG_BLACKFIN
313 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
314 puts ("Comparison with L1 instruction memory not supported.\n\r");
319 bytes = size * count;
320 base = buf1 = map_sysmem(addr1, bytes);
321 buf2 = map_sysmem(addr2, bytes);
322 for (ngood = 0; ngood < count; ++ngood) {
324 word1 = *(u32 *)buf1;
325 word2 = *(u32 *)buf2;
326 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
327 } else if (size == 8) {
328 word1 = *(u64 *)buf1;
329 word2 = *(u64 *)buf2;
331 } else if (size == 2) {
332 word1 = *(u16 *)buf1;
333 word2 = *(u16 *)buf2;
338 if (word1 != word2) {
339 ulong offset = buf1 - base;
340 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
341 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
342 type, (void *)(addr1 + offset), size, word1,
343 type, (void *)(addr2 + offset), size, word2);
345 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
346 type, (ulong)(addr1 + offset), size, word1,
347 type, (ulong)(addr2 + offset), size, word2);
356 /* reset watchdog from time to time */
357 if ((ngood % (64 << 10)) == 0)
363 printf("Total of %ld %s(s) were the same\n", ngood, type);
367 static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
369 ulong addr, dest, count, bytes;
375 return CMD_RET_USAGE;
377 /* Check for size specification.
379 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
382 addr = simple_strtoul(argv[1], NULL, 16);
383 addr += base_address;
385 dest = simple_strtoul(argv[2], NULL, 16);
386 dest += base_address;
388 count = simple_strtoul(argv[3], NULL, 16);
391 puts ("Zero length ???\n");
395 #ifndef CONFIG_SYS_NO_FLASH
396 /* check if we are copying to Flash */
397 if ( (addr2info(dest) != NULL)
398 #ifdef CONFIG_HAS_DATAFLASH
399 && (!addr_dataflash(dest))
404 puts ("Copy to Flash... ");
406 rc = flash_write ((char *)addr, dest, count*size);
416 #ifdef CONFIG_HAS_DATAFLASH
417 /* Check if we are copying from RAM or Flash to DataFlash */
418 if (addr_dataflash(dest) && !addr_dataflash(addr)){
421 puts ("Copy to DataFlash... ");
423 rc = write_dataflash (dest, addr, count*size);
426 dataflash_perror (rc);
433 /* Check if we are copying from DataFlash to RAM */
434 if (addr_dataflash(addr) && !addr_dataflash(dest)
435 #ifndef CONFIG_SYS_NO_FLASH
436 && (addr2info(dest) == NULL)
440 rc = read_dataflash(addr, count * size, (char *) dest);
442 dataflash_perror (rc);
448 if (addr_dataflash(addr) && addr_dataflash(dest)){
449 puts ("Unsupported combination of source/destination.\n\r");
454 #ifdef CONFIG_BLACKFIN
455 /* See if we're copying to/from L1 inst */
456 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
457 memcpy((void *)dest, (void *)addr, count * size);
462 bytes = size * count;
463 buf = map_sysmem(dest, bytes);
464 src = map_sysmem(addr, bytes);
465 while (count-- > 0) {
467 *((u32 *)buf) = *((u32 *)src);
468 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
470 *((u64 *)buf) = *((u64 *)src);
473 *((u16 *)buf) = *((u16 *)src);
475 *((u8 *)buf) = *((u8 *)src);
479 /* reset watchdog from time to time */
480 if ((count % (64 << 10)) == 0)
486 static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
490 /* Set new base address.
492 base_address = simple_strtoul(argv[1], NULL, 16);
494 /* Print the current base address.
496 printf("Base Address: 0x%08lx\n", base_address);
500 static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
503 ulong addr, length, i, bytes;
505 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
509 volatile u16 *shortp;
514 return CMD_RET_USAGE;
517 * Check for a size specification.
518 * Defaults to long if no or incorrect specification.
520 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
523 /* Address is always specified.
525 addr = simple_strtoul(argv[1], NULL, 16);
527 /* Length is the number of objects, not number of bytes.
529 length = simple_strtoul(argv[2], NULL, 16);
531 bytes = size * length;
532 buf = map_sysmem(addr, bytes);
534 /* We want to optimize the loops to run as fast as possible.
535 * If we have only one object, just run infinite loops.
538 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
560 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
598 static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc,
601 ulong addr, length, i, bytes;
603 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
610 volatile u16 *shortp;
615 return CMD_RET_USAGE;
618 * Check for a size specification.
619 * Defaults to long if no or incorrect specification.
621 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
624 /* Address is always specified.
626 addr = simple_strtoul(argv[1], NULL, 16);
628 /* Length is the number of objects, not number of bytes.
630 length = simple_strtoul(argv[2], NULL, 16);
633 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
634 data = simple_strtoull(argv[3], NULL, 16);
636 data = simple_strtoul(argv[3], NULL, 16);
639 bytes = size * length;
640 buf = map_sysmem(addr, bytes);
642 /* We want to optimize the loops to run as fast as possible.
643 * If we have only one object, just run infinite loops.
646 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
668 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
701 #endif /* CONFIG_LOOPW */
703 #ifdef CONFIG_CMD_MEMTEST
704 static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
715 vu_long anti_pattern;
717 static const ulong bitpattern[] = {
718 0x00000001, /* single bit */
719 0x00000003, /* two adjacent bits */
720 0x00000007, /* three adjacent bits */
721 0x0000000F, /* four adjacent bits */
722 0x00000005, /* two non-adjacent bits */
723 0x00000015, /* three non-adjacent bits */
724 0x00000055, /* four non-adjacent bits */
725 0xaaaaaaaa, /* alternating 1/0 */
728 num_words = (end_addr - start_addr) / sizeof(vu_long);
731 * Data line test: write a pattern to the first
732 * location, write the 1's complement to a 'parking'
733 * address (changes the state of the data bus so a
734 * floating bus doesn't give a false OK), and then
735 * read the value back. Note that we read it back
736 * into a variable because the next time we read it,
737 * it might be right (been there, tough to explain to
738 * the quality guys why it prints a failure when the
739 * "is" and "should be" are obviously the same in the
742 * Rather than exhaustively testing, we test some
743 * patterns by shifting '1' bits through a field of
744 * '0's and '0' bits through a field of '1's (i.e.
745 * pattern and ~pattern).
748 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
750 for (; val != 0; val <<= 1) {
752 *dummy = ~val; /* clear the test data off the bus */
754 if (readback != val) {
755 printf("FAILURE (data line): "
756 "expected %08lx, actual %08lx\n",
765 if (readback != ~val) {
766 printf("FAILURE (data line): "
767 "Is %08lx, should be %08lx\n",
777 * Based on code whose Original Author and Copyright
778 * information follows: Copyright (c) 1998 by Michael
779 * Barr. This software is placed into the public
780 * domain and may be used for any purpose. However,
781 * this notice must not be changed or removed and no
782 * warranty is either expressed or implied by its
783 * publication or distribution.
789 * Description: Test the address bus wiring in a
790 * memory region by performing a walking
791 * 1's test on the relevant bits of the
792 * address and checking for aliasing.
793 * This test will find single-bit
794 * address failures such as stuck-high,
795 * stuck-low, and shorted pins. The base
796 * address and size of the region are
797 * selected by the caller.
799 * Notes: For best results, the selected base
800 * address should have enough LSB 0's to
801 * guarantee single address bit changes.
802 * For example, to test a 64-Kbyte
803 * region, select a base address on a
804 * 64-Kbyte boundary. Also, select the
805 * region size as a power-of-two if at
808 * Returns: 0 if the test succeeds, 1 if the test fails.
810 pattern = (vu_long) 0xaaaaaaaa;
811 anti_pattern = (vu_long) 0x55555555;
813 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
815 * Write the default pattern at each of the
816 * power-of-two offsets.
818 for (offset = 1; offset < num_words; offset <<= 1)
819 addr[offset] = pattern;
822 * Check for address bits stuck high.
825 addr[test_offset] = anti_pattern;
827 for (offset = 1; offset < num_words; offset <<= 1) {
829 if (temp != pattern) {
830 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
831 " expected 0x%.8lx, actual 0x%.8lx\n",
832 start_addr + offset*sizeof(vu_long),
839 addr[test_offset] = pattern;
843 * Check for addr bits stuck low or shorted.
845 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
846 addr[test_offset] = anti_pattern;
848 for (offset = 1; offset < num_words; offset <<= 1) {
850 if ((temp != pattern) && (offset != test_offset)) {
851 printf("\nFAILURE: Address bit stuck low or"
852 " shorted @ 0x%.8lx: expected 0x%.8lx,"
854 start_addr + offset*sizeof(vu_long),
861 addr[test_offset] = pattern;
865 * Description: Test the integrity of a physical
866 * memory device by performing an
867 * increment/decrement test over the
868 * entire region. In the process every
869 * storage bit in the device is tested
870 * as a zero and a one. The base address
871 * and the size of the region are
872 * selected by the caller.
874 * Returns: 0 if the test succeeds, 1 if the test fails.
879 * Fill memory with a known pattern.
881 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
883 addr[offset] = pattern;
887 * Check each location and invert it for the second pass.
889 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
892 if (temp != pattern) {
893 printf("\nFAILURE (read/write) @ 0x%.8lx:"
894 " expected 0x%.8lx, actual 0x%.8lx)\n",
895 start_addr + offset*sizeof(vu_long),
902 anti_pattern = ~pattern;
903 addr[offset] = anti_pattern;
907 * Check each location for the inverted pattern and zero it.
909 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
911 anti_pattern = ~pattern;
913 if (temp != anti_pattern) {
914 printf("\nFAILURE (read/write): @ 0x%.8lx:"
915 " expected 0x%.8lx, actual 0x%.8lx)\n",
916 start_addr + offset*sizeof(vu_long),
928 static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
929 vu_long pattern, int iteration)
937 /* Alternate the pattern */
942 * Flip the pattern each time to make lots of zeros and
943 * then, the next time, lots of ones. We decrement
944 * the "negative" patterns and increment the "positive"
945 * patterns to preserve this feature.
947 if (pattern & 0x80000000)
948 pattern = -pattern; /* complement & increment */
952 length = (end_addr - start_addr) / sizeof(ulong);
954 printf("\rPattern %08lX Writing..."
956 "\b\b\b\b\b\b\b\b\b\b",
959 for (addr = buf, val = pattern; addr < end; addr++) {
967 for (addr = buf, val = pattern; addr < end; addr++) {
970 if (readback != val) {
971 ulong offset = addr - buf;
973 printf("\nMem error @ 0x%08X: "
974 "found %08lX, expected %08lX\n",
975 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
988 * Perform a memory test. A more complete alternative test can be
989 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
990 * interrupted by ctrl-c or by a failure of one of the sub-tests.
992 static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
996 vu_long *buf, *dummy;
999 ulong errs = 0; /* number of errors, or -1 if interrupted */
1002 #if defined(CONFIG_SYS_ALT_MEMTEST)
1003 const int alt_test = 1;
1005 const int alt_test = 0;
1009 start = simple_strtoul(argv[1], NULL, 16);
1011 start = CONFIG_SYS_MEMTEST_START;
1014 end = simple_strtoul(argv[2], NULL, 16);
1016 end = CONFIG_SYS_MEMTEST_END;
1019 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
1024 iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
1026 iteration_limit = 0;
1028 printf("Testing %08x ... %08x:\n", (uint)start, (uint)end);
1029 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
1032 buf = map_sysmem(start, end - start);
1033 dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
1035 !iteration_limit || iteration < iteration_limit;
1042 printf("Iteration: %6d\r", iteration + 1);
1045 errs = mem_test_alt(buf, start, end, dummy);
1047 errs = mem_test_quick(buf, start, end, pattern,
1055 * Work-around for eldk-4.2 which gives this warning if we try to
1056 * case in the unmap_sysmem() call:
1057 * warning: initialization discards qualifiers from pointer target type
1060 void *vbuf = (void *)buf;
1061 void *vdummy = (void *)dummy;
1064 unmap_sysmem(vdummy);
1068 /* Memory test was aborted - write a newline to finish off */
1072 printf("Tested %d iteration(s) with %lu errors.\n",
1077 return ret; /* not reached */
1079 #endif /* CONFIG_CMD_MEMTEST */
1084 * mm{.b, .w, .l, .q} {addr}
1085 * nm{.b, .w, .l, .q} {addr}
1088 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
1091 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1100 return CMD_RET_USAGE;
1102 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1103 /* We use the last specified parameters, unless new ones are
1106 addr = mm_last_addr;
1107 size = mm_last_size;
1109 if ((flag & CMD_FLAG_REPEAT) == 0) {
1110 /* New command specified. Check for a size specification.
1111 * Defaults to long if no or incorrect specification.
1113 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1116 /* Address is specified since argc > 1
1118 addr = simple_strtoul(argv[1], NULL, 16);
1119 addr += base_address;
1122 #ifdef CONFIG_HAS_DATAFLASH
1123 if (addr_dataflash(addr)){
1124 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1129 #ifdef CONFIG_BLACKFIN
1130 if (addr_bfin_on_chip_mem(addr)) {
1131 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1136 /* Print the address, followed by value. Then accept input for
1137 * the next value. A non-converted value exits.
1140 ptr = map_sysmem(addr, size);
1141 printf("%08lx:", addr);
1143 printf(" %08x", *((u32 *)ptr));
1144 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1146 printf(" %016llx", *((u64 *)ptr));
1149 printf(" %04x", *((u16 *)ptr));
1151 printf(" %02x", *((u8 *)ptr));
1153 nbytes = cli_readline(" ? ");
1154 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1155 /* <CR> pressed as only input, don't modify current
1156 * location and move to next. "-" pressed will go back.
1159 addr += nbytes ? -size : size;
1161 /* good enough to not time out */
1162 bootretry_reset_cmd_timeout();
1164 #ifdef CONFIG_BOOT_RETRY_TIME
1165 else if (nbytes == -2) {
1166 break; /* timed out, exit the command */
1171 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1172 i = simple_strtoull(console_buffer, &endp, 16);
1174 i = simple_strtoul(console_buffer, &endp, 16);
1176 nbytes = endp - console_buffer;
1178 /* good enough to not time out
1180 bootretry_reset_cmd_timeout();
1183 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1199 mm_last_addr = addr;
1200 mm_last_size = size;
1204 #ifdef CONFIG_CMD_CRC32
1206 static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1213 return CMD_RET_USAGE;
1217 #ifdef CONFIG_HASH_VERIFY
1218 if (strcmp(*av, "-v") == 0) {
1219 flags |= HASH_FLAG_VERIFY;
1225 return hash_command("crc32", flags, cmdtp, flag, ac, av);
1230 /**************************************************/
1232 md, 3, 1, do_mem_md,
1234 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1235 "[.b, .w, .l, .q] address [# of objects]"
1237 "[.b, .w, .l] address [# of objects]"
1243 mm, 2, 1, do_mem_mm,
1244 "memory modify (auto-incrementing address)",
1245 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1246 "[.b, .w, .l, .q] address"
1248 "[.b, .w, .l] address"
1254 nm, 2, 1, do_mem_nm,
1255 "memory modify (constant address)",
1256 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1257 "[.b, .w, .l, .q] address"
1259 "[.b, .w, .l] address"
1264 mw, 4, 1, do_mem_mw,
1265 "memory write (fill)",
1266 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1267 "[.b, .w, .l, .q] address value [count]"
1269 "[.b, .w, .l] address value [count]"
1274 cp, 4, 1, do_mem_cp,
1276 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1277 "[.b, .w, .l, .q] source target count"
1279 "[.b, .w, .l] source target count"
1284 cmp, 4, 1, do_mem_cmp,
1286 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1287 "[.b, .w, .l, .q] addr1 addr2 count"
1289 "[.b, .w, .l] addr1 addr2 count"
1293 #ifdef CONFIG_CMD_CRC32
1295 #ifndef CONFIG_CRC32_VERIFY
1298 crc32, 4, 1, do_mem_crc,
1299 "checksum calculation",
1300 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1303 #else /* CONFIG_CRC32_VERIFY */
1306 crc32, 5, 1, do_mem_crc,
1307 "checksum calculation",
1308 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1309 "-v address count crc\n - verify crc of memory area"
1312 #endif /* CONFIG_CRC32_VERIFY */
1316 #ifdef CONFIG_CMD_MEMINFO
1317 __weak void board_show_dram(ulong size)
1320 print_size(size, "\n");
1323 static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
1324 char * const argv[])
1326 board_show_dram(gd->ram_size);
1333 base, 2, 1, do_mem_base,
1334 "print or set address offset",
1335 "\n - print address offset for memory commands\n"
1336 "base off\n - set address offset for memory commands to 'off'"
1340 loop, 3, 1, do_mem_loop,
1341 "infinite loop on address range",
1342 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1343 "[.b, .w, .l, .q] address number_of_objects"
1345 "[.b, .w, .l] address number_of_objects"
1351 loopw, 4, 1, do_mem_loopw,
1352 "infinite write loop on address range",
1353 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1354 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1356 "[.b, .w, .l] address number_of_objects data_to_write"
1359 #endif /* CONFIG_LOOPW */
1361 #ifdef CONFIG_CMD_MEMTEST
1363 mtest, 5, 1, do_mem_mtest,
1364 "simple RAM read/write test",
1365 "[start [end [pattern [iterations]]]]"
1367 #endif /* CONFIG_CMD_MEMTEST */
1369 #ifdef CONFIG_MX_CYCLIC
1371 mdc, 4, 1, do_mem_mdc,
1372 "memory display cyclic",
1373 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1374 "[.b, .w, .l, .q] address count delay(ms)"
1376 "[.b, .w, .l] address count delay(ms)"
1381 mwc, 4, 1, do_mem_mwc,
1382 "memory write cyclic",
1383 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1384 "[.b, .w, .l, .q] address value delay(ms)"
1386 "[.b, .w, .l] address value delay(ms)"
1389 #endif /* CONFIG_MX_CYCLIC */
1391 #ifdef CONFIG_CMD_MEMINFO
1393 meminfo, 3, 1, do_mem_info,
1394 "display memory information",