Skip to content

Commit c4a3c1f

Browse files
committed
fix(sdmmc): fix sdmmc initialization issue in caused by CMD52 CRC error
1 parent ffebb32 commit c4a3c1f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

components/sdmmc/sdmmc_io.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ esp_err_t sdmmc_io_reset(sdmmc_card_t* card)
6666
{
6767
uint8_t sdio_reset = CCCR_CTL_RES;
6868
esp_err_t err = sdmmc_io_rw_direct(card, 0, SD_IO_CCCR_CTL, SD_ARG_CMD52_WRITE, &sdio_reset);
69-
if (err == ESP_ERR_TIMEOUT || (host_is_spi(card) && err == ESP_ERR_NOT_SUPPORTED)) {
69+
if (err == ESP_ERR_TIMEOUT || (host_is_spi(card) && err == ESP_ERR_NOT_SUPPORTED) || err == ESP_ERR_INVALID_CRC) {
7070
/* Non-IO cards are allowed to time out (in SD mode) or
7171
* return "invalid command" error (in SPI mode).
72+
* CRC errors are also allowed as the card may be in a state where
73+
* CRC is enabled from a previous session, especially after ESP32 restart
74+
* without power cycling the SD card.
7275
*/
7376
} else if (err == ESP_ERR_NOT_FOUND) {
7477
ESP_LOGD(TAG, "%s: card not present", __func__);

0 commit comments

Comments
 (0)