svn_rev_676
This commit is contained in:
parent
f59546b79b
commit
5a7d488510
|
@ -125,7 +125,12 @@ config CMD_MEMINFO
|
|||
|
||||
config CMD_MEMORY
|
||||
bool
|
||||
prompt "md, mm, mw and several others"
|
||||
prompt "md and mw"
|
||||
|
||||
config CMD_CRC
|
||||
bool
|
||||
select CRC32
|
||||
prompt "crc"
|
||||
|
||||
config CMD_MTEST
|
||||
bool
|
||||
|
|
|
@ -27,3 +27,4 @@ obj-$(CONFIG_CMD_CAT) += cat.o
|
|||
obj-$(CONFIG_CMD_MOUNT) += mount.o
|
||||
obj-$(CONFIG_CMD_UMOUNT) += umount.o
|
||||
obj-$(CONFIG_CMD_REGINFO) += reginfo.o
|
||||
obj-$(CONFIG_CMD_CRC) += crc.o
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
|
||||
#ifndef CONFIG_CRC32_VERIFY
|
||||
|
||||
int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
ulong addr, length;
|
||||
ulong crc;
|
||||
ulong *ptr;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
addr = simple_strtoul (argv[1], NULL, 16);
|
||||
|
||||
length = simple_strtoul (argv[2], NULL, 16);
|
||||
|
||||
crc = crc32 (0, (const uchar *) addr, length);
|
||||
|
||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
|
||||
addr, addr + length - 1, crc);
|
||||
|
||||
if (argc > 3) {
|
||||
ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
|
||||
*ptr = crc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* CONFIG_CRC32_VERIFY */
|
||||
|
||||
int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
ulong addr, length;
|
||||
ulong crc;
|
||||
ulong *ptr;
|
||||
ulong vcrc;
|
||||
int verify;
|
||||
int ac;
|
||||
char **av;
|
||||
|
||||
if (argc < 3) {
|
||||
usage:
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
av = argv + 1;
|
||||
ac = argc - 1;
|
||||
if (strcmp(*av, "-v") == 0) {
|
||||
verify = 1;
|
||||
av++;
|
||||
ac--;
|
||||
if (ac < 3)
|
||||
goto usage;
|
||||
} else
|
||||
verify = 0;
|
||||
|
||||
addr = simple_strtoul(*av++, NULL, 16);
|
||||
length = simple_strtoul(*av++, NULL, 16);
|
||||
|
||||
crc = crc32(0, (const uchar *) addr, length);
|
||||
|
||||
if (!verify) {
|
||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
|
||||
addr, addr + length - 1, crc);
|
||||
if (ac > 2) {
|
||||
ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
|
||||
*ptr = crc;
|
||||
}
|
||||
} else {
|
||||
vcrc = simple_strtoul(*av++, NULL, 16);
|
||||
if (vcrc != crc) {
|
||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
|
||||
addr, addr + length - 1, crc, vcrc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif /* CONFIG_CRC32_VERIFY */
|
||||
|
||||
#ifndef CONFIG_CRC32_VERIFY
|
||||
|
||||
U_BOOT_CMD_START(crc32)
|
||||
.maxargs = 4,
|
||||
.cmd = do_mem_crc,
|
||||
.usage = "checksum calculation",
|
||||
U_BOOT_CMD_HELP("address count [addr]\n - compute CRC32 checksum [save at addr]\n")
|
||||
U_BOOT_CMD_END
|
||||
|
||||
#else /* CONFIG_CRC32_VERIFY */
|
||||
|
||||
U_BOOT_CMD(
|
||||
crc32, 5, 0, do_mem_crc,
|
||||
"crc32 - checksum calculation\n",
|
||||
"address count [addr]\n - compute CRC32 checksum [save at addr]\n"
|
||||
"-v address count crc\n - verify crc of memory area\n"
|
||||
);
|
||||
|
||||
#endif /* CONFIG_CRC32_VERIFY */
|
Loading…
Reference in New Issue