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>
37 #include <u-boot/md5.h>
41 #define PRINTF(fmt,args...) printf (fmt ,##args)
43 #define PRINTF(fmt,args...)
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 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;
80 return cmd_usage(cmdtp);
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 /* Print the lines. */
148 print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
154 dp_last_length = length;
159 int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
161 return mod_mem (cmdtp, 1, flag, argc, argv);
163 int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
165 return mod_mem (cmdtp, 0, flag, argc, argv);
168 int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
170 ulong addr, writeval, count;
173 if ((argc < 3) || (argc > 4))
174 return cmd_usage(cmdtp);
176 /* Check for size specification.
178 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
181 /* Address is specified since argc > 1
183 addr = simple_strtoul(argv[1], NULL, 16);
184 addr += base_address;
186 /* Get the value to write.
188 writeval = simple_strtoul(argv[2], NULL, 16);
192 count = simple_strtoul(argv[3], NULL, 16);
197 while (count-- > 0) {
199 *((ulong *)addr) = (ulong )writeval;
201 *((ushort *)addr) = (ushort)writeval;
203 *((u_char *)addr) = (u_char)writeval;
209 #ifdef CONFIG_MX_CYCLIC
210 int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
216 return cmd_usage(cmdtp);
218 count = simple_strtoul(argv[3], NULL, 10);
221 do_mem_md (NULL, 0, 3, argv);
223 /* delay for <count> ms... */
224 for (i=0; i<count; i++)
227 /* check for ctrl-c to abort... */
237 int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
243 return cmd_usage(cmdtp);
245 count = simple_strtoul(argv[3], NULL, 10);
248 do_mem_mw (NULL, 0, 3, argv);
250 /* delay for <count> ms... */
251 for (i=0; i<count; i++)
254 /* check for ctrl-c to abort... */
263 #endif /* CONFIG_MX_CYCLIC */
265 int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
267 ulong addr1, addr2, count, ngood;
272 return cmd_usage(cmdtp);
274 /* Check for size specification.
276 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
279 addr1 = simple_strtoul(argv[1], NULL, 16);
280 addr1 += base_address;
282 addr2 = simple_strtoul(argv[2], NULL, 16);
283 addr2 += base_address;
285 count = simple_strtoul(argv[3], NULL, 16);
287 #ifdef CONFIG_HAS_DATAFLASH
288 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
289 puts ("Comparison with DataFlash space not supported.\n\r");
294 #ifdef CONFIG_BLACKFIN
295 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
296 puts ("Comparison with L1 instruction memory not supported.\n\r");
303 while (count-- > 0) {
305 ulong word1 = *(ulong *)addr1;
306 ulong word2 = *(ulong *)addr2;
307 if (word1 != word2) {
308 printf("word at 0x%08lx (0x%08lx) "
309 "!= word at 0x%08lx (0x%08lx)\n",
310 addr1, word1, addr2, word2);
315 else if (size == 2) {
316 ushort hword1 = *(ushort *)addr1;
317 ushort hword2 = *(ushort *)addr2;
318 if (hword1 != hword2) {
319 printf("halfword at 0x%08lx (0x%04x) "
320 "!= halfword at 0x%08lx (0x%04x)\n",
321 addr1, hword1, addr2, hword2);
327 u_char byte1 = *(u_char *)addr1;
328 u_char byte2 = *(u_char *)addr2;
329 if (byte1 != byte2) {
330 printf("byte at 0x%08lx (0x%02x) "
331 "!= byte at 0x%08lx (0x%02x)\n",
332 addr1, byte1, addr2, byte2);
341 /* reset watchdog from time to time */
342 if ((count % (64 << 10)) == 0)
346 printf("Total of %ld %s%s were the same\n",
347 ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte",
348 ngood == 1 ? "" : "s");
352 int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
354 ulong addr, dest, count;
358 return cmd_usage(cmdtp);
360 /* Check for size specification.
362 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
365 addr = simple_strtoul(argv[1], NULL, 16);
366 addr += base_address;
368 dest = simple_strtoul(argv[2], NULL, 16);
369 dest += base_address;
371 count = simple_strtoul(argv[3], NULL, 16);
374 puts ("Zero length ???\n");
378 #ifndef CONFIG_SYS_NO_FLASH
379 /* check if we are copying to Flash */
380 if ( (addr2info(dest) != NULL)
381 #ifdef CONFIG_HAS_DATAFLASH
382 && (!addr_dataflash(dest))
387 puts ("Copy to Flash... ");
389 rc = flash_write ((char *)addr, dest, count*size);
399 #ifdef CONFIG_HAS_DATAFLASH
400 /* Check if we are copying from RAM or Flash to DataFlash */
401 if (addr_dataflash(dest) && !addr_dataflash(addr)){
404 puts ("Copy to DataFlash... ");
406 rc = write_dataflash (dest, addr, count*size);
409 dataflash_perror (rc);
416 /* Check if we are copying from DataFlash to RAM */
417 if (addr_dataflash(addr) && !addr_dataflash(dest)
418 #ifndef CONFIG_SYS_NO_FLASH
419 && (addr2info(dest) == NULL)
423 rc = read_dataflash(addr, count * size, (char *) dest);
425 dataflash_perror (rc);
431 if (addr_dataflash(addr) && addr_dataflash(dest)){
432 puts ("Unsupported combination of source/destination.\n\r");
437 #ifdef CONFIG_BLACKFIN
438 /* See if we're copying to/from L1 inst */
439 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
440 memcpy((void *)dest, (void *)addr, count * size);
445 while (count-- > 0) {
447 *((ulong *)dest) = *((ulong *)addr);
449 *((ushort *)dest) = *((ushort *)addr);
451 *((u_char *)dest) = *((u_char *)addr);
455 /* reset watchdog from time to time */
456 if ((count % (64 << 10)) == 0)
462 int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
465 /* Set new base address.
467 base_address = simple_strtoul(argv[1], NULL, 16);
469 /* Print the current base address.
471 printf("Base Address: 0x%08lx\n", base_address);
475 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
477 ulong addr, length, i, junk;
479 volatile uint *longp;
480 volatile ushort *shortp;
484 return cmd_usage(cmdtp);
486 /* Check for a size spefication.
487 * Defaults to long if no or incorrect specification.
489 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
492 /* Address is always specified.
494 addr = simple_strtoul(argv[1], NULL, 16);
496 /* Length is the number of objects, not number of bytes.
498 length = simple_strtoul(argv[2], NULL, 16);
500 /* We want to optimize the loops to run as fast as possible.
501 * If we have only one object, just run infinite loops.
505 longp = (uint *)addr;
510 shortp = (ushort *)addr;
521 longp = (uint *)addr;
529 shortp = (ushort *)addr;
544 int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
546 ulong addr, length, i, data;
548 volatile uint *longp;
549 volatile ushort *shortp;
553 return cmd_usage(cmdtp);
555 /* Check for a size spefication.
556 * Defaults to long if no or incorrect specification.
558 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
561 /* Address is always specified.
563 addr = simple_strtoul(argv[1], NULL, 16);
565 /* Length is the number of objects, not number of bytes.
567 length = simple_strtoul(argv[2], NULL, 16);
570 data = simple_strtoul(argv[3], 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;
614 #endif /* CONFIG_LOOPW */
617 * Perform a memory test. A more complete alternative test can be
618 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
619 * interrupted by ctrl-c or by a failure of one of the sub-tests.
621 int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
623 vu_long *addr, *start, *end;
630 #if defined(CONFIG_SYS_ALT_MEMTEST)
636 vu_long anti_pattern;
638 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
639 vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
641 vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */
645 static const ulong bitpattern[] = {
646 0x00000001, /* single bit */
647 0x00000003, /* two adjacent bits */
648 0x00000007, /* three adjacent bits */
649 0x0000000F, /* four adjacent bits */
650 0x00000005, /* two non-adjacent bits */
651 0x00000015, /* three non-adjacent bits */
652 0x00000055, /* four non-adjacent bits */
653 0xaaaaaaaa, /* alternating 1/0 */
661 start = (ulong *)simple_strtoul(argv[1], NULL, 16);
663 start = (ulong *)CONFIG_SYS_MEMTEST_START;
666 end = (ulong *)simple_strtoul(argv[2], NULL, 16);
668 end = (ulong *)(CONFIG_SYS_MEMTEST_END);
671 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
676 iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
680 #if defined(CONFIG_SYS_ALT_MEMTEST)
681 printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
682 PRINTF("%s:%d: start 0x%p end 0x%p\n",
683 __FUNCTION__, __LINE__, start, end);
692 if (iteration_limit && iterations > iteration_limit) {
693 printf("Tested %d iteration(s) with %lu errors.\n",
698 printf("Iteration: %6d\r", iterations);
703 * Data line test: write a pattern to the first
704 * location, write the 1's complement to a 'parking'
705 * address (changes the state of the data bus so a
706 * floating bus doen't give a false OK), and then
707 * read the value back. Note that we read it back
708 * into a variable because the next time we read it,
709 * it might be right (been there, tough to explain to
710 * the quality guys why it prints a failure when the
711 * "is" and "should be" are obviously the same in the
714 * Rather than exhaustively testing, we test some
715 * patterns by shifting '1' bits through a field of
716 * '0's and '0' bits through a field of '1's (i.e.
717 * pattern and ~pattern).
720 for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
722 for(; val != 0; val <<= 1) {
724 *dummy = ~val; /* clear the test data off of the bus */
726 if(readback != val) {
727 printf ("FAILURE (data line): "
728 "expected %08lx, actual %08lx\n",
739 if(readback != ~val) {
740 printf ("FAILURE (data line): "
741 "Is %08lx, should be %08lx\n",
753 * Based on code whose Original Author and Copyright
754 * information follows: Copyright (c) 1998 by Michael
755 * Barr. This software is placed into the public
756 * domain and may be used for any purpose. However,
757 * this notice must not be changed or removed and no
758 * warranty is either expressed or implied by its
759 * publication or distribution.
765 * Description: Test the address bus wiring in a
766 * memory region by performing a walking
767 * 1's test on the relevant bits of the
768 * address and checking for aliasing.
769 * This test will find single-bit
770 * address failures such as stuck -high,
771 * stuck-low, and shorted pins. The base
772 * address and size of the region are
773 * selected by the caller.
775 * Notes: For best results, the selected base
776 * address should have enough LSB 0's to
777 * guarantee single address bit changes.
778 * For example, to test a 64-Kbyte
779 * region, select a base address on a
780 * 64-Kbyte boundary. Also, select the
781 * region size as a power-of-two if at
784 * Returns: 0 if the test succeeds, 1 if the test fails.
786 len = ((ulong)end - (ulong)start)/sizeof(vu_long);
787 pattern = (vu_long) 0xaaaaaaaa;
788 anti_pattern = (vu_long) 0x55555555;
790 PRINTF("%s:%d: length = 0x%.8lx\n",
791 __FUNCTION__, __LINE__,
794 * Write the default pattern at each of the
795 * power-of-two offsets.
797 for (offset = 1; offset < len; offset <<= 1) {
798 start[offset] = pattern;
802 * Check for address bits stuck high.
805 start[test_offset] = anti_pattern;
807 for (offset = 1; offset < len; offset <<= 1) {
808 temp = start[offset];
809 if (temp != pattern) {
810 printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
811 " expected 0x%.8lx, actual 0x%.8lx\n",
812 (ulong)&start[offset], pattern, temp);
820 start[test_offset] = pattern;
824 * Check for addr bits stuck low or shorted.
826 for (test_offset = 1; test_offset < len; test_offset <<= 1) {
827 start[test_offset] = anti_pattern;
829 for (offset = 1; offset < len; offset <<= 1) {
830 temp = start[offset];
831 if ((temp != pattern) && (offset != test_offset)) {
832 printf ("\nFAILURE: Address bit stuck low or shorted @"
833 " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
834 (ulong)&start[offset], pattern, temp);
842 start[test_offset] = pattern;
846 * Description: Test the integrity of a physical
847 * memory device by performing an
848 * increment/decrement test over the
849 * entire region. In the process every
850 * storage bit in the device is tested
851 * as a zero and a one. The base address
852 * and the size of the region are
853 * selected by the caller.
855 * Returns: 0 if the test succeeds, 1 if the test fails.
857 num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
860 * Fill memory with a known pattern.
862 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
864 start[offset] = pattern;
868 * Check each location and invert it for the second pass.
870 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
872 temp = start[offset];
873 if (temp != pattern) {
874 printf ("\nFAILURE (read/write) @ 0x%.8lx:"
875 " expected 0x%.8lx, actual 0x%.8lx)\n",
876 (ulong)&start[offset], pattern, temp);
884 anti_pattern = ~pattern;
885 start[offset] = anti_pattern;
889 * Check each location for the inverted pattern and zero it.
891 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
893 anti_pattern = ~pattern;
894 temp = start[offset];
895 if (temp != anti_pattern) {
896 printf ("\nFAILURE (read/write): @ 0x%.8lx:"
897 " expected 0x%.8lx, actual 0x%.8lx)\n",
898 (ulong)&start[offset], anti_pattern, temp);
909 #else /* The original, quickie test */
917 if (iteration_limit && iterations > iteration_limit) {
918 printf("Tested %d iteration(s) with %lu errors.\n",
924 printf ("\rPattern %08lX Writing..."
926 "\b\b\b\b\b\b\b\b\b\b",
929 for (addr=start,val=pattern; addr<end; addr++) {
937 for (addr=start,val=pattern; addr<end; addr++) {
940 if (readback != val) {
941 printf ("\nMem error @ 0x%08X: "
942 "found %08lX, expected %08lX\n",
943 (uint)addr, readback, val);
954 * Flip the pattern each time to make lots of zeros and
955 * then, the next time, lots of ones. We decrement
956 * the "negative" patterns and increment the "positive"
957 * patterns to preserve this feature.
959 if(pattern & 0x80000000) {
960 pattern = -pattern; /* complement & increment */
968 return 0; /* not reached */
975 * mm{.b, .w, .l} {addr}
976 * nm{.b, .w, .l} {addr}
979 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
983 extern char console_buffer[];
986 return cmd_usage(cmdtp);
988 #ifdef CONFIG_BOOT_RETRY_TIME
989 reset_cmd_timeout(); /* got a good command to get here */
991 /* We use the last specified parameters, unless new ones are
997 if ((flag & CMD_FLAG_REPEAT) == 0) {
998 /* New command specified. Check for a size specification.
999 * Defaults to long if no or incorrect specification.
1001 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1004 /* Address is specified since argc > 1
1006 addr = simple_strtoul(argv[1], NULL, 16);
1007 addr += base_address;
1010 #ifdef CONFIG_HAS_DATAFLASH
1011 if (addr_dataflash(addr)){
1012 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1017 #ifdef CONFIG_BLACKFIN
1018 if (addr_bfin_on_chip_mem(addr)) {
1019 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1024 /* Print the address, followed by value. Then accept input for
1025 * the next value. A non-converted value exits.
1028 printf("%08lx:", addr);
1030 printf(" %08x", *((uint *)addr));
1032 printf(" %04x", *((ushort *)addr));
1034 printf(" %02x", *((u_char *)addr));
1036 nbytes = readline (" ? ");
1037 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1038 /* <CR> pressed as only input, don't modify current
1039 * location and move to next. "-" pressed will go back.
1042 addr += nbytes ? -size : size;
1044 #ifdef CONFIG_BOOT_RETRY_TIME
1045 reset_cmd_timeout(); /* good enough to not time out */
1048 #ifdef CONFIG_BOOT_RETRY_TIME
1049 else if (nbytes == -2) {
1050 break; /* timed out, exit the command */
1055 i = simple_strtoul(console_buffer, &endp, 16);
1056 nbytes = endp - console_buffer;
1058 #ifdef CONFIG_BOOT_RETRY_TIME
1059 /* good enough to not time out
1061 reset_cmd_timeout();
1064 *((uint *)addr) = i;
1066 *((ushort *)addr) = i;
1068 *((u_char *)addr) = i;
1075 mm_last_addr = addr;
1076 mm_last_size = size;
1080 #ifndef CONFIG_CRC32_VERIFY
1082 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1089 return cmd_usage(cmdtp);
1091 addr = simple_strtoul (argv[1], NULL, 16);
1092 addr += base_address;
1094 length = simple_strtoul (argv[2], NULL, 16);
1096 crc = crc32 (0, (const uchar *) addr, length);
1098 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1099 addr, addr + length - 1, crc);
1102 ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
1109 #else /* CONFIG_CRC32_VERIFY */
1111 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1123 return cmd_usage(cmdtp);
1128 if (strcmp(*av, "-v") == 0) {
1137 addr = simple_strtoul(*av++, NULL, 16);
1138 addr += base_address;
1139 length = simple_strtoul(*av++, NULL, 16);
1141 crc = crc32(0, (const uchar *) addr, length);
1144 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1145 addr, addr + length - 1, crc);
1147 ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
1151 vcrc = simple_strtoul(*av++, NULL, 16);
1153 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1154 addr, addr + length - 1, crc, vcrc);
1162 #endif /* CONFIG_CRC32_VERIFY */
1164 #ifdef CONFIG_CMD_MD5SUM
1165 int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1167 unsigned long addr, len;
1172 return cmd_usage(cmdtp);
1174 addr = simple_strtoul(argv[1], NULL, 16);
1175 len = simple_strtoul(argv[2], NULL, 16);
1177 md5((unsigned char *) addr, len, output);
1178 printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
1179 for (i = 0; i < 16; i++)
1180 printf("%02x", output[i]);
1187 #ifdef CONFIG_CMD_SHA1SUM
1188 int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1190 unsigned long addr, len;
1195 return cmd_usage(cmdtp);
1197 addr = simple_strtoul(argv[1], NULL, 16);
1198 len = simple_strtoul(argv[2], NULL, 16);
1200 sha1_csum((unsigned char *) addr, len, output);
1201 printf("SHA1 for %08lx ... %08lx ==> ", addr, addr + len - 1);
1202 for (i = 0; i < 20; i++)
1203 printf("%02x", output[i]);
1210 #ifdef CONFIG_CMD_UNZIP
1211 int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1213 unsigned long src, dst;
1214 unsigned long src_len = ~0UL, dst_len = ~0UL;
1219 dst_len = simple_strtoul(argv[3], NULL, 16);
1222 src = simple_strtoul(argv[1], NULL, 16);
1223 dst = simple_strtoul(argv[2], NULL, 16);
1226 return cmd_usage(cmdtp);
1229 if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0)
1232 printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
1233 sprintf(buf, "%lX", src_len);
1234 setenv("filesize", buf);
1238 #endif /* CONFIG_CMD_UNZIP */
1241 /**************************************************/
1243 md, 3, 1, do_mem_md,
1245 "[.b, .w, .l] address [# of objects]"
1250 mm, 2, 1, do_mem_mm,
1251 "memory modify (auto-incrementing address)",
1252 "[.b, .w, .l] address"
1257 nm, 2, 1, do_mem_nm,
1258 "memory modify (constant address)",
1259 "[.b, .w, .l] address"
1263 mw, 4, 1, do_mem_mw,
1264 "memory write (fill)",
1265 "[.b, .w, .l] address value [count]"
1269 cp, 4, 1, do_mem_cp,
1271 "[.b, .w, .l] source target count"
1275 cmp, 4, 1, do_mem_cmp,
1277 "[.b, .w, .l] addr1 addr2 count"
1280 #ifndef CONFIG_CRC32_VERIFY
1283 crc32, 4, 1, do_mem_crc,
1284 "checksum calculation",
1285 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1288 #else /* CONFIG_CRC32_VERIFY */
1291 crc32, 5, 1, do_mem_crc,
1292 "checksum calculation",
1293 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1294 "-v address count crc\n - verify crc of memory area"
1297 #endif /* CONFIG_CRC32_VERIFY */
1300 base, 2, 1, do_mem_base,
1301 "print or set address offset",
1302 "\n - print address offset for memory commands\n"
1303 "base off\n - set address offset for memory commands to 'off'"
1307 loop, 3, 1, do_mem_loop,
1308 "infinite loop on address range",
1309 "[.b, .w, .l] address number_of_objects"
1314 loopw, 4, 1, do_mem_loopw,
1315 "infinite write loop on address range",
1316 "[.b, .w, .l] address number_of_objects data_to_write"
1318 #endif /* CONFIG_LOOPW */
1321 mtest, 5, 1, do_mem_mtest,
1322 "simple RAM read/write test",
1323 "[start [end [pattern [iterations]]]]"
1326 #ifdef CONFIG_MX_CYCLIC
1328 mdc, 4, 1, do_mem_mdc,
1329 "memory display cyclic",
1330 "[.b, .w, .l] address count delay(ms)"
1334 mwc, 4, 1, do_mem_mwc,
1335 "memory write cyclic",
1336 "[.b, .w, .l] address value delay(ms)"
1338 #endif /* CONFIG_MX_CYCLIC */
1340 #ifdef CONFIG_CMD_MD5SUM
1342 md5sum, 3, 1, do_md5sum,
1343 "compute MD5 message digest",
1348 #ifdef CONFIG_CMD_SHA1SUM
1350 sha1sum, 3, 1, do_sha1sum,
1351 "compute SHA1 message digest",
1354 #endif /* CONFIG_CMD_SHA1SUM */
1356 #ifdef CONFIG_CMD_UNZIP
1358 unzip, 4, 1, do_unzip,
1359 "unzip a memory region",
1360 "srcaddr dstaddr [dstsize]"
1362 #endif /* CONFIG_CMD_UNZIP */