From 1b0eef38fe63e99634d006748d8aa3496bbdff29 Mon Sep 17 00:00:00 2001 From: "sonika.rathi" Date: Tue, 24 Jun 2025 13:48:38 +0200 Subject: [PATCH] fix(sdmmc): fix sdmmc initialization issue in caused by CMD52 CRC error --- components/sdmmc/sdmmc_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/sdmmc/sdmmc_io.c b/components/sdmmc/sdmmc_io.c index 90051111ee..76170fd18f 100644 --- a/components/sdmmc/sdmmc_io.c +++ b/components/sdmmc/sdmmc_io.c @@ -66,9 +66,12 @@ esp_err_t sdmmc_io_reset(sdmmc_card_t* card) { uint8_t sdio_reset = CCCR_CTL_RES; esp_err_t err = sdmmc_io_rw_direct(card, 0, SD_IO_CCCR_CTL, SD_ARG_CMD52_WRITE, &sdio_reset); - if (err == ESP_ERR_TIMEOUT || (host_is_spi(card) && err == ESP_ERR_NOT_SUPPORTED)) { + if (err == ESP_ERR_TIMEOUT || (host_is_spi(card) && err == ESP_ERR_NOT_SUPPORTED) || err == ESP_ERR_INVALID_CRC) { /* Non-IO cards are allowed to time out (in SD mode) or * return "invalid command" error (in SPI mode). + * CRC errors are also allowed as the card may be in a state where + * CRC is enabled from a previous session, especially after ESP32 restart + * without power cycling the SD card. */ } else if (err == ESP_ERR_NOT_FOUND) { ESP_LOGD(TAG, "%s: card not present", __func__);