mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-27 22:56:49 +08:00
cmd: sf: Print error on test failure
The sf test command is used to test spi flashes (and spi masters). Printing the exact error code is very helpful to those debugging the spi stack. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
parent
1bb8ca3b4b
commit
9bc772812d
22
cmd/sf.c
22
cmd/sf.c
@ -445,20 +445,22 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
|
||||
ulong offset, uint8_t *vbuf)
|
||||
{
|
||||
struct test_info test;
|
||||
int i;
|
||||
int err, i;
|
||||
|
||||
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)) {
|
||||
printf("Erase failed\n");
|
||||
err = spi_flash_erase(flash, offset, len);
|
||||
if (err) {
|
||||
printf("Erase failed (err = %d)\n", err);
|
||||
return -1;
|
||||
}
|
||||
spi_test_next_stage(&test);
|
||||
|
||||
if (spi_flash_read(flash, offset, len, vbuf)) {
|
||||
printf("Check read failed\n");
|
||||
err = spi_flash_read(flash, offset, len, vbuf);
|
||||
if (err) {
|
||||
printf("Check read failed (err = %d)\n", err);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
@ -471,15 +473,17 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
|
||||
}
|
||||
spi_test_next_stage(&test);
|
||||
|
||||
if (spi_flash_write(flash, offset, len, buf)) {
|
||||
printf("Write failed\n");
|
||||
err = spi_flash_write(flash, offset, len, buf);
|
||||
if (err) {
|
||||
printf("Write failed (err = %d)\n", err);
|
||||
return -1;
|
||||
}
|
||||
memset(vbuf, '\0', len);
|
||||
spi_test_next_stage(&test);
|
||||
|
||||
if (spi_flash_read(flash, offset, len, vbuf)) {
|
||||
printf("Read failed\n");
|
||||
err = spi_flash_read(flash, offset, len, vbuf);
|
||||
if (err) {
|
||||
printf("Read failed (ret = %d)\n", err);
|
||||
return -1;
|
||||
}
|
||||
spi_test_next_stage(&test);
|
||||
|
Loading…
Reference in New Issue
Block a user