cmd: sf: add test count

Change-Id: I06c0783998152ef5d32f95f6813d5dfe315b4cc2
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
This commit is contained in:
Andy Yan 2018-02-06 09:52:31 +08:00
parent a3d7c00b32
commit 4715d15e17
1 changed files with 17 additions and 2 deletions

View File

@ -442,12 +442,15 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
{
struct test_info test;
int i;
int erase_len;
printf("SPI flash test:\n");
memset(&test, '\0', sizeof(test));
test.base_ms = get_timer(0);
test.bytes = len;
if (spi_flash_erase(flash, offset, len)) {
erase_len = roundup(len, 4096);
if (spi_flash_erase(flash, offset, erase_len)) {
printf("Erase failed\n");
return -1;
}
@ -506,6 +509,8 @@ static int do_spi_flash_test(int argc, char * const argv[])
char *endp;
uint8_t *vbuf;
int ret;
int count;
int i;
if (argc < 3)
return -1;
@ -516,6 +521,10 @@ static int do_spi_flash_test(int argc, char * const argv[])
if (*argv[2] == 0 || *endp != 0)
return -1;
count = simple_strtoul(argv[3], &endp, 10);
if (!count)
count = 1;
vbuf = memalign(ARCH_DMA_MINALIGN, len);
if (!vbuf) {
printf("Cannot allocate memory (%lu bytes)\n", len);
@ -530,7 +539,13 @@ static int do_spi_flash_test(int argc, char * const argv[])
from = map_sysmem(CONFIG_SYS_TEXT_BASE, 0);
memcpy(buf, from, len);
ret = spi_flash_test(flash, buf, len, offset, vbuf);
for (i = 0; i < count; i++) {
ret = spi_flash_test(flash, buf, len, offset, vbuf);
if (ret < 0) {
printf("Test Failed, passed count:%d\n", i);
break;
}
}
free(vbuf);
free(buf);
if (ret) {