3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
32 #ifdef CONFIG_HAS_DATAFLASH
33 #include <dataflash.h>
38 #include <linux/compiler.h>
40 DECLARE_GLOBAL_DATA_PTR
;
42 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
43 #define CONFIG_SYS_MEMTEST_SCRATCH 0
46 static int mod_mem(cmd_tbl_t
*, int, int, int, char * const []);
48 /* Display values from last command.
49 * Memory modify remembered values are different from display memory.
51 static uint dp_last_addr
, dp_last_size
;
52 static uint dp_last_length
= 0x40;
53 static uint mm_last_addr
, mm_last_size
;
55 static ulong base_address
= 0;
60 * md{.b, .w, .l} {addr} {len}
62 #define DISP_LINE_LEN 16
63 static int do_mem_md(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
66 #if defined(CONFIG_HAS_DATAFLASH)
67 ulong nbytes
, linebytes
;
72 /* We use the last specified parameters, unless new ones are
77 length
= dp_last_length
;
82 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
83 /* New command specified. Check for a size specification.
84 * Defaults to long if no or incorrect specification.
86 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
89 /* Address is specified since argc > 1
91 addr
= simple_strtoul(argv
[1], NULL
, 16);
94 /* If another parameter, it is the length to display.
95 * Length is the number of objects, not number of bytes.
98 length
= simple_strtoul(argv
[2], NULL
, 16);
101 #if defined(CONFIG_HAS_DATAFLASH)
104 * We buffer all read data, so we can make sure data is read only
105 * once, and all accesses are with the specified bus width.
107 nbytes
= length
* size
;
109 char linebuf
[DISP_LINE_LEN
];
111 linebytes
= (nbytes
>DISP_LINE_LEN
)?DISP_LINE_LEN
:nbytes
;
113 rc
= read_dataflash(addr
, (linebytes
/size
)*size
, linebuf
);
114 p
= (rc
== DATAFLASH_OK
) ? linebuf
: (void*)addr
;
115 print_buffer(addr
, p
, size
, linebytes
/size
, DISP_LINE_LEN
/size
);
123 } while (nbytes
> 0);
126 # if defined(CONFIG_BLACKFIN)
127 /* See if we're trying to display L1 inst */
128 if (addr_bfin_on_chip_mem(addr
)) {
129 char linebuf
[DISP_LINE_LEN
];
130 ulong linebytes
, nbytes
= length
* size
;
132 linebytes
= (nbytes
> DISP_LINE_LEN
) ? DISP_LINE_LEN
: nbytes
;
133 memcpy(linebuf
, (void *)addr
, linebytes
);
134 print_buffer(addr
, linebuf
, size
, linebytes
/size
, DISP_LINE_LEN
/size
);
142 } while (nbytes
> 0);
147 ulong bytes
= size
* length
;
148 const void *buf
= map_sysmem(addr
, bytes
);
150 /* Print the lines. */
151 print_buffer(addr
, buf
, size
, length
, DISP_LINE_LEN
/ size
);
158 dp_last_length
= length
;
163 static int do_mem_mm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
165 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
167 static int do_mem_nm(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
169 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
172 static int do_mem_mw(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
174 ulong addr
, writeval
, count
;
179 if ((argc
< 3) || (argc
> 4))
180 return CMD_RET_USAGE
;
182 /* Check for size specification.
184 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
187 /* Address is specified since argc > 1
189 addr
= simple_strtoul(argv
[1], NULL
, 16);
190 addr
+= base_address
;
192 /* Get the value to write.
194 writeval
= simple_strtoul(argv
[2], NULL
, 16);
198 count
= simple_strtoul(argv
[3], NULL
, 16);
203 bytes
= size
* count
;
204 buf
= map_sysmem(addr
, bytes
);
205 while (count
-- > 0) {
207 *((ulong
*)buf
) = (ulong
)writeval
;
209 *((ushort
*)buf
) = (ushort
)writeval
;
211 *((u_char
*)buf
) = (u_char
)writeval
;
218 #ifdef CONFIG_MX_CYCLIC
219 int do_mem_mdc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
225 return CMD_RET_USAGE
;
227 count
= simple_strtoul(argv
[3], NULL
, 10);
230 do_mem_md (NULL
, 0, 3, argv
);
232 /* delay for <count> ms... */
233 for (i
=0; i
<count
; i
++)
236 /* check for ctrl-c to abort... */
246 int do_mem_mwc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
252 return CMD_RET_USAGE
;
254 count
= simple_strtoul(argv
[3], NULL
, 10);
257 do_mem_mw (NULL
, 0, 3, argv
);
259 /* delay for <count> ms... */
260 for (i
=0; i
<count
; i
++)
263 /* check for ctrl-c to abort... */
272 #endif /* CONFIG_MX_CYCLIC */
274 static int do_mem_cmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
276 ulong addr1
, addr2
, count
, ngood
, bytes
;
280 const void *buf1
, *buf2
, *base
;
283 return CMD_RET_USAGE
;
285 /* Check for size specification.
287 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
289 type
= size
== 4 ? "word" : size
== 2 ? "halfword" : "byte";
291 addr1
= simple_strtoul(argv
[1], NULL
, 16);
292 addr1
+= base_address
;
294 addr2
= simple_strtoul(argv
[2], NULL
, 16);
295 addr2
+= base_address
;
297 count
= simple_strtoul(argv
[3], NULL
, 16);
299 #ifdef CONFIG_HAS_DATAFLASH
300 if (addr_dataflash(addr1
) | addr_dataflash(addr2
)){
301 puts ("Comparison with DataFlash space not supported.\n\r");
306 #ifdef CONFIG_BLACKFIN
307 if (addr_bfin_on_chip_mem(addr1
) || addr_bfin_on_chip_mem(addr2
)) {
308 puts ("Comparison with L1 instruction memory not supported.\n\r");
313 bytes
= size
* count
;
314 base
= buf1
= map_sysmem(addr1
, bytes
);
315 buf2
= map_sysmem(addr2
, bytes
);
316 for (ngood
= 0; ngood
< count
; ++ngood
) {
319 word1
= *(ulong
*)buf1
;
320 word2
= *(ulong
*)buf2
;
321 } else if (size
== 2) {
322 word1
= *(ushort
*)buf1
;
323 word2
= *(ushort
*)buf2
;
325 word1
= *(u_char
*)buf1
;
326 word2
= *(u_char
*)buf2
;
328 if (word1
!= word2
) {
329 ulong offset
= buf1
- base
;
331 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
332 type
, (ulong
)(addr1
+ offset
), size
, word1
,
333 type
, (ulong
)(addr2
+ offset
), size
, word2
);
341 /* reset watchdog from time to time */
342 if ((ngood
% (64 << 10)) == 0)
348 printf("Total of %ld %s(s) were the same\n", ngood
, type
);
352 static int do_mem_cp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
354 ulong addr
, dest
, count
, bytes
;
360 return CMD_RET_USAGE
;
362 /* Check for size specification.
364 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
367 addr
= simple_strtoul(argv
[1], NULL
, 16);
368 addr
+= base_address
;
370 dest
= simple_strtoul(argv
[2], NULL
, 16);
371 dest
+= base_address
;
373 count
= simple_strtoul(argv
[3], NULL
, 16);
376 puts ("Zero length ???\n");
380 #ifndef CONFIG_SYS_NO_FLASH
381 /* check if we are copying to Flash */
382 if ( (addr2info(dest
) != NULL
)
383 #ifdef CONFIG_HAS_DATAFLASH
384 && (!addr_dataflash(dest
))
389 puts ("Copy to Flash... ");
391 rc
= flash_write ((char *)addr
, dest
, count
*size
);
401 #ifdef CONFIG_HAS_DATAFLASH
402 /* Check if we are copying from RAM or Flash to DataFlash */
403 if (addr_dataflash(dest
) && !addr_dataflash(addr
)){
406 puts ("Copy to DataFlash... ");
408 rc
= write_dataflash (dest
, addr
, count
*size
);
411 dataflash_perror (rc
);
418 /* Check if we are copying from DataFlash to RAM */
419 if (addr_dataflash(addr
) && !addr_dataflash(dest
)
420 #ifndef CONFIG_SYS_NO_FLASH
421 && (addr2info(dest
) == NULL
)
425 rc
= read_dataflash(addr
, count
* size
, (char *) dest
);
427 dataflash_perror (rc
);
433 if (addr_dataflash(addr
) && addr_dataflash(dest
)){
434 puts ("Unsupported combination of source/destination.\n\r");
439 #ifdef CONFIG_BLACKFIN
440 /* See if we're copying to/from L1 inst */
441 if (addr_bfin_on_chip_mem(dest
) || addr_bfin_on_chip_mem(addr
)) {
442 memcpy((void *)dest
, (void *)addr
, count
* size
);
447 bytes
= size
* count
;
448 buf
= map_sysmem(dest
, bytes
);
449 src
= map_sysmem(addr
, bytes
);
450 while (count
-- > 0) {
452 *((ulong
*)buf
) = *((ulong
*)src
);
454 *((ushort
*)buf
) = *((ushort
*)src
);
456 *((u_char
*)buf
) = *((u_char
*)src
);
460 /* reset watchdog from time to time */
461 if ((count
% (64 << 10)) == 0)
467 static int do_mem_base(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
471 /* Set new base address.
473 base_address
= simple_strtoul(argv
[1], NULL
, 16);
475 /* Print the current base address.
477 printf("Base Address: 0x%08lx\n", base_address
);
481 static int do_mem_loop(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
484 ulong addr
, length
, i
, bytes
;
486 volatile uint
*longp
;
487 volatile ushort
*shortp
;
492 return CMD_RET_USAGE
;
495 * Check for a size specification.
496 * Defaults to long if no or incorrect specification.
498 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
501 /* Address is always specified.
503 addr
= simple_strtoul(argv
[1], NULL
, 16);
505 /* Length is the number of objects, not number of bytes.
507 length
= simple_strtoul(argv
[2], NULL
, 16);
509 bytes
= size
* length
;
510 buf
= map_sysmem(addr
, bytes
);
512 /* We want to optimize the loops to run as fast as possible.
513 * If we have only one object, just run infinite loops.
522 shortp
= (ushort
*)buf
;
541 shortp
= (ushort
*)buf
;
557 int do_mem_loopw (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
559 ulong addr
, length
, i
, data
, bytes
;
561 volatile uint
*longp
;
562 volatile ushort
*shortp
;
567 return CMD_RET_USAGE
;
570 * Check for a size specification.
571 * Defaults to long if no or incorrect specification.
573 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
576 /* Address is always specified.
578 addr
= simple_strtoul(argv
[1], NULL
, 16);
580 /* Length is the number of objects, not number of bytes.
582 length
= simple_strtoul(argv
[2], NULL
, 16);
585 data
= simple_strtoul(argv
[3], NULL
, 16);
587 bytes
= size
* length
;
588 buf
= map_sysmem(addr
, bytes
);
590 /* We want to optimize the loops to run as fast as possible.
591 * If we have only one object, just run infinite loops.
600 shortp
= (ushort
*)buf
;
619 shortp
= (ushort
*)buf
;
632 #endif /* CONFIG_LOOPW */
634 #ifdef CONFIG_CMD_MEMTEST
635 static ulong
mem_test_alt(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
646 vu_long anti_pattern
;
648 static const ulong bitpattern
[] = {
649 0x00000001, /* single bit */
650 0x00000003, /* two adjacent bits */
651 0x00000007, /* three adjacent bits */
652 0x0000000F, /* four adjacent bits */
653 0x00000005, /* two non-adjacent bits */
654 0x00000015, /* three non-adjacent bits */
655 0x00000055, /* four non-adjacent bits */
656 0xaaaaaaaa, /* alternating 1/0 */
659 num_words
= (end_addr
- start_addr
) / sizeof(vu_long
);
662 * Data line test: write a pattern to the first
663 * location, write the 1's complement to a 'parking'
664 * address (changes the state of the data bus so a
665 * floating bus doesn't give a false OK), and then
666 * read the value back. Note that we read it back
667 * into a variable because the next time we read it,
668 * it might be right (been there, tough to explain to
669 * the quality guys why it prints a failure when the
670 * "is" and "should be" are obviously the same in the
673 * Rather than exhaustively testing, we test some
674 * patterns by shifting '1' bits through a field of
675 * '0's and '0' bits through a field of '1's (i.e.
676 * pattern and ~pattern).
679 for (j
= 0; j
< sizeof(bitpattern
) / sizeof(bitpattern
[0]); j
++) {
681 for (; val
!= 0; val
<<= 1) {
683 *dummy
= ~val
; /* clear the test data off the bus */
685 if (readback
!= val
) {
686 printf("FAILURE (data line): "
687 "expected %08lx, actual %08lx\n",
696 if (readback
!= ~val
) {
697 printf("FAILURE (data line): "
698 "Is %08lx, should be %08lx\n",
708 * Based on code whose Original Author and Copyright
709 * information follows: Copyright (c) 1998 by Michael
710 * Barr. This software is placed into the public
711 * domain and may be used for any purpose. However,
712 * this notice must not be changed or removed and no
713 * warranty is either expressed or implied by its
714 * publication or distribution.
720 * Description: Test the address bus wiring in a
721 * memory region by performing a walking
722 * 1's test on the relevant bits of the
723 * address and checking for aliasing.
724 * This test will find single-bit
725 * address failures such as stuck-high,
726 * stuck-low, and shorted pins. The base
727 * address and size of the region are
728 * selected by the caller.
730 * Notes: For best results, the selected base
731 * address should have enough LSB 0's to
732 * guarantee single address bit changes.
733 * For example, to test a 64-Kbyte
734 * region, select a base address on a
735 * 64-Kbyte boundary. Also, select the
736 * region size as a power-of-two if at
739 * Returns: 0 if the test succeeds, 1 if the test fails.
741 pattern
= (vu_long
) 0xaaaaaaaa;
742 anti_pattern
= (vu_long
) 0x55555555;
744 debug("%s:%d: length = 0x%.8lx\n", __func__
, __LINE__
, num_words
);
746 * Write the default pattern at each of the
747 * power-of-two offsets.
749 for (offset
= 1; offset
< num_words
; offset
<<= 1)
750 addr
[offset
] = pattern
;
753 * Check for address bits stuck high.
756 addr
[test_offset
] = anti_pattern
;
758 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
760 if (temp
!= pattern
) {
761 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
762 " expected 0x%.8lx, actual 0x%.8lx\n",
763 start_addr
+ offset
, pattern
, temp
);
769 addr
[test_offset
] = pattern
;
773 * Check for addr bits stuck low or shorted.
775 for (test_offset
= 1; test_offset
< num_words
; test_offset
<<= 1) {
776 addr
[test_offset
] = anti_pattern
;
778 for (offset
= 1; offset
< num_words
; offset
<<= 1) {
780 if ((temp
!= pattern
) && (offset
!= test_offset
)) {
781 printf("\nFAILURE: Address bit stuck low or"
782 " shorted @ 0x%.8lx: expected 0x%.8lx,"
784 start_addr
+ offset
, pattern
, temp
);
790 addr
[test_offset
] = pattern
;
794 * Description: Test the integrity of a physical
795 * memory device by performing an
796 * increment/decrement test over the
797 * entire region. In the process every
798 * storage bit in the device is tested
799 * as a zero and a one. The base address
800 * and the size of the region are
801 * selected by the caller.
803 * Returns: 0 if the test succeeds, 1 if the test fails.
808 * Fill memory with a known pattern.
810 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
812 addr
[offset
] = pattern
;
816 * Check each location and invert it for the second pass.
818 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
821 if (temp
!= pattern
) {
822 printf("\nFAILURE (read/write) @ 0x%.8lx:"
823 " expected 0x%.8lx, actual 0x%.8lx)\n",
824 start_addr
+ offset
, pattern
, temp
);
830 anti_pattern
= ~pattern
;
831 addr
[offset
] = anti_pattern
;
835 * Check each location for the inverted pattern and zero it.
837 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
839 anti_pattern
= ~pattern
;
841 if (temp
!= anti_pattern
) {
842 printf("\nFAILURE (read/write): @ 0x%.8lx:"
843 " expected 0x%.8lx, actual 0x%.8lx)\n",
844 start_addr
+ offset
, anti_pattern
, temp
);
855 static ulong
mem_test_quick(vu_long
*buf
, ulong start_addr
, ulong end_addr
,
856 vu_long pattern
, int iteration
)
864 /* Alternate the pattern */
869 * Flip the pattern each time to make lots of zeros and
870 * then, the next time, lots of ones. We decrement
871 * the "negative" patterns and increment the "positive"
872 * patterns to preserve this feature.
874 if (pattern
& 0x80000000)
875 pattern
= -pattern
; /* complement & increment */
879 length
= (end_addr
- start_addr
) / sizeof(ulong
);
881 printf("\rPattern %08lX Writing..."
883 "\b\b\b\b\b\b\b\b\b\b",
886 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
894 for (addr
= buf
, val
= pattern
; addr
< end
; addr
++) {
897 if (readback
!= val
) {
898 ulong offset
= addr
- buf
;
900 printf("\nMem error @ 0x%08X: "
901 "found %08lX, expected %08lX\n",
902 (uint
)(uintptr_t)(start_addr
+ offset
),
915 * Perform a memory test. A more complete alternative test can be
916 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
917 * interrupted by ctrl-c or by a failure of one of the sub-tests.
919 static int do_mem_mtest(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
923 vu_long
*buf
, *dummy
;
926 ulong errs
= 0; /* number of errors, or -1 if interrupted */
929 #if defined(CONFIG_SYS_ALT_MEMTEST)
930 const int alt_test
= 1;
932 const int alt_test
= 0;
936 start
= simple_strtoul(argv
[1], NULL
, 16);
938 start
= CONFIG_SYS_MEMTEST_START
;
941 end
= simple_strtoul(argv
[2], NULL
, 16);
943 end
= CONFIG_SYS_MEMTEST_END
;
946 pattern
= (ulong
)simple_strtoul(argv
[3], NULL
, 16);
951 iteration_limit
= (ulong
)simple_strtoul(argv
[4], NULL
, 16);
955 printf("Testing %08x ... %08x:\n", (uint
)start
, (uint
)end
);
956 debug("%s:%d: start %#08lx end %#08lx\n", __func__
, __LINE__
,
959 buf
= map_sysmem(start
, end
- start
);
960 dummy
= map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH
, sizeof(vu_long
));
962 !iteration_limit
|| iteration
< iteration_limit
;
969 printf("Iteration: %6d\r", iteration
+ 1);
972 errs
= mem_test_alt(buf
, start
, end
, dummy
);
974 errs
= mem_test_quick(buf
, start
, end
, pattern
,
982 * Work-around for eldk-4.2 which gives this warning if we try to
983 * case in the unmap_sysmem() call:
984 * warning: initialization discards qualifiers from pointer target type
987 void *vbuf
= (void *)buf
;
988 void *vdummy
= (void *)dummy
;
991 unmap_sysmem(vdummy
);
995 /* Memory test was aborted - write a newline to finish off */
999 printf("Tested %d iteration(s) with %lu errors.\n",
1004 return ret
; /* not reached */
1006 #endif /* CONFIG_CMD_MEMTEST */
1011 * mm{.b, .w, .l} {addr}
1012 * nm{.b, .w, .l} {addr}
1015 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char * const argv
[])
1022 return CMD_RET_USAGE
;
1024 #ifdef CONFIG_BOOT_RETRY_TIME
1025 reset_cmd_timeout(); /* got a good command to get here */
1027 /* We use the last specified parameters, unless new ones are
1030 addr
= mm_last_addr
;
1031 size
= mm_last_size
;
1033 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
1034 /* New command specified. Check for a size specification.
1035 * Defaults to long if no or incorrect specification.
1037 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
1040 /* Address is specified since argc > 1
1042 addr
= simple_strtoul(argv
[1], NULL
, 16);
1043 addr
+= base_address
;
1046 #ifdef CONFIG_HAS_DATAFLASH
1047 if (addr_dataflash(addr
)){
1048 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1053 #ifdef CONFIG_BLACKFIN
1054 if (addr_bfin_on_chip_mem(addr
)) {
1055 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1060 /* Print the address, followed by value. Then accept input for
1061 * the next value. A non-converted value exits.
1064 ptr
= map_sysmem(addr
, size
);
1065 printf("%08lx:", addr
);
1067 printf(" %08x", *((uint
*)ptr
));
1069 printf(" %04x", *((ushort
*)ptr
));
1071 printf(" %02x", *((u_char
*)ptr
));
1073 nbytes
= readline (" ? ");
1074 if (nbytes
== 0 || (nbytes
== 1 && console_buffer
[0] == '-')) {
1075 /* <CR> pressed as only input, don't modify current
1076 * location and move to next. "-" pressed will go back.
1079 addr
+= nbytes
? -size
: size
;
1081 #ifdef CONFIG_BOOT_RETRY_TIME
1082 reset_cmd_timeout(); /* good enough to not time out */
1085 #ifdef CONFIG_BOOT_RETRY_TIME
1086 else if (nbytes
== -2) {
1087 break; /* timed out, exit the command */
1092 i
= simple_strtoul(console_buffer
, &endp
, 16);
1093 nbytes
= endp
- console_buffer
;
1095 #ifdef CONFIG_BOOT_RETRY_TIME
1096 /* good enough to not time out
1098 reset_cmd_timeout();
1103 *((ushort
*)ptr
) = i
;
1105 *((u_char
*)ptr
) = i
;
1114 mm_last_addr
= addr
;
1115 mm_last_size
= size
;
1119 #ifdef CONFIG_CMD_CRC32
1121 static int do_mem_crc(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
1128 return CMD_RET_USAGE
;
1132 #ifdef CONFIG_HASH_VERIFY
1133 if (strcmp(*av
, "-v") == 0) {
1134 flags
|= HASH_FLAG_VERIFY
;
1140 return hash_command("crc32", flags
, cmdtp
, flag
, ac
, av
);
1145 /**************************************************/
1147 md
, 3, 1, do_mem_md
,
1149 "[.b, .w, .l] address [# of objects]"
1154 mm
, 2, 1, do_mem_mm
,
1155 "memory modify (auto-incrementing address)",
1156 "[.b, .w, .l] address"
1161 nm
, 2, 1, do_mem_nm
,
1162 "memory modify (constant address)",
1163 "[.b, .w, .l] address"
1167 mw
, 4, 1, do_mem_mw
,
1168 "memory write (fill)",
1169 "[.b, .w, .l] address value [count]"
1173 cp
, 4, 1, do_mem_cp
,
1175 "[.b, .w, .l] source target count"
1179 cmp
, 4, 1, do_mem_cmp
,
1181 "[.b, .w, .l] addr1 addr2 count"
1184 #ifdef CONFIG_CMD_CRC32
1186 #ifndef CONFIG_CRC32_VERIFY
1189 crc32
, 4, 1, do_mem_crc
,
1190 "checksum calculation",
1191 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1194 #else /* CONFIG_CRC32_VERIFY */
1197 crc32
, 5, 1, do_mem_crc
,
1198 "checksum calculation",
1199 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1200 "-v address count crc\n - verify crc of memory area"
1203 #endif /* CONFIG_CRC32_VERIFY */
1207 #ifdef CONFIG_CMD_MEMINFO
1208 __weak
void board_show_dram(ulong size
)
1211 print_size(size
, "\n");
1214 static int do_mem_info(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
1215 char * const argv
[])
1217 board_show_dram(gd
->ram_size
);
1224 base
, 2, 1, do_mem_base
,
1225 "print or set address offset",
1226 "\n - print address offset for memory commands\n"
1227 "base off\n - set address offset for memory commands to 'off'"
1231 loop
, 3, 1, do_mem_loop
,
1232 "infinite loop on address range",
1233 "[.b, .w, .l] address number_of_objects"
1238 loopw
, 4, 1, do_mem_loopw
,
1239 "infinite write loop on address range",
1240 "[.b, .w, .l] address number_of_objects data_to_write"
1242 #endif /* CONFIG_LOOPW */
1244 #ifdef CONFIG_CMD_MEMTEST
1246 mtest
, 5, 1, do_mem_mtest
,
1247 "simple RAM read/write test",
1248 "[start [end [pattern [iterations]]]]"
1250 #endif /* CONFIG_CMD_MEMTEST */
1252 #ifdef CONFIG_MX_CYCLIC
1254 mdc
, 4, 1, do_mem_mdc
,
1255 "memory display cyclic",
1256 "[.b, .w, .l] address count delay(ms)"
1260 mwc
, 4, 1, do_mem_mwc
,
1261 "memory write cyclic",
1262 "[.b, .w, .l] address value delay(ms)"
1264 #endif /* CONFIG_MX_CYCLIC */
1266 #ifdef CONFIG_CMD_MEMINFO
1268 meminfo
, 3, 1, do_mem_info
,
1269 "display memory information",