diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 0142fad442..9934f55e49 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -192,19 +192,28 @@ int spi_flash_cmd_poll_bit(const struct spi_flash *flash, unsigned long timeout, { const struct spi_slave *spi = &flash->spi; int ret; + int attempt = 0; u8 status; struct stopwatch sw; stopwatch_init_msecs_expire(&sw, timeout); do { + attempt++; + ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1); - if (ret) + if (ret) { + printk(BIOS_WARNING, + "SF: SPI command failed on attempt %d with rc %d\n", attempt, + ret); return -1; + } + if ((status & poll_bit) == 0) return 0; } while (!stopwatch_expired(&sw)); - printk(BIOS_WARNING, "SF: timeout at %ld msec\n", stopwatch_duration_msecs(&sw)); + printk(BIOS_WARNING, "SF: timeout at %ld msec after %d attempts\n", + stopwatch_duration_msecs(&sw), attempt); return -1; }