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>
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(cmd_tbl_t *, int, int, int, char * const []);
36 /* Display values from last command.
37 * Memory modify remembered values are different from display memory.
39 static uint dp_last_addr, dp_last_size;
40 static uint dp_last_length = 0x40;
41 static uint 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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
54 #if defined(CONFIG_HAS_DATAFLASH)
55 ulong nbytes, linebytes;
60 /* We use the last specified parameters, unless new ones are
65 length = dp_last_length;
70 if ((flag & CMD_FLAG_REPEAT) == 0) {
71 /* New command specified. Check for a size specification.
72 * Defaults to long if no or incorrect specification.
74 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
77 /* Address is specified since argc > 1
79 addr = simple_strtoul(argv[1], NULL, 16);
82 /* If another parameter, it is the length to display.
83 * Length is the number of objects, not number of bytes.
86 length = simple_strtoul(argv[2], NULL, 16);
89 #if defined(CONFIG_HAS_DATAFLASH)
92 * We buffer all read data, so we can make sure data is read only
93 * once, and all accesses are with the specified bus width.
95 nbytes = length * size;
97 char linebuf[DISP_LINE_LEN];
99 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
101 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
102 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
103 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
111 } while (nbytes > 0);
114 # if defined(CONFIG_BLACKFIN)
115 /* See if we're trying to display L1 inst */
116 if (addr_bfin_on_chip_mem(addr)) {
117 char linebuf[DISP_LINE_LEN];
118 ulong linebytes, nbytes = length * size;
120 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
121 memcpy(linebuf, (void *)addr, linebytes);
122 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
130 } while (nbytes > 0);
135 ulong bytes = size * length;
136 const void *buf = map_sysmem(addr, bytes);
138 /* Print the lines. */
139 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
146 dp_last_length = length;
151 static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
153 return mod_mem (cmdtp, 1, flag, argc, argv);
155 static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
157 return mod_mem (cmdtp, 0, flag, argc, argv);
160 static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
162 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
172 if ((argc < 3) || (argc > 4))
173 return CMD_RET_USAGE;
175 /* Check for size specification.
177 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
180 /* Address is specified since argc > 1
182 addr = simple_strtoul(argv[1], NULL, 16);
183 addr += base_address;
185 /* Get the value to write.
187 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
188 writeval = simple_strtoull(argv[2], NULL, 16);
190 writeval = simple_strtoul(argv[2], NULL, 16);
195 count = simple_strtoul(argv[3], NULL, 16);
200 bytes = size * count;
201 start = map_sysmem(addr, bytes);
203 while (count-- > 0) {
205 *((u32 *)buf) = (u32)writeval;
206 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
208 *((u64 *)buf) = (u64)writeval;
211 *((u16 *)buf) = (u16)writeval;
213 *((u8 *)buf) = (u8)writeval;
220 #ifdef CONFIG_MX_CYCLIC
221 static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
227 return CMD_RET_USAGE;
229 count = simple_strtoul(argv[3], NULL, 10);
232 do_mem_md (NULL, 0, 3, argv);
234 /* delay for <count> ms... */
235 for (i=0; i<count; i++)
238 /* check for ctrl-c to abort... */
248 static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
254 return CMD_RET_USAGE;
256 count = simple_strtoul(argv[3], NULL, 10);
259 do_mem_mw (NULL, 0, 3, argv);
261 /* delay for <count> ms... */
262 for (i=0; i<count; i++)
265 /* check for ctrl-c to abort... */
274 #endif /* CONFIG_MX_CYCLIC */
276 static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
278 ulong addr1, addr2, count, ngood, bytes;
282 const void *buf1, *buf2, *base;
283 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
290 return CMD_RET_USAGE;
292 /* Check for size specification.
294 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
296 type = size == 8 ? "double word" :
298 size == 2 ? "halfword" : "byte";
300 addr1 = simple_strtoul(argv[1], NULL, 16);
301 addr1 += base_address;
303 addr2 = simple_strtoul(argv[2], NULL, 16);
304 addr2 += base_address;
306 count = simple_strtoul(argv[3], NULL, 16);
308 #ifdef CONFIG_HAS_DATAFLASH
309 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
310 puts ("Comparison with DataFlash space not supported.\n\r");
315 #ifdef CONFIG_BLACKFIN
316 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
317 puts ("Comparison with L1 instruction memory not supported.\n\r");
322 bytes = size * count;
323 base = buf1 = map_sysmem(addr1, bytes);
324 buf2 = map_sysmem(addr2, bytes);
325 for (ngood = 0; ngood < count; ++ngood) {
327 word1 = *(u32 *)buf1;
328 word2 = *(u32 *)buf2;
329 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
330 } else if (size == 8) {
331 word1 = *(u64 *)buf1;
332 word2 = *(u64 *)buf2;
334 } else if (size == 2) {
335 word1 = *(u16 *)buf1;
336 word2 = *(u16 *)buf2;
341 if (word1 != word2) {
342 ulong offset = buf1 - base;
343 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
344 printf("%s at 0x%p (%#0*"PRIx64") != %s at 0x%p (%#0*"
346 type, (void *)(addr1 + offset), size, word1,
347 type, (void *)(addr2 + offset), size, word2);
349 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
350 type, (ulong)(addr1 + offset), size, word1,
351 type, (ulong)(addr2 + offset), size, word2);
360 /* reset watchdog from time to time */
361 if ((ngood % (64 << 10)) == 0)
367 printf("Total of %ld %s(s) were the same\n", ngood, type);
371 static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
373 ulong addr, dest, count, bytes;
379 return CMD_RET_USAGE;
381 /* Check for size specification.
383 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
386 addr = simple_strtoul(argv[1], NULL, 16);
387 addr += base_address;
389 dest = simple_strtoul(argv[2], NULL, 16);
390 dest += base_address;
392 count = simple_strtoul(argv[3], NULL, 16);
395 puts ("Zero length ???\n");
399 #ifndef CONFIG_SYS_NO_FLASH
400 /* check if we are copying to Flash */
401 if ( (addr2info(dest) != NULL)
402 #ifdef CONFIG_HAS_DATAFLASH
403 && (!addr_dataflash(dest))
408 puts ("Copy to Flash... ");
410 rc = flash_write ((char *)addr, dest, count*size);
420 #ifdef CONFIG_HAS_DATAFLASH
421 /* Check if we are copying from RAM or Flash to DataFlash */
422 if (addr_dataflash(dest) && !addr_dataflash(addr)){
425 puts ("Copy to DataFlash... ");
427 rc = write_dataflash (dest, addr, count*size);
430 dataflash_perror (rc);
437 /* Check if we are copying from DataFlash to RAM */
438 if (addr_dataflash(addr) && !addr_dataflash(dest)
439 #ifndef CONFIG_SYS_NO_FLASH
440 && (addr2info(dest) == NULL)
444 rc = read_dataflash(addr, count * size, (char *) dest);
446 dataflash_perror (rc);
452 if (addr_dataflash(addr) && addr_dataflash(dest)){
453 puts ("Unsupported combination of source/destination.\n\r");
458 #ifdef CONFIG_BLACKFIN
459 /* See if we're copying to/from L1 inst */
460 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
461 memcpy((void *)dest, (void *)addr, count * size);
466 bytes = size * count;
467 buf = map_sysmem(dest, bytes);
468 src = map_sysmem(addr, bytes);
469 while (count-- > 0) {
471 *((u32 *)buf) = *((u32 *)src);
472 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
474 *((u64 *)buf) = *((u64 *)src);
477 *((u16 *)buf) = *((u16 *)src);
479 *((u8 *)buf) = *((u8 *)src);
483 /* reset watchdog from time to time */
484 if ((count % (64 << 10)) == 0)
493 static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
497 /* Set new base address.
499 base_address = simple_strtoul(argv[1], NULL, 16);
501 /* Print the current base address.
503 printf("Base Address: 0x%08lx\n", base_address);
507 static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
510 ulong addr, length, i, bytes;
512 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
516 volatile u16 *shortp;
521 return CMD_RET_USAGE;
524 * Check for a size specification.
525 * Defaults to long if no or incorrect specification.
527 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
530 /* Address is always specified.
532 addr = simple_strtoul(argv[1], NULL, 16);
534 /* Length is the number of objects, not number of bytes.
536 length = simple_strtoul(argv[2], NULL, 16);
538 bytes = size * length;
539 buf = map_sysmem(addr, bytes);
541 /* We want to optimize the loops to run as fast as possible.
542 * If we have only one object, just run infinite loops.
545 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
567 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
605 static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc,
608 ulong addr, length, i, bytes;
610 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
617 volatile u16 *shortp;
622 return CMD_RET_USAGE;
625 * Check for a size specification.
626 * Defaults to long if no or incorrect specification.
628 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
631 /* Address is always specified.
633 addr = simple_strtoul(argv[1], NULL, 16);
635 /* Length is the number of objects, not number of bytes.
637 length = simple_strtoul(argv[2], NULL, 16);
640 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
641 data = simple_strtoull(argv[3], NULL, 16);
643 data = simple_strtoul(argv[3], NULL, 16);
646 bytes = size * length;
647 buf = map_sysmem(addr, bytes);
649 /* We want to optimize the loops to run as fast as possible.
650 * If we have only one object, just run infinite loops.
653 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
675 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
708 #endif /* CONFIG_LOOPW */
710 #ifdef CONFIG_CMD_MEMTEST
711 static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
722 vu_long anti_pattern;
724 static const ulong bitpattern[] = {
725 0x00000001, /* single bit */
726 0x00000003, /* two adjacent bits */
727 0x00000007, /* three adjacent bits */
728 0x0000000F, /* four adjacent bits */
729 0x00000005, /* two non-adjacent bits */
730 0x00000015, /* three non-adjacent bits */
731 0x00000055, /* four non-adjacent bits */
732 0xaaaaaaaa, /* alternating 1/0 */
735 num_words = (end_addr - start_addr) / sizeof(vu_long);
738 * Data line test: write a pattern to the first
739 * location, write the 1's complement to a 'parking'
740 * address (changes the state of the data bus so a
741 * floating bus doesn't give a false OK), and then
742 * read the value back. Note that we read it back
743 * into a variable because the next time we read it,
744 * it might be right (been there, tough to explain to
745 * the quality guys why it prints a failure when the
746 * "is" and "should be" are obviously the same in the
749 * Rather than exhaustively testing, we test some
750 * patterns by shifting '1' bits through a field of
751 * '0's and '0' bits through a field of '1's (i.e.
752 * pattern and ~pattern).
755 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
757 for (; val != 0; val <<= 1) {
759 *dummy = ~val; /* clear the test data off the bus */
761 if (readback != val) {
762 printf("FAILURE (data line): "
763 "expected %08lx, actual %08lx\n",
772 if (readback != ~val) {
773 printf("FAILURE (data line): "
774 "Is %08lx, should be %08lx\n",
784 * Based on code whose Original Author and Copyright
785 * information follows: Copyright (c) 1998 by Michael
786 * Barr. This software is placed into the public
787 * domain and may be used for any purpose. However,
788 * this notice must not be changed or removed and no
789 * warranty is either expressed or implied by its
790 * publication or distribution.
796 * Description: Test the address bus wiring in a
797 * memory region by performing a walking
798 * 1's test on the relevant bits of the
799 * address and checking for aliasing.
800 * This test will find single-bit
801 * address failures such as stuck-high,
802 * stuck-low, and shorted pins. The base
803 * address and size of the region are
804 * selected by the caller.
806 * Notes: For best results, the selected base
807 * address should have enough LSB 0's to
808 * guarantee single address bit changes.
809 * For example, to test a 64-Kbyte
810 * region, select a base address on a
811 * 64-Kbyte boundary. Also, select the
812 * region size as a power-of-two if at
815 * Returns: 0 if the test succeeds, 1 if the test fails.
817 pattern = (vu_long) 0xaaaaaaaa;
818 anti_pattern = (vu_long) 0x55555555;
820 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
822 * Write the default pattern at each of the
823 * power-of-two offsets.
825 for (offset = 1; offset < num_words; offset <<= 1)
826 addr[offset] = pattern;
829 * Check for address bits stuck high.
832 addr[test_offset] = anti_pattern;
834 for (offset = 1; offset < num_words; offset <<= 1) {
836 if (temp != pattern) {
837 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
838 " expected 0x%.8lx, actual 0x%.8lx\n",
839 start_addr + offset*sizeof(vu_long),
846 addr[test_offset] = pattern;
850 * Check for addr bits stuck low or shorted.
852 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
853 addr[test_offset] = anti_pattern;
855 for (offset = 1; offset < num_words; offset <<= 1) {
857 if ((temp != pattern) && (offset != test_offset)) {
858 printf("\nFAILURE: Address bit stuck low or"
859 " shorted @ 0x%.8lx: expected 0x%.8lx,"
861 start_addr + offset*sizeof(vu_long),
868 addr[test_offset] = pattern;
872 * Description: Test the integrity of a physical
873 * memory device by performing an
874 * increment/decrement test over the
875 * entire region. In the process every
876 * storage bit in the device is tested
877 * as a zero and a one. The base address
878 * and the size of the region are
879 * selected by the caller.
881 * Returns: 0 if the test succeeds, 1 if the test fails.
886 * Fill memory with a known pattern.
888 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
890 addr[offset] = pattern;
894 * Check each location and invert it for the second pass.
896 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
899 if (temp != pattern) {
900 printf("\nFAILURE (read/write) @ 0x%.8lx:"
901 " expected 0x%.8lx, actual 0x%.8lx)\n",
902 start_addr + offset*sizeof(vu_long),
909 anti_pattern = ~pattern;
910 addr[offset] = anti_pattern;
914 * Check each location for the inverted pattern and zero it.
916 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
918 anti_pattern = ~pattern;
920 if (temp != anti_pattern) {
921 printf("\nFAILURE (read/write): @ 0x%.8lx:"
922 " expected 0x%.8lx, actual 0x%.8lx)\n",
923 start_addr + offset*sizeof(vu_long),
935 static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
936 vu_long pattern, int iteration)
944 /* Alternate the pattern */
949 * Flip the pattern each time to make lots of zeros and
950 * then, the next time, lots of ones. We decrement
951 * the "negative" patterns and increment the "positive"
952 * patterns to preserve this feature.
954 if (pattern & 0x80000000)
955 pattern = -pattern; /* complement & increment */
959 length = (end_addr - start_addr) / sizeof(ulong);
961 printf("\rPattern %08lX Writing..."
963 "\b\b\b\b\b\b\b\b\b\b",
966 for (addr = buf, val = pattern; addr < end; addr++) {
974 for (addr = buf, val = pattern; addr < end; addr++) {
977 if (readback != val) {
978 ulong offset = addr - buf;
980 printf("\nMem error @ 0x%08X: "
981 "found %08lX, expected %08lX\n",
982 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
995 * Perform a memory test. A more complete alternative test can be
996 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
997 * interrupted by ctrl-c or by a failure of one of the sub-tests.
999 static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
1000 char * const argv[])
1003 vu_long *buf, *dummy;
1004 ulong iteration_limit = 0;
1006 ulong errs = 0; /* number of errors, or -1 if interrupted */
1009 #if defined(CONFIG_SYS_ALT_MEMTEST)
1010 const int alt_test = 1;
1012 const int alt_test = 0;
1015 start = CONFIG_SYS_MEMTEST_START;
1016 end = CONFIG_SYS_MEMTEST_END;
1019 if (strict_strtoul(argv[1], 16, &start) < 0)
1020 return CMD_RET_USAGE;
1023 if (strict_strtoul(argv[2], 16, &end) < 0)
1024 return CMD_RET_USAGE;
1027 if (strict_strtoul(argv[3], 16, &pattern) < 0)
1028 return CMD_RET_USAGE;
1031 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
1032 return CMD_RET_USAGE;
1035 printf("Refusing to do empty test\n");
1039 printf("Testing %08x ... %08x:\n", (uint)start, (uint)end);
1040 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
1043 buf = map_sysmem(start, end - start);
1044 dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
1046 !iteration_limit || iteration < iteration_limit;
1053 printf("Iteration: %6d\r", iteration + 1);
1056 errs = mem_test_alt(buf, start, end, dummy);
1058 errs = mem_test_quick(buf, start, end, pattern,
1066 * Work-around for eldk-4.2 which gives this warning if we try to
1067 * case in the unmap_sysmem() call:
1068 * warning: initialization discards qualifiers from pointer target type
1071 void *vbuf = (void *)buf;
1072 void *vdummy = (void *)dummy;
1075 unmap_sysmem(vdummy);
1079 /* Memory test was aborted - write a newline to finish off */
1083 printf("Tested %d iteration(s) with %lu errors.\n",
1090 #endif /* CONFIG_CMD_MEMTEST */
1095 * mm{.b, .w, .l, .q} {addr}
1096 * nm{.b, .w, .l, .q} {addr}
1099 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
1102 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1111 return CMD_RET_USAGE;
1113 bootretry_reset_cmd_timeout(); /* got a good command to get here */
1114 /* We use the last specified parameters, unless new ones are
1117 addr = mm_last_addr;
1118 size = mm_last_size;
1120 if ((flag & CMD_FLAG_REPEAT) == 0) {
1121 /* New command specified. Check for a size specification.
1122 * Defaults to long if no or incorrect specification.
1124 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1127 /* Address is specified since argc > 1
1129 addr = simple_strtoul(argv[1], NULL, 16);
1130 addr += base_address;
1133 #ifdef CONFIG_HAS_DATAFLASH
1134 if (addr_dataflash(addr)){
1135 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1140 #ifdef CONFIG_BLACKFIN
1141 if (addr_bfin_on_chip_mem(addr)) {
1142 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1147 /* Print the address, followed by value. Then accept input for
1148 * the next value. A non-converted value exits.
1151 ptr = map_sysmem(addr, size);
1152 printf("%08lx:", addr);
1154 printf(" %08x", *((u32 *)ptr));
1155 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1157 printf(" %016" PRIx64, *((u64 *)ptr));
1160 printf(" %04x", *((u16 *)ptr));
1162 printf(" %02x", *((u8 *)ptr));
1164 nbytes = cli_readline(" ? ");
1165 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1166 /* <CR> pressed as only input, don't modify current
1167 * location and move to next. "-" pressed will go back.
1170 addr += nbytes ? -size : size;
1172 /* good enough to not time out */
1173 bootretry_reset_cmd_timeout();
1175 #ifdef CONFIG_BOOT_RETRY_TIME
1176 else if (nbytes == -2) {
1177 break; /* timed out, exit the command */
1182 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1183 i = simple_strtoull(console_buffer, &endp, 16);
1185 i = simple_strtoul(console_buffer, &endp, 16);
1187 nbytes = endp - console_buffer;
1189 /* good enough to not time out
1191 bootretry_reset_cmd_timeout();
1194 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1210 mm_last_addr = addr;
1211 mm_last_size = size;
1215 #ifdef CONFIG_CMD_CRC32
1217 static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1224 return CMD_RET_USAGE;
1228 #ifdef CONFIG_HASH_VERIFY
1229 if (strcmp(*av, "-v") == 0) {
1230 flags |= HASH_FLAG_VERIFY;
1236 return hash_command("crc32", flags, cmdtp, flag, ac, av);
1241 /**************************************************/
1243 md, 3, 1, do_mem_md,
1245 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1246 "[.b, .w, .l, .q] address [# of objects]"
1248 "[.b, .w, .l] address [# of objects]"
1254 mm, 2, 1, do_mem_mm,
1255 "memory modify (auto-incrementing address)",
1256 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1257 "[.b, .w, .l, .q] address"
1259 "[.b, .w, .l] address"
1265 nm, 2, 1, do_mem_nm,
1266 "memory modify (constant address)",
1267 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1268 "[.b, .w, .l, .q] address"
1270 "[.b, .w, .l] address"
1275 mw, 4, 1, do_mem_mw,
1276 "memory write (fill)",
1277 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1278 "[.b, .w, .l, .q] address value [count]"
1280 "[.b, .w, .l] address value [count]"
1285 cp, 4, 1, do_mem_cp,
1287 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1288 "[.b, .w, .l, .q] source target count"
1290 "[.b, .w, .l] source target count"
1295 cmp, 4, 1, do_mem_cmp,
1297 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1298 "[.b, .w, .l, .q] addr1 addr2 count"
1300 "[.b, .w, .l] addr1 addr2 count"
1304 #ifdef CONFIG_CMD_CRC32
1306 #ifndef CONFIG_CRC32_VERIFY
1309 crc32, 4, 1, do_mem_crc,
1310 "checksum calculation",
1311 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1314 #else /* CONFIG_CRC32_VERIFY */
1317 crc32, 5, 1, do_mem_crc,
1318 "checksum calculation",
1319 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1320 "-v address count crc\n - verify crc of memory area"
1323 #endif /* CONFIG_CRC32_VERIFY */
1327 #ifdef CONFIG_CMD_MEMINFO
1328 __weak void board_show_dram(ulong size)
1331 print_size(size, "\n");
1334 static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
1335 char * const argv[])
1337 board_show_dram(gd->ram_size);
1344 base, 2, 1, do_mem_base,
1345 "print or set address offset",
1346 "\n - print address offset for memory commands\n"
1347 "base off\n - set address offset for memory commands to 'off'"
1351 loop, 3, 1, do_mem_loop,
1352 "infinite loop on address range",
1353 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1354 "[.b, .w, .l, .q] address number_of_objects"
1356 "[.b, .w, .l] address number_of_objects"
1362 loopw, 4, 1, do_mem_loopw,
1363 "infinite write loop on address range",
1364 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1365 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1367 "[.b, .w, .l] address number_of_objects data_to_write"
1370 #endif /* CONFIG_LOOPW */
1372 #ifdef CONFIG_CMD_MEMTEST
1374 mtest, 5, 1, do_mem_mtest,
1375 "simple RAM read/write test",
1376 "[start [end [pattern [iterations]]]]"
1378 #endif /* CONFIG_CMD_MEMTEST */
1380 #ifdef CONFIG_MX_CYCLIC
1382 mdc, 4, 1, do_mem_mdc,
1383 "memory display cyclic",
1384 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1385 "[.b, .w, .l, .q] address count delay(ms)"
1387 "[.b, .w, .l] address count delay(ms)"
1392 mwc, 4, 1, do_mem_mwc,
1393 "memory write cyclic",
1394 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1395 "[.b, .w, .l, .q] address value delay(ms)"
1397 "[.b, .w, .l] address value delay(ms)"
1400 #endif /* CONFIG_MX_CYCLIC */
1402 #ifdef CONFIG_CMD_MEMINFO
1404 meminfo, 3, 1, do_mem_info,
1405 "display memory information",