From: Gabriel Somlo Date: Fri, 27 Mar 2020 11:01:02 +0000 (-0400) Subject: software/libbase/spisdcard: add delay to goidle loop X-Git-Tag: 24jan2021_ls180~510^2~1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e9054ef65ad518cca6d792d9db767e19b3c60e3b;p=litex.git software/libbase/spisdcard: add delay to goidle loop In `spi_sdcard_goidle()`, insert a `busy_wait()` into the CMD55+ACMD41 loop to avoid exhausting the retry counter before the card has a chance to be ready (required on the trellisboard, also tested OK on nexys4ddr). Signed-off-by: Gabriel Somlo --- diff --git a/litex/soc/software/libbase/spisdcard.c b/litex/soc/software/libbase/spisdcard.c index 0befe993..ab6cbe03 100644 --- a/litex/soc/software/libbase/spisdcard.c +++ b/litex/soc/software/libbase/spisdcard.c @@ -20,6 +20,7 @@ #include #include #include +#include #define USE_SPISCARD_RECLOCKING @@ -217,6 +218,7 @@ uint8_t spi_sdcard_goidle(void) spi_write_byte( 0xff ); spi_write_byte( 0x69 ); spi_write_byte( 0x40 ); spi_write_byte( 0x00 ); spi_write_byte( 0x00 ); spi_write_byte( 0x00 ); spi_write_byte( 0x00 ); r = spi_read_rbyte(); timeout--; + busy_wait(20); } while ((r != 0x00) && (timeout>0)); if(r!=0x00) return FAILURE;