From c071bb4ac7b23312548d2095c5c8e2802bb4f118 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 16 Mar 2021 12:44:00 +0100 Subject: [PATCH] software/liblitesdcard: Check sdcard_wait_data_done in sdcard_switch/sdcard_app_send_scr since requesting a data read transfer. --- litex/soc/software/liblitesdcard/sdcard.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index 1cb74b4a4..48203d2eb 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -218,9 +218,10 @@ int sdcard_switch(unsigned int mode, unsigned int group, unsigned int value) { #endif sdcore_block_length_write(64); sdcore_block_count_write(1); - return sdcard_send_command(arg, 6, + while (sdcard_send_command(arg, 6, (SDCARD_CTRL_DATA_TRANSFER_READ << 5) | - SDCARD_CTRL_RESPONSE_SHORT); + SDCARD_CTRL_RESPONSE_SHORT) != SD_OK); + return sdcard_wait_data_done(); } int sdcard_app_send_scr(void) { @@ -229,9 +230,10 @@ int sdcard_app_send_scr(void) { #endif sdcore_block_length_write(8); sdcore_block_count_write(1); - return sdcard_send_command(0, 51, + while (sdcard_send_command(0, 51, (SDCARD_CTRL_DATA_TRANSFER_READ << 5) | - SDCARD_CTRL_RESPONSE_SHORT); + SDCARD_CTRL_RESPONSE_SHORT) != SD_OK); + return sdcard_wait_data_done(); } int sdcard_app_set_blocklen(unsigned int blocklen) {