diff --git a/components/sdmmc/sdmmc_cmd.c b/components/sdmmc/sdmmc_cmd.c index 6aaf7098f0..9b08c3751b 100644 --- a/components/sdmmc/sdmmc_cmd.c +++ b/components/sdmmc/sdmmc_cmd.c @@ -600,6 +600,20 @@ esp_err_t sdmmc_erase_sectors(sdmmc_card_t* card, size_t start_sector, ESP_LOGE(TAG, "%s: sdmmc_send_cmd returned 0x%x", __func__, err); return err; } + + if (host_is_spi(card)) { + uint32_t status; + err = sdmmc_send_cmd_send_status(card, &status); + if (err != ESP_OK) { + return err; + } + if (status != 0) { + ESP_LOGE(TAG, "%s: card status indicates an error after erase operation: r2=0x%04x", + __func__, status); + return ESP_ERR_INVALID_RESPONSE; + } + } + return ESP_OK; } diff --git a/components/sdmmc/test/test_sd.c b/components/sdmmc/test/test_sd.c index 0feaf0f231..1054efe333 100644 --- a/components/sdmmc/test/test_sd.c +++ b/components/sdmmc/test/test_sd.c @@ -869,10 +869,6 @@ static void test_sdspi_erase_blocks(size_t start_block, size_t block_count) float time_er = 1e3f * (t_stop_wr.tv_sec - t_start_er.tv_sec) + 1e-3f * (t_stop_wr.tv_usec - t_start_er.tv_usec); printf("Erase duration: %.2fms\n", time_er); - // nominal delay before re-init card - vTaskDelay(pdMS_TO_TICKS(1000)); - // has to re-init card, after erase operation. - TEST_ESP_OK(sdmmc_card_init(&config, card)); printf("Verifying erase state...\n"); uint8_t erase_mem_byte = 0xFF; // ensure all the blocks are erased and are up to after erase state.