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>
23 #include <linux/compiler.h>
25 DECLARE_GLOBAL_DATA_PTR
;
27 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
28 #define CONFIG_SYS_MEMTEST_SCRATCH 0
31 static int mod_mem(cmd_tbl_t
*, int, int, int, char * const []);
33 /* Display values from last command.
34 * Memory modify remembered values are different from display memory.
36 static ulong dp_last_addr
, dp_last_size
;
37 static ulong dp_last_length
= 0x40;
38 static ulong mm_last_addr
, mm_last_size
;
40 static ulong base_address
= 0;
45 * md{.b, .w, .l, .q} {addr} {len}
47 #define DISP_LINE_LEN 16
48 static int do_mem_md(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
50 ulong addr
, length
, bytes
;
55 /* We use the last specified parameters, unless new ones are
60 length
= dp_last_length
;
65 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
66 /* New command specified. Check for a size specification.
67 * Defaults to long if no or incorrect specification.
69 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
72 /* Address is specified since argc > 1
74 addr
= simple_strtoul(argv
[1], NULL
, 16);
77 /* If another parameter, it is the length to display.
78 * Length is the number of objects, not number of bytes.
81 length
= simple_strtoul(argv
[2], NULL
, 16);
84 bytes
= size
* length
;
85 buf
= map_sysmem(addr
, bytes
);
87 /* Print the lines. */
88 print_buffer(addr
, buf
, size
, length
, DISP_LINE_LEN
/ size
);
93 dp_last_length
= length
;
98 static int do_mem_mm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
100 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
102 static int do_mem_nm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
104 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
107 static int do_mem_mw(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
109 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
119 if ((argc
< 3) || (argc
> 4))
120 return CMD_RET_USAGE
;
122 /* Check for size specification.
124 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
127 /* Address is specified since argc > 1
129 addr
= simple_strtoul(argv
[1], NULL
, 16);
130 addr
+= base_address
;
132 /* Get the value to write.
134 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
135 writeval
= simple_strtoull(argv
[2], NULL
, 16);
137 writeval
= simple_strtoul(argv
[2], NULL
, 16);
142 count
= simple_strtoul(argv
[3], NULL
, 16);
147 bytes
= size
* count
;
148 start
= map_sysmem(addr
, bytes
);
150 while (count
-- > 0) {
152 *((u32
*)buf
) = (u32
)writeval
;
153 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
155 *((u64
*)buf
) = (u64
)writeval
;
158 *((u16
*)buf
) = (u16
)writeval
;
160 *((u8
*)buf
) = (u8
)writeval
;
167 #ifdef CONFIG_MX_CYCLIC
168 static int do_mem_mdc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
174 return CMD_RET_USAGE
;
176 count
= simple_strtoul(argv
[3], NULL
, 10);
179 do_mem_md (NULL
, 0, 3, argv
);
181 /* delay for <count> ms... */
182 for (i
=0; i
<count
; i
++)
185 /* check for ctrl-c to abort... */
195 static int do_mem_mwc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
201 return CMD_RET_USAGE
;
203 count
= simple_strtoul(argv
[3], NULL
, 10);
206 do_mem_mw (NULL
, 0, 3, argv
);
208 /* delay for <count> ms... */
209 for (i
=0; i
<count
; i
++)
212 /* check for ctrl-c to abort... */
221 #endif /* CONFIG_MX_CYCLIC */
223 static int do_mem_cmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
225 ulong addr1
, addr2
, count
, ngood
, bytes
;
229 const void *buf1
, *buf2
, *base
;
230 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
237 return CMD_RET_USAGE
;
239 /* Check for size specification.
241 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
243 type
= size
== 8 ? "double word" :
245 size
== 2 ? "halfword" : "byte";
247 addr1
= simple_strtoul(argv
[1], NULL
, 16);
248 addr1
+= base_address
;
250 addr2
= simple_strtoul(argv
[2], NULL
, 16);
251 addr2
+= base_address
;
253 count
= simple_strtoul(argv
[3], NULL
, 16);
255 bytes
= size
* count
;
256 base
= buf1
= map_sysmem(addr1
, bytes
);
257 buf2
= map_sysmem(addr2
, bytes
);
258 for (ngood
= 0; ngood
< count
; ++ngood
) {
260 word1
= *(u32
*)buf1
;
261 word2
= *(u32
*)buf2
;
262 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
263 } else if (size
== 8) {
264 word1
= *(u64
*)buf1
;
265 word2
= *(u64
*)buf2
;
267 } else if (size
== 2) {
268 word1
= *(u16
*)buf1
;
269 word2
= *(u16
*)buf2
;
274 if (word1
!= word2
) {
275 ulong offset
= buf1
- base
;
276 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
277 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
278 type
, (void *)(addr1
+ offset
), size
, word1
,
279 type
, (void *)(addr2
+ offset
), size
, word2
);
281 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
282 type
, (ulong
)(addr1
+ offset
), size
, word1
,
283 type
, (ulong
)(addr2
+ offset
), size
, word2
);
292 /* reset watchdog from time to time */
293 if ((ngood
% (64 << 10)) == 0)
299 printf("Total of %ld %s(s) were the same\n", ngood
, type
);
303 static int do_mem_cp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
305 ulong addr
, dest
, count
;
309 return CMD_RET_USAGE
;
311 /* Check for size specification.
313 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
316 addr
= simple_strtoul(argv
[1], NULL
, 16);
317 addr
+= base_address
;
319 dest
= simple_strtoul(argv
[2], NULL
, 16);
320 dest
+= base_address
;
322 count
= simple_strtoul(argv
[3], NULL
, 16);
325 puts ("Zero length ???\n");
329 #ifdef CONFIG_MTD_NOR_FLASH
330 /* check if we are copying to Flash */
331 if (addr2info(dest
) != NULL
) {
334 puts ("Copy to Flash... ");
336 rc
= flash_write ((char *)addr
, dest
, count
*size
);
346 memcpy((void *)dest
, (void *)addr
, count
* size
);
351 static int do_mem_base(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
355 /* Set new base address.
357 base_address
= simple_strtoul(argv
[1], NULL
, 16);
359 /* Print the current base address.
361 printf("Base Address: 0x%08lx\n", base_address
);
365 static int do_mem_loop(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
368 ulong addr
, length
, i
, bytes
;
370 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
374 volatile u16
*shortp
;
379 return CMD_RET_USAGE
;
382 * Check for a size specification.
383 * Defaults to long if no or incorrect specification.
385 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
388 /* Address is always specified.
390 addr
= simple_strtoul(argv
[1], NULL
, 16);
392 /* Length is the number of objects, not number of bytes.
394 length
= simple_strtoul(argv
[2], NULL
, 16);
396 bytes
= size
* length
;
397 buf
= map_sysmem(addr
, bytes
);
399 /* We want to optimize the loops to run as fast as possible.
400 * If we have only one object, just run infinite loops.
403 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
425 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
463 static int do_mem_loopw(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
466 ulong addr
, length
, i
, bytes
;
468 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
475 volatile u16
*shortp
;
480 return CMD_RET_USAGE
;
483 * Check for a size specification.
484 * Defaults to long if no or incorrect specification.
486 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
489 /* Address is always specified.
491 addr
= simple_strtoul(argv
[1], NULL
, 16);
493 /* Length is the number of objects, not number of bytes.
495 length
= simple_strtoul(argv
[2], NULL
, 16);
498 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
499 data
= simple_strtoull(argv
[3], NULL
, 16);
501 data
= simple_strtoul(argv
[3], NULL
, 16);
504 bytes
= size
* length
;
505 buf
= map_sysmem(addr
, bytes
);
507 /* We want to optimize the loops to run as fast as possible.
508 * If we have only one object, just run infinite loops.
511 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
533 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
566 #endif /* CONFIG_LOOPW */
568 #ifdef CONFIG_CMD_MEMTEST
569 static ulong
mem_test_alt(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
580 vu_long anti_pattern
;
582 static const ulong bitpattern
[] = {
583 0x00000001, /* single bit */
584 0x00000003, /* two adjacent bits */
585 0x00000007, /* three adjacent bits */
586 0x0000000F, /* four adjacent bits */
587 0x00000005, /* two non-adjacent bits */
588 0x00000015, /* three non-adjacent bits */
589 0x00000055, /* four non-adjacent bits */
590 0xaaaaaaaa, /* alternating 1/0 */
593 num_words
= (end_addr
- start_addr
) / sizeof(vu_long
);
596 * Data line test: write a pattern to the first
597 * location, write the 1's complement to a 'parking'
598 * address (changes the state of the data bus so a
599 * floating bus doesn't give a false OK), and then
600 * read the value back. Note that we read it back
601 * into a variable because the next time we read it,
602 * it might be right (been there, tough to explain to
603 * the quality guys why it prints a failure when the
604 * "is" and "should be" are obviously the same in the
607 * Rather than exhaustively testing, we test some
608 * patterns by shifting '1' bits through a field of
609 * '0's and '0' bits through a field of '1's (i.e.
610 * pattern and ~pattern).
613 for (j
= 0; j
< sizeof(bitpattern
) / sizeof(bitpattern
[0]); j
++) {
615 for (; val
!= 0; val
<<= 1) {
617 *dummy
= ~val
; /* clear the test data off the bus */
619 if (readback
!= val
) {
620 printf("FAILURE (data line): "
621 "expected %08lx, actual %08lx\n",
630 if (readback
!= ~val
) {
631 printf("FAILURE (data line): "
632 "Is %08lx, should be %08lx\n",
642 * Based on code whose Original Author and Copyright
643 * information follows: Copyright (c) 1998 by Michael
644 * Barr. This software is placed into the public
645 * domain and may be used for any purpose. However,
646 * this notice must not be changed or removed and no
647 * warranty is either expressed or implied by its
648 * publication or distribution.
654 * Description: Test the address bus wiring in a
655 * memory region by performing a walking
656 * 1's test on the relevant bits of the
657 * address and checking for aliasing.
658 * This test will find single-bit
659 * address failures such as stuck-high,
660 * stuck-low, and shorted pins. The base
661 * address and size of the region are
662 * selected by the caller.
664 * Notes: For best results, the selected base
665 * address should have enough LSB 0's to
666 * guarantee single address bit changes.
667 * For example, to test a 64-Kbyte
668 * region, select a base address on a
669 * 64-Kbyte boundary. Also, select the
670 * region size as a power-of-two if at
673 * Returns: 0 if the test succeeds, 1 if the test fails.
675 pattern
= (vu_long
) 0xaaaaaaaa;
676 anti_pattern
= (vu_long
) 0x55555555;
678 debug("%s:%d: length = 0x%.8lx\n", __func__
, __LINE__
, num_words
);
680 * Write the default pattern at each of the
681 * power-of-two offsets.
683 for (offset
= 1; offset
< num_words
; offset
<<= 1)
684 addr
[offset
] = pattern
;
687 * Check for address bits stuck high.
690 addr
[test_offset
] = anti_pattern
;
692 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
694 if (temp
!= pattern
) {
695 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
696 " expected 0x%.8lx, actual 0x%.8lx\n",
697 start_addr
+ offset
*sizeof(vu_long
),
704 addr
[test_offset
] = pattern
;
708 * Check for addr bits stuck low or shorted.
710 for (test_offset
= 1; test_offset
< num_words
; test_offset
<<= 1) {
711 addr
[test_offset
] = anti_pattern
;
713 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
715 if ((temp
!= pattern
) && (offset
!= test_offset
)) {
716 printf("\nFAILURE: Address bit stuck low or"
717 " shorted @ 0x%.8lx: expected 0x%.8lx,"
719 start_addr
+ offset
*sizeof(vu_long
),
726 addr
[test_offset
] = pattern
;
730 * Description: Test the integrity of a physical
731 * memory device by performing an
732 * increment/decrement test over the
733 * entire region. In the process every
734 * storage bit in the device is tested
735 * as a zero and a one. The base address
736 * and the size of the region are
737 * selected by the caller.
739 * Returns: 0 if the test succeeds, 1 if the test fails.
744 * Fill memory with a known pattern.
746 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
748 addr
[offset
] = pattern
;
752 * Check each location and invert it for the second pass.
754 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
757 if (temp
!= pattern
) {
758 printf("\nFAILURE (read/write) @ 0x%.8lx:"
759 " expected 0x%.8lx, actual 0x%.8lx)\n",
760 start_addr
+ offset
*sizeof(vu_long
),
767 anti_pattern
= ~pattern
;
768 addr
[offset
] = anti_pattern
;
772 * Check each location for the inverted pattern and zero it.
774 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
776 anti_pattern
= ~pattern
;
778 if (temp
!= anti_pattern
) {
779 printf("\nFAILURE (read/write): @ 0x%.8lx:"
780 " expected 0x%.8lx, actual 0x%.8lx)\n",
781 start_addr
+ offset
*sizeof(vu_long
),
793 static ulong
mem_test_quick(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
794 vu_long pattern
, int iteration
)
802 /* Alternate the pattern */
807 * Flip the pattern each time to make lots of zeros and
808 * then, the next time, lots of ones. We decrement
809 * the "negative" patterns and increment the "positive"
810 * patterns to preserve this feature.
812 if (pattern
& 0x80000000)
813 pattern
= -pattern
; /* complement & increment */
817 length
= (end_addr
- start_addr
) / sizeof(ulong
);
819 printf("\rPattern %08lX Writing..."
821 "\b\b\b\b\b\b\b\b\b\b",
824 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
832 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
835 if (readback
!= val
) {
836 ulong offset
= addr
- buf
;
838 printf("\nMem error @ 0x%08X: "
839 "found %08lX, expected %08lX\n",
840 (uint
)(uintptr_t)(start_addr
+ offset
*sizeof(vu_long
)),
853 * Perform a memory test. A more complete alternative test can be
854 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
855 * interrupted by ctrl-c or by a failure of one of the sub-tests.
857 static int do_mem_mtest(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
861 vu_long
*buf
, *dummy
;
862 ulong iteration_limit
= 0;
864 ulong errs
= 0; /* number of errors, or -1 if interrupted */
867 #if defined(CONFIG_SYS_ALT_MEMTEST)
868 const int alt_test
= 1;
870 const int alt_test
= 0;
873 start
= CONFIG_SYS_MEMTEST_START
;
874 end
= CONFIG_SYS_MEMTEST_END
;
877 if (strict_strtoul(argv
[1], 16, &start
) < 0)
878 return CMD_RET_USAGE
;
881 if (strict_strtoul(argv
[2], 16, &end
) < 0)
882 return CMD_RET_USAGE
;
885 if (strict_strtoul(argv
[3], 16, &pattern
) < 0)
886 return CMD_RET_USAGE
;
889 if (strict_strtoul(argv
[4], 16, &iteration_limit
) < 0)
890 return CMD_RET_USAGE
;
893 printf("Refusing to do empty test\n");
897 printf("Testing %08lx ... %08lx:\n", start
, end
);
898 debug("%s:%d: start %#08lx end %#08lx\n", __func__
, __LINE__
,
901 buf
= map_sysmem(start
, end
- start
);
902 dummy
= map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH
, sizeof(vu_long
));
904 !iteration_limit
|| iteration
< iteration_limit
;
911 printf("Iteration: %6d\r", iteration
+ 1);
914 errs
= mem_test_alt(buf
, start
, end
, dummy
);
916 errs
= mem_test_quick(buf
, start
, end
, pattern
,
924 * Work-around for eldk-4.2 which gives this warning if we try to
925 * case in the unmap_sysmem() call:
926 * warning: initialization discards qualifiers from pointer target type
929 void *vbuf
= (void *)buf
;
930 void *vdummy
= (void *)dummy
;
933 unmap_sysmem(vdummy
);
937 /* Memory test was aborted - write a newline to finish off */
941 printf("Tested %d iteration(s) with %lu errors.\n",
948 #endif /* CONFIG_CMD_MEMTEST */
953 * mm{.b, .w, .l, .q} {addr}
954 * nm{.b, .w, .l, .q} {addr}
957 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char * const argv
[])
960 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
969 return CMD_RET_USAGE
;
971 bootretry_reset_cmd_timeout(); /* got a good command to get here */
972 /* We use the last specified parameters, unless new ones are
978 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
979 /* New command specified. Check for a size specification.
980 * Defaults to long if no or incorrect specification.
982 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
985 /* Address is specified since argc > 1
987 addr
= simple_strtoul(argv
[1], NULL
, 16);
988 addr
+= base_address
;
991 /* Print the address, followed by value. Then accept input for
992 * the next value. A non-converted value exits.
995 ptr
= map_sysmem(addr
, size
);
996 printf("%08lx:", addr
);
998 printf(" %08x", *((u32
*)ptr
));
999 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1001 printf(" %016llx", *((u64
*)ptr
));
1004 printf(" %04x", *((u16
*)ptr
));
1006 printf(" %02x", *((u8
*)ptr
));
1008 nbytes
= cli_readline(" ? ");
1009 if (nbytes
== 0 || (nbytes
== 1 && console_buffer
[0] == '-')) {
1010 /* <CR> pressed as only input, don't modify current
1011 * location and move to next. "-" pressed will go back.
1014 addr
+= nbytes
? -size
: size
;
1016 /* good enough to not time out */
1017 bootretry_reset_cmd_timeout();
1019 #ifdef CONFIG_BOOT_RETRY_TIME
1020 else if (nbytes
== -2) {
1021 break; /* timed out, exit the command */
1026 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1027 i
= simple_strtoull(console_buffer
, &endp
, 16);
1029 i
= simple_strtoul(console_buffer
, &endp
, 16);
1031 nbytes
= endp
- console_buffer
;
1033 /* good enough to not time out
1035 bootretry_reset_cmd_timeout();
1038 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1054 mm_last_addr
= addr
;
1055 mm_last_size
= size
;
1059 #ifdef CONFIG_CMD_CRC32
1061 static int do_mem_crc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1068 return CMD_RET_USAGE
;
1072 #ifdef CONFIG_CRC32_VERIFY
1073 if (strcmp(*av
, "-v") == 0) {
1074 flags
|= HASH_FLAG_VERIFY
| HASH_FLAG_ENV
;
1080 return hash_command("crc32", flags
, cmdtp
, flag
, ac
, av
);
1085 /**************************************************/
1087 md
, 3, 1, do_mem_md
,
1089 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1090 "[.b, .w, .l, .q] address [# of objects]"
1092 "[.b, .w, .l] address [# of objects]"
1098 mm
, 2, 1, do_mem_mm
,
1099 "memory modify (auto-incrementing address)",
1100 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1101 "[.b, .w, .l, .q] address"
1103 "[.b, .w, .l] address"
1109 nm
, 2, 1, do_mem_nm
,
1110 "memory modify (constant address)",
1111 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1112 "[.b, .w, .l, .q] address"
1114 "[.b, .w, .l] address"
1119 mw
, 4, 1, do_mem_mw
,
1120 "memory write (fill)",
1121 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1122 "[.b, .w, .l, .q] address value [count]"
1124 "[.b, .w, .l] address value [count]"
1129 cp
, 4, 1, do_mem_cp
,
1131 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1132 "[.b, .w, .l, .q] source target count"
1134 "[.b, .w, .l] source target count"
1139 cmp
, 4, 1, do_mem_cmp
,
1141 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1142 "[.b, .w, .l, .q] addr1 addr2 count"
1144 "[.b, .w, .l] addr1 addr2 count"
1148 #ifdef CONFIG_CMD_CRC32
1150 #ifndef CONFIG_CRC32_VERIFY
1153 crc32
, 4, 1, do_mem_crc
,
1154 "checksum calculation",
1155 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1158 #else /* CONFIG_CRC32_VERIFY */
1161 crc32
, 5, 1, do_mem_crc
,
1162 "checksum calculation",
1163 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1164 "-v address count crc\n - verify crc of memory area"
1167 #endif /* CONFIG_CRC32_VERIFY */
1171 #ifdef CONFIG_CMD_MEMINFO
1172 __weak
void board_show_dram(phys_size_t size
)
1175 print_size(size
, "\n");
1178 static int do_mem_info(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
1179 char * const argv
[])
1181 board_show_dram(gd
->ram_size
);
1188 base
, 2, 1, do_mem_base
,
1189 "print or set address offset",
1190 "\n - print address offset for memory commands\n"
1191 "base off\n - set address offset for memory commands to 'off'"
1195 loop
, 3, 1, do_mem_loop
,
1196 "infinite loop on address range",
1197 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1198 "[.b, .w, .l, .q] address number_of_objects"
1200 "[.b, .w, .l] address number_of_objects"
1206 loopw
, 4, 1, do_mem_loopw
,
1207 "infinite write loop on address range",
1208 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1209 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1211 "[.b, .w, .l] address number_of_objects data_to_write"
1214 #endif /* CONFIG_LOOPW */
1216 #ifdef CONFIG_CMD_MEMTEST
1218 mtest
, 5, 1, do_mem_mtest
,
1219 "simple RAM read/write test",
1220 "[start [end [pattern [iterations]]]]"
1222 #endif /* CONFIG_CMD_MEMTEST */
1224 #ifdef CONFIG_MX_CYCLIC
1226 mdc
, 4, 1, do_mem_mdc
,
1227 "memory display cyclic",
1228 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1229 "[.b, .w, .l, .q] address count delay(ms)"
1231 "[.b, .w, .l] address count delay(ms)"
1236 mwc
, 4, 1, do_mem_mwc
,
1237 "memory write cyclic",
1238 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
1239 "[.b, .w, .l, .q] address value delay(ms)"
1241 "[.b, .w, .l] address value delay(ms)"
1244 #endif /* CONFIG_MX_CYCLIC */
1246 #ifdef CONFIG_CMD_MEMINFO
1248 meminfo
, 3, 1, do_mem_info
,
1249 "display memory information",