diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index f3108f8ac..abf8e7dbd 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -728,7 +728,8 @@ DSTATUS disk_status(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) { if (drv) return STA_NOINIT; - sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; + if (sdcardstatus) + sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; return sdcardstatus; } diff --git a/litex/soc/software/liblitesdcard/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c index 510c34fe7..7131d0830 100644 --- a/litex/soc/software/liblitesdcard/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -277,8 +277,10 @@ DSTATUS disk_status(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) { if (drv) return STA_NOINIT; - spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; - spisdcard_deselect(); + if (spisdcardstatus) { + spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; + spisdcard_deselect(); + } return spisdcardstatus; }