software/libbase/spisdcard: add delay to goidle loop
authorGabriel Somlo <gsomlo@gmail.com>
Fri, 27 Mar 2020 11:01:02 +0000 (07:01 -0400)
committerGabriel Somlo <gsomlo@gmail.com>
Fri, 27 Mar 2020 19:24:09 +0000 (15:24 -0400)
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 <gsomlo@gmail.com>
litex/soc/software/libbase/spisdcard.c

index 0befe993b518d1a8dfc2495f039b0e742257dec3..ab6cbe0398405de7debe6b87e640b935434323eb 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
+#include <system.h>
 
 #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;