From 42bfb90f14851bf781cc673dcb8f192b39e81e20 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 1 Jul 2020 12:40:23 +0200 Subject: [PATCH] liblitesdcard/sdcard: add SDCARD_MULTIPLE_BLOCK_SUPPORT define. --- litex/soc/software/liblitesdcard/sdcard.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index 4b9e8aef2..66a4c8765 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -19,6 +19,8 @@ //#define SDCARD_DEBUG #define SDCARD_WAIT_WORKAROUND +#define SDCARD_MULTIPLE_BLOCK_SUPPORT + #ifdef CSR_SDCORE_BASE unsigned int sdcard_response[SD_RESPONSE_SIZE/4]; @@ -491,11 +493,16 @@ void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf) sdreader_enable_write(1); /* Read Block(s) from SDCard */ +#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT sdcard_set_block_count(count); - if (count > 0) - sdcard_read_multiple_block(sector, count); - else + sdcard_read_multiple_block(sector, count); +#else + while (count) { sdcard_read_single_block(sector); + sector += 1; + count -= 1; + } +#endif /* Wait for DMA Writer to complete */ while ((sdreader_done_read() & 0x1) == 0); @@ -517,7 +524,9 @@ void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf) while ((sdwriter_done_read() & 0x1) == 0); /* Write Single Block to SDCard */ +#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT sdcard_set_block_count(1); +#endif sdcard_write_single_block(sector); /* Update buf/sector */