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 #if defined(CONFIG_CMD_MMC)
35 #ifdef CONFIG_HAS_DATAFLASH
36 #include <dataflash.h>
39 #if defined(CONFIG_CMD_MEMORY) \
40 || defined(CONFIG_CMD_I2C) \
41 || defined(CONFIG_CMD_ITEST) \
42 || defined(CONFIG_CMD_PCI) \
43 || defined(CONFIG_CMD_PORTIO)
45 int cmd_get_data_size(char* arg, int default_size)
47 /* Check for a size specification .b, .w or .l.
49 int len = strlen(arg);
50 if (len > 2 && arg[len-2] == '.') {
68 #if defined(CONFIG_CMD_MEMORY)
71 #define PRINTF(fmt,args...) printf (fmt ,##args)
73 #define PRINTF(fmt,args...)
76 static int mod_mem(cmd_tbl_t *, int, int, int, char *[]);
78 /* Display values from last command.
79 * Memory modify remembered values are different from display memory.
81 uint dp_last_addr, dp_last_size;
82 uint dp_last_length = 0x40;
83 uint mm_last_addr, mm_last_size;
85 static ulong base_address = 0;
90 * md{.b, .w, .l} {addr} {len}
92 #define DISP_LINE_LEN 16
93 int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
96 #if defined(CONFIG_HAS_DATAFLASH)
97 ulong nbytes, linebytes;
102 /* We use the last specified parameters, unless new ones are
107 length = dp_last_length;
110 printf ("Usage:\n%s\n", cmdtp->usage);
114 if ((flag & CMD_FLAG_REPEAT) == 0) {
115 /* New command specified. Check for a size specification.
116 * Defaults to long if no or incorrect specification.
118 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
121 /* Address is specified since argc > 1
123 addr = simple_strtoul(argv[1], NULL, 16);
124 addr += base_address;
126 /* If another parameter, it is the length to display.
127 * Length is the number of objects, not number of bytes.
130 length = simple_strtoul(argv[2], NULL, 16);
133 #if defined(CONFIG_HAS_DATAFLASH)
136 * We buffer all read data, so we can make sure data is read only
137 * once, and all accesses are with the specified bus width.
139 nbytes = length * size;
141 char linebuf[DISP_LINE_LEN];
143 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
145 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
146 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
147 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
155 } while (nbytes > 0);
158 # if defined(CONFIG_BLACKFIN)
159 /* See if we're trying to display L1 inst */
160 if (addr_bfin_on_chip_mem(addr)) {
161 char linebuf[DISP_LINE_LEN];
162 ulong linebytes, nbytes = length * size;
164 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
165 memcpy(linebuf, (void *)addr, linebytes);
166 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
174 } while (nbytes > 0);
179 /* Print the lines. */
180 print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
186 dp_last_length = length;
191 int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
193 return mod_mem (cmdtp, 1, flag, argc, argv);
195 int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
197 return mod_mem (cmdtp, 0, flag, argc, argv);
200 int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
202 ulong addr, writeval, count;
205 if ((argc < 3) || (argc > 4)) {
206 printf ("Usage:\n%s\n", cmdtp->usage);
210 /* Check for size specification.
212 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
215 /* Address is specified since argc > 1
217 addr = simple_strtoul(argv[1], NULL, 16);
218 addr += base_address;
220 /* Get the value to write.
222 writeval = simple_strtoul(argv[2], NULL, 16);
226 count = simple_strtoul(argv[3], NULL, 16);
231 while (count-- > 0) {
233 *((ulong *)addr) = (ulong )writeval;
235 *((ushort *)addr) = (ushort)writeval;
237 *((u_char *)addr) = (u_char)writeval;
243 #ifdef CONFIG_MX_CYCLIC
244 int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
250 printf ("Usage:\n%s\n", cmdtp->usage);
254 count = simple_strtoul(argv[3], NULL, 10);
257 do_mem_md (NULL, 0, 3, argv);
259 /* delay for <count> ms... */
260 for (i=0; i<count; i++)
263 /* check for ctrl-c to abort... */
273 int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
279 printf ("Usage:\n%s\n", cmdtp->usage);
283 count = simple_strtoul(argv[3], NULL, 10);
286 do_mem_mw (NULL, 0, 3, argv);
288 /* delay for <count> ms... */
289 for (i=0; i<count; i++)
292 /* check for ctrl-c to abort... */
301 #endif /* CONFIG_MX_CYCLIC */
303 int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
305 ulong addr1, addr2, count, ngood;
310 printf ("Usage:\n%s\n", cmdtp->usage);
314 /* Check for size specification.
316 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
319 addr1 = simple_strtoul(argv[1], NULL, 16);
320 addr1 += base_address;
322 addr2 = simple_strtoul(argv[2], NULL, 16);
323 addr2 += base_address;
325 count = simple_strtoul(argv[3], NULL, 16);
327 #ifdef CONFIG_HAS_DATAFLASH
328 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
329 puts ("Comparison with DataFlash space not supported.\n\r");
334 #ifdef CONFIG_BLACKFIN
335 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
336 puts ("Comparison with L1 instruction memory not supported.\n\r");
343 while (count-- > 0) {
345 ulong word1 = *(ulong *)addr1;
346 ulong word2 = *(ulong *)addr2;
347 if (word1 != word2) {
348 printf("word at 0x%08lx (0x%08lx) "
349 "!= word at 0x%08lx (0x%08lx)\n",
350 addr1, word1, addr2, word2);
355 else if (size == 2) {
356 ushort hword1 = *(ushort *)addr1;
357 ushort hword2 = *(ushort *)addr2;
358 if (hword1 != hword2) {
359 printf("halfword at 0x%08lx (0x%04x) "
360 "!= halfword at 0x%08lx (0x%04x)\n",
361 addr1, hword1, addr2, hword2);
367 u_char byte1 = *(u_char *)addr1;
368 u_char byte2 = *(u_char *)addr2;
369 if (byte1 != byte2) {
370 printf("byte at 0x%08lx (0x%02x) "
371 "!= byte at 0x%08lx (0x%02x)\n",
372 addr1, byte1, addr2, byte2);
382 printf("Total of %ld %s%s were the same\n",
383 ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte",
384 ngood == 1 ? "" : "s");
388 int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
390 ulong addr, dest, count;
394 printf ("Usage:\n%s\n", cmdtp->usage);
398 /* Check for size specification.
400 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
403 addr = simple_strtoul(argv[1], NULL, 16);
404 addr += base_address;
406 dest = simple_strtoul(argv[2], NULL, 16);
407 dest += base_address;
409 count = simple_strtoul(argv[3], NULL, 16);
412 puts ("Zero length ???\n");
417 /* check if we are copying to Flash */
418 if ( (addr2info(dest) != NULL)
419 #ifdef CONFIG_HAS_DATAFLASH
420 && (!addr_dataflash(addr))
425 puts ("Copy to Flash... ");
427 rc = flash_write ((char *)addr, dest, count*size);
437 #if defined(CONFIG_CMD_MMC)
438 if (mmc2info(dest)) {
441 puts ("Copy to MMC... ");
442 switch (rc = mmc_write ((uchar *)addr, dest, count*size)) {
450 printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
457 if (mmc2info(addr)) {
460 puts ("Copy from MMC... ");
461 switch (rc = mmc_read (addr, (uchar *)dest, count*size)) {
469 printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
477 #ifdef CONFIG_HAS_DATAFLASH
478 /* Check if we are copying from RAM or Flash to DataFlash */
479 if (addr_dataflash(dest) && !addr_dataflash(addr)){
482 puts ("Copy to DataFlash... ");
484 rc = write_dataflash (dest, addr, count*size);
487 dataflash_perror (rc);
494 /* Check if we are copying from DataFlash to RAM */
495 if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
497 rc = read_dataflash(addr, count * size, (char *) dest);
499 dataflash_perror (rc);
505 if (addr_dataflash(addr) && addr_dataflash(dest)){
506 puts ("Unsupported combination of source/destination.\n\r");
511 #ifdef CONFIG_BLACKFIN
512 /* See if we're copying to/from L1 inst */
513 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
514 memcpy((void *)dest, (void *)addr, count * size);
519 while (count-- > 0) {
521 *((ulong *)dest) = *((ulong *)addr);
523 *((ushort *)dest) = *((ushort *)addr);
525 *((u_char *)dest) = *((u_char *)addr);
532 int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
535 /* Set new base address.
537 base_address = simple_strtoul(argv[1], NULL, 16);
539 /* Print the current base address.
541 printf("Base Address: 0x%08lx\n", base_address);
545 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
547 ulong addr, length, i, junk;
549 volatile uint *longp;
550 volatile ushort *shortp;
554 printf ("Usage:\n%s\n", cmdtp->usage);
558 /* Check for a size spefication.
559 * Defaults to long if no or incorrect specification.
561 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
564 /* Address is always specified.
566 addr = simple_strtoul(argv[1], NULL, 16);
568 /* Length is the number of objects, not number of bytes.
570 length = simple_strtoul(argv[2], NULL, 16);
572 /* We want to optimize the loops to run as fast as possible.
573 * If we have only one object, just run infinite loops.
577 longp = (uint *)addr;
582 shortp = (ushort *)addr;
593 longp = (uint *)addr;
601 shortp = (ushort *)addr;
616 int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
618 ulong addr, length, i, data;
620 volatile uint *longp;
621 volatile ushort *shortp;
625 printf ("Usage:\n%s\n", cmdtp->usage);
629 /* Check for a size spefication.
630 * Defaults to long if no or incorrect specification.
632 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
635 /* Address is always specified.
637 addr = simple_strtoul(argv[1], NULL, 16);
639 /* Length is the number of objects, not number of bytes.
641 length = simple_strtoul(argv[2], NULL, 16);
644 data = simple_strtoul(argv[3], NULL, 16);
646 /* We want to optimize the loops to run as fast as possible.
647 * If we have only one object, just run infinite loops.
651 longp = (uint *)addr;
656 shortp = (ushort *)addr;
667 longp = (uint *)addr;
675 shortp = (ushort *)addr;
688 #endif /* CONFIG_LOOPW */
691 * Perform a memory test. A more complete alternative test can be
692 * configured using CFG_ALT_MEMTEST. The complete test loops until
693 * interrupted by ctrl-c or by a failure of one of the sub-tests.
695 int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
697 vu_long *addr, *start, *end;
702 #if defined(CFG_ALT_MEMTEST)
708 vu_long anti_pattern;
710 #if defined(CFG_MEMTEST_SCRATCH)
711 vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
713 vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */
718 static const ulong bitpattern[] = {
719 0x00000001, /* single bit */
720 0x00000003, /* two adjacent bits */
721 0x00000007, /* three adjacent bits */
722 0x0000000F, /* four adjacent bits */
723 0x00000005, /* two non-adjacent bits */
724 0x00000015, /* three non-adjacent bits */
725 0x00000055, /* four non-adjacent bits */
726 0xaaaaaaaa, /* alternating 1/0 */
734 start = (ulong *)simple_strtoul(argv[1], NULL, 16);
736 start = (ulong *)CFG_MEMTEST_START;
740 end = (ulong *)simple_strtoul(argv[2], NULL, 16);
742 end = (ulong *)(CFG_MEMTEST_END);
746 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
751 #if defined(CFG_ALT_MEMTEST)
752 printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
753 PRINTF("%s:%d: start 0x%p end 0x%p\n",
754 __FUNCTION__, __LINE__, start, end);
762 printf("Iteration: %6d\r", iterations);
763 PRINTF("Iteration: %6d\n", iterations);
767 * Data line test: write a pattern to the first
768 * location, write the 1's complement to a 'parking'
769 * address (changes the state of the data bus so a
770 * floating bus doen't give a false OK), and then
771 * read the value back. Note that we read it back
772 * into a variable because the next time we read it,
773 * it might be right (been there, tough to explain to
774 * the quality guys why it prints a failure when the
775 * "is" and "should be" are obviously the same in the
778 * Rather than exhaustively testing, we test some
779 * patterns by shifting '1' bits through a field of
780 * '0's and '0' bits through a field of '1's (i.e.
781 * pattern and ~pattern).
784 for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
786 for(; val != 0; val <<= 1) {
788 *dummy = ~val; /* clear the test data off of the bus */
790 if(readback != val) {
791 printf ("FAILURE (data line): "
792 "expected %08lx, actual %08lx\n",
798 if(readback != ~val) {
799 printf ("FAILURE (data line): "
800 "Is %08lx, should be %08lx\n",
807 * Based on code whose Original Author and Copyright
808 * information follows: Copyright (c) 1998 by Michael
809 * Barr. This software is placed into the public
810 * domain and may be used for any purpose. However,
811 * this notice must not be changed or removed and no
812 * warranty is either expressed or implied by its
813 * publication or distribution.
819 * Description: Test the address bus wiring in a
820 * memory region by performing a walking
821 * 1's test on the relevant bits of the
822 * address and checking for aliasing.
823 * This test will find single-bit
824 * address failures such as stuck -high,
825 * stuck-low, and shorted pins. The base
826 * address and size of the region are
827 * selected by the caller.
829 * Notes: For best results, the selected base
830 * address should have enough LSB 0's to
831 * guarantee single address bit changes.
832 * For example, to test a 64-Kbyte
833 * region, select a base address on a
834 * 64-Kbyte boundary. Also, select the
835 * region size as a power-of-two if at
838 * Returns: 0 if the test succeeds, 1 if the test fails.
840 * ## NOTE ## Be sure to specify start and end
841 * addresses such that addr_mask has
842 * lots of bits set. For example an
843 * address range of 01000000 02000000 is
844 * bad while a range of 01000000
845 * 01ffffff is perfect.
847 addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
848 pattern = (vu_long) 0xaaaaaaaa;
849 anti_pattern = (vu_long) 0x55555555;
851 PRINTF("%s:%d: addr mask = 0x%.8lx\n",
852 __FUNCTION__, __LINE__,
855 * Write the default pattern at each of the
856 * power-of-two offsets.
858 for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
859 start[offset] = pattern;
863 * Check for address bits stuck high.
866 start[test_offset] = anti_pattern;
868 for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
869 temp = start[offset];
870 if (temp != pattern) {
871 printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
872 " expected 0x%.8lx, actual 0x%.8lx\n",
873 (ulong)&start[offset], pattern, temp);
877 start[test_offset] = pattern;
880 * Check for addr bits stuck low or shorted.
882 for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
883 start[test_offset] = anti_pattern;
885 for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
886 temp = start[offset];
887 if ((temp != pattern) && (offset != test_offset)) {
888 printf ("\nFAILURE: Address bit stuck low or shorted @"
889 " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
890 (ulong)&start[offset], pattern, temp);
894 start[test_offset] = pattern;
898 * Description: Test the integrity of a physical
899 * memory device by performing an
900 * increment/decrement test over the
901 * entire region. In the process every
902 * storage bit in the device is tested
903 * as a zero and a one. The base address
904 * and the size of the region are
905 * selected by the caller.
907 * Returns: 0 if the test succeeds, 1 if the test fails.
909 num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
912 * Fill memory with a known pattern.
914 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
915 start[offset] = pattern;
919 * Check each location and invert it for the second pass.
921 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
922 temp = start[offset];
923 if (temp != pattern) {
924 printf ("\nFAILURE (read/write) @ 0x%.8lx:"
925 " expected 0x%.8lx, actual 0x%.8lx)\n",
926 (ulong)&start[offset], pattern, temp);
930 anti_pattern = ~pattern;
931 start[offset] = anti_pattern;
935 * Check each location for the inverted pattern and zero it.
937 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
938 anti_pattern = ~pattern;
939 temp = start[offset];
940 if (temp != anti_pattern) {
941 printf ("\nFAILURE (read/write): @ 0x%.8lx:"
942 " expected 0x%.8lx, actual 0x%.8lx)\n",
943 (ulong)&start[offset], anti_pattern, temp);
950 #else /* The original, quickie test */
958 printf ("\rPattern %08lX Writing..."
960 "\b\b\b\b\b\b\b\b\b\b",
963 for (addr=start,val=pattern; addr<end; addr++) {
970 for (addr=start,val=pattern; addr<end; addr++) {
972 if (readback != val) {
973 printf ("\nMem error @ 0x%08X: "
974 "found %08lX, expected %08lX\n",
975 (uint)addr, readback, val);
982 * Flip the pattern each time to make lots of zeros and
983 * then, the next time, lots of ones. We decrement
984 * the "negative" patterns and increment the "positive"
985 * patterns to preserve this feature.
987 if(pattern & 0x80000000) {
988 pattern = -pattern; /* complement & increment */
1003 * mm{.b, .w, .l} {addr}
1004 * nm{.b, .w, .l} {addr}
1007 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
1011 extern char console_buffer[];
1014 printf ("Usage:\n%s\n", cmdtp->usage);
1018 #ifdef CONFIG_BOOT_RETRY_TIME
1019 reset_cmd_timeout(); /* got a good command to get here */
1021 /* We use the last specified parameters, unless new ones are
1024 addr = mm_last_addr;
1025 size = mm_last_size;
1027 if ((flag & CMD_FLAG_REPEAT) == 0) {
1028 /* New command specified. Check for a size specification.
1029 * Defaults to long if no or incorrect specification.
1031 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1034 /* Address is specified since argc > 1
1036 addr = simple_strtoul(argv[1], NULL, 16);
1037 addr += base_address;
1040 #ifdef CONFIG_HAS_DATAFLASH
1041 if (addr_dataflash(addr)){
1042 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1047 #ifdef CONFIG_BLACKFIN
1048 if (addr_bfin_on_chip_mem(addr)) {
1049 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1054 /* Print the address, followed by value. Then accept input for
1055 * the next value. A non-converted value exits.
1058 printf("%08lx:", addr);
1060 printf(" %08x", *((uint *)addr));
1062 printf(" %04x", *((ushort *)addr));
1064 printf(" %02x", *((u_char *)addr));
1066 nbytes = readline (" ? ");
1067 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1068 /* <CR> pressed as only input, don't modify current
1069 * location and move to next. "-" pressed will go back.
1072 addr += nbytes ? -size : size;
1074 #ifdef CONFIG_BOOT_RETRY_TIME
1075 reset_cmd_timeout(); /* good enough to not time out */
1078 #ifdef CONFIG_BOOT_RETRY_TIME
1079 else if (nbytes == -2) {
1080 break; /* timed out, exit the command */
1085 i = simple_strtoul(console_buffer, &endp, 16);
1086 nbytes = endp - console_buffer;
1088 #ifdef CONFIG_BOOT_RETRY_TIME
1089 /* good enough to not time out
1091 reset_cmd_timeout();
1094 *((uint *)addr) = i;
1096 *((ushort *)addr) = i;
1098 *((u_char *)addr) = i;
1105 mm_last_addr = addr;
1106 mm_last_size = size;
1110 #ifndef CONFIG_CRC32_VERIFY
1112 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1119 printf ("Usage:\n%s\n", cmdtp->usage);
1123 addr = simple_strtoul (argv[1], NULL, 16);
1124 addr += base_address;
1126 length = simple_strtoul (argv[2], NULL, 16);
1128 crc = crc32 (0, (const uchar *) addr, length);
1130 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1131 addr, addr + length - 1, crc);
1134 ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
1141 #else /* CONFIG_CRC32_VERIFY */
1143 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1155 printf ("Usage:\n%s\n", cmdtp->usage);
1161 if (strcmp(*av, "-v") == 0) {
1170 addr = simple_strtoul(*av++, NULL, 16);
1171 addr += base_address;
1172 length = simple_strtoul(*av++, NULL, 16);
1174 crc = crc32(0, (const uchar *) addr, length);
1177 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1178 addr, addr + length - 1, crc);
1180 ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
1184 vcrc = simple_strtoul(*av++, NULL, 16);
1186 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1187 addr, addr + length - 1, crc, vcrc);
1195 #endif /* CONFIG_CRC32_VERIFY */
1197 /**************************************************/
1198 #if defined(CONFIG_CMD_MEMORY)
1200 md, 3, 1, do_mem_md,
1201 "md - memory display\n",
1202 "[.b, .w, .l] address [# of objects]\n - memory display\n"
1207 mm, 2, 1, do_mem_mm,
1208 "mm - memory modify (auto-incrementing)\n",
1209 "[.b, .w, .l] address\n" " - memory modify, auto increment address\n"
1214 nm, 2, 1, do_mem_nm,
1215 "nm - memory modify (constant address)\n",
1216 "[.b, .w, .l] address\n - memory modify, read and keep address\n"
1220 mw, 4, 1, do_mem_mw,
1221 "mw - memory write (fill)\n",
1222 "[.b, .w, .l] address value [count]\n - write memory\n"
1226 cp, 4, 1, do_mem_cp,
1227 "cp - memory copy\n",
1228 "[.b, .w, .l] source target count\n - copy memory\n"
1232 cmp, 4, 1, do_mem_cmp,
1233 "cmp - memory compare\n",
1234 "[.b, .w, .l] addr1 addr2 count\n - compare memory\n"
1237 #ifndef CONFIG_CRC32_VERIFY
1240 crc32, 4, 1, do_mem_crc,
1241 "crc32 - checksum calculation\n",
1242 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1245 #else /* CONFIG_CRC32_VERIFY */
1248 crc32, 5, 1, do_mem_crc,
1249 "crc32 - checksum calculation\n",
1250 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1251 "-v address count crc\n - verify crc of memory area\n"
1254 #endif /* CONFIG_CRC32_VERIFY */
1257 base, 2, 1, do_mem_base,
1258 "base - print or set address offset\n",
1259 "\n - print address offset for memory commands\n"
1260 "base off\n - set address offset for memory commands to 'off'\n"
1264 loop, 3, 1, do_mem_loop,
1265 "loop - infinite loop on address range\n",
1266 "[.b, .w, .l] address number_of_objects\n"
1267 " - loop on a set of addresses\n"
1272 loopw, 4, 1, do_mem_loopw,
1273 "loopw - infinite write loop on address range\n",
1274 "[.b, .w, .l] address number_of_objects data_to_write\n"
1275 " - loop on a set of addresses\n"
1277 #endif /* CONFIG_LOOPW */
1280 mtest, 4, 1, do_mem_mtest,
1281 "mtest - simple RAM test\n",
1282 "[start [end [pattern]]]\n"
1283 " - simple RAM read/write test\n"
1286 #ifdef CONFIG_MX_CYCLIC
1288 mdc, 4, 1, do_mem_mdc,
1289 "mdc - memory display cyclic\n",
1290 "[.b, .w, .l] address count delay(ms)\n - memory display cyclic\n"
1294 mwc, 4, 1, do_mem_mwc,
1295 "mwc - memory write cyclic\n",
1296 "[.b, .w, .l] address value delay(ms)\n - memory write cyclic\n"
1298 #endif /* CONFIG_MX_CYCLIC */