Newer
Older
ulong iteration_limit = 0;
ulong errs = 0; /* number of errors, or -1 if interrupted */
#if defined(CONFIG_SYS_ALT_MEMTEST)
const int alt_test = 1;
#else
const int alt_test = 0;
start = CONFIG_SYS_MEMTEST_START;
end = CONFIG_SYS_MEMTEST_END;
if (strict_strtoul(argv[1], 16, &start) < 0)
return CMD_RET_USAGE;
if (strict_strtoul(argv[2], 16, &end) < 0)
return CMD_RET_USAGE;
if (strict_strtoul(argv[3], 16, &pattern) < 0)
return CMD_RET_USAGE;
if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
return CMD_RET_USAGE;
if (end < start) {
printf("Refusing to do empty test\n");
return -1;
}
printf("Testing %08x ... %08x:\n", (uint)start, (uint)end);
debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
start, end);
buf = map_sysmem(start, end - start);
dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
for (iteration = 0;
!iteration_limit || iteration < iteration_limit;
iteration++) {
if (ctrlc()) {
errs = -1UL;
break;
}
printf("Iteration: %6d\r", iteration + 1);
debug("\n");
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
if (alt_test) {
errs = mem_test_alt(buf, start, end, dummy);
} else {
errs = mem_test_quick(buf, start, end, pattern,
iteration);
}
if (errs == -1UL)
break;
}
/*
* Work-around for eldk-4.2 which gives this warning if we try to
* case in the unmap_sysmem() call:
* warning: initialization discards qualifiers from pointer target type
*/
{
void *vbuf = (void *)buf;
void *vdummy = (void *)dummy;
unmap_sysmem(vbuf);
unmap_sysmem(vdummy);
/* Memory test was aborted - write a newline to finish off */
putc('\n');
ret = 1;
} else {
printf("Tested %d iteration(s) with %lu errors.\n",
iteration, errs);
ret = errs != 0;
}
#endif /* CONFIG_CMD_MEMTEST */
* mm{.b, .w, .l, .q} {addr}
* nm{.b, .w, .l, .q} {addr}
mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
ulong addr;
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
u64 i;
#else
ulong i;
#endif
int nbytes, size;
return CMD_RET_USAGE;
bootretry_reset_cmd_timeout(); /* got a good command to get here */
/* We use the last specified parameters, unless new ones are
* entered.
*/
addr = mm_last_addr;
size = mm_last_size;
if ((flag & CMD_FLAG_REPEAT) == 0) {
/* New command specified. Check for a size specification.
* Defaults to long if no or incorrect specification.
*/
if ((size = cmd_get_data_size(argv[0], 4)) < 0)
return 1;
/* Address is specified since argc > 1
*/
addr = simple_strtoul(argv[1], NULL, 16);
addr += base_address;
}
#ifdef CONFIG_HAS_DATAFLASH
if (addr_dataflash(addr)){
puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
return 0;
}
#endif
#ifdef CONFIG_BLACKFIN
if (addr_bfin_on_chip_mem(addr)) {
puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
return 0;
}
#endif
/* Print the address, followed by value. Then accept input for
* the next value. A non-converted value exits.
*/
do {
ptr = map_sysmem(addr, size);
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
else if (size == 8)
printf(" %016" PRIx64, *((u64 *)ptr));
if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
/* <CR> pressed as only input, don't modify current
* location and move to next. "-" pressed will go back.
*/
if (incrflag)
addr += nbytes ? -size : size;
nbytes = 1;
/* good enough to not time out */
bootretry_reset_cmd_timeout();
}
#ifdef CONFIG_BOOT_RETRY_TIME
else if (nbytes == -2) {
break; /* timed out, exit the command */
}
#endif
else {
char *endp;
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
i = simple_strtoull(console_buffer, &endp, 16);
#else
nbytes = endp - console_buffer;
if (nbytes) {
/* good enough to not time out
*/
bootretry_reset_cmd_timeout();
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
else if (size == 8)
*((u64 *)ptr) = i;
#endif
if (incrflag)
addr += size;
}
}
} while (nbytes);
if (ptr)
unmap_sysmem(ptr);
mm_last_addr = addr;
mm_last_size = size;
return 0;
}
static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char * const *av;
return CMD_RET_USAGE;
av = argv + 1;
ac = argc - 1;
if (strcmp(*av, "-v") == 0) {
return hash_command("crc32", flags, cmdtp, flag, ac, av);
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address [# of objects]"
#else
"memory modify (auto-incrementing address)",
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address"
#else
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address"
#else
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address value [count]"
#else
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] source target count"
#else
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] addr1 addr2 count"
#else
#ifndef CONFIG_CRC32_VERIFY
"address count [addr]\n - compute CRC32 checksum [save at addr]"
#else /* CONFIG_CRC32_VERIFY */
U_BOOT_CMD(
"address count [addr]\n - compute CRC32 checksum [save at addr]\n"
"-v address count crc\n - verify crc of memory area"
);
#endif /* CONFIG_CRC32_VERIFY */
#ifdef CONFIG_CMD_MEMINFO
__weak void board_show_dram(ulong size)
{
puts("DRAM: ");
print_size(size, "\n");
}
static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
board_show_dram(gd->ram_size);
return 0;
}
#endif
"base off\n - set address offset for memory commands to 'off'"
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address number_of_objects"
#else
#ifdef CONFIG_LOOPW
U_BOOT_CMD(
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address number_of_objects data_to_write"
#else
"[.b, .w, .l] address number_of_objects data_to_write"
);
#endif /* CONFIG_LOOPW */
#ifdef CONFIG_CMD_MEMTEST
"simple RAM read/write test",
"[start [end [pattern [iterations]]]]"
#endif /* CONFIG_CMD_MEMTEST */
#ifdef CONFIG_MX_CYCLIC
U_BOOT_CMD(
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address count delay(ms)"
#else
);
U_BOOT_CMD(
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
"[.b, .w, .l, .q] address value delay(ms)"
#else
);
#endif /* CONFIG_MX_CYCLIC */
#ifdef CONFIG_CMD_MEMINFO
U_BOOT_CMD(
meminfo, 3, 1, do_mem_info,
"display memory information",
""
);
#endif