mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode
SD cards don't support CMD7 (select_card) in SPI mode. Highspeed probe of sdspi will fail in this step and stop working in highspeed mode. Remove the CMD7 in enable_hs_mode_and_check to fix this issue. Please note that, on ESP32, you have to use the IOMUX pins to use sdspi in 40MHz, otherwise the initialization process will report reading issue and fail.
This commit is contained in:
parent
7abb8e7fc3
commit
7dfb6adf27
@ -225,25 +225,30 @@ esp_err_t sdmmc_enable_hs_mode_and_check(sdmmc_card_t* card)
|
||||
/* HS mode has been enabled on the card.
|
||||
* Read CSD again, it should now indicate that the card supports
|
||||
* 50MHz clock.
|
||||
* Since SEND_CSD is allowed only in standby mode, and the card is
|
||||
* currently in data transfer more, deselect the card first, then
|
||||
* get the CSD, then select the card again.
|
||||
* Since SEND_CSD is allowed only in standby mode, and the card is currently in data transfer
|
||||
* mode, deselect the card first, then get the CSD, then select the card again. This step is
|
||||
* not required in SPI mode, since CMD7 (select_card) is not supported.
|
||||
*/
|
||||
const bool is_spi = host_is_spi(card);
|
||||
if (!is_spi) {
|
||||
err = sdmmc_send_cmd_select_card(card, 0);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: select_card (1) returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = sdmmc_send_cmd_send_csd(card, &card->csd);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: send_csd returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
if (!is_spi) {
|
||||
err = sdmmc_send_cmd_select_card(card, card->rca);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: select_card (2) returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if (card->csd.tr_speed != 50000000) {
|
||||
ESP_LOGW(TAG, "unexpected: after enabling HS mode, tr_speed=%d", card->csd.tr_speed);
|
||||
|
@ -319,6 +319,8 @@ TEST_CASE("SDMMC read/write test (SD slot 1, in SPI mode)", "[sdspi][test_env=UT
|
||||
sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT();
|
||||
TEST_ESP_OK(sdspi_host_init());
|
||||
TEST_ESP_OK(sdspi_host_init_slot(config.slot, &slot_config));
|
||||
// This test can only run under 20MHz on ESP32, because the runner connects the card to
|
||||
// non-IOMUX pins of HSPI.
|
||||
sdmmc_card_t* card = malloc(sizeof(sdmmc_card_t));
|
||||
TEST_ASSERT_NOT_NULL(card);
|
||||
TEST_ESP_OK(sdmmc_card_init(&config, card));
|
||||
|
Loading…
Reference in New Issue
Block a user