diff -r 89fc3c57282e -r e0f50087c909 main/task_sdcard.c --- a/main/task_sdcard.c Wed Jun 26 21:48:49 2024 +0200 +++ b/main/task_sdcard.c Fri Jun 28 15:33:24 2024 +0200 @@ -467,6 +467,7 @@ ESP_LOGI(TAG, "Start SD card"); sdmmc_host_t host = SDSPI_HOST_DEFAULT(); host.slot = SDCARD_HOST_SLOT; // HSPI_HOST is in use by the TFT. + host.max_freq_khz = 20000; // 20 MHz speed limit. spi_bus_config_t bus_cfg = { .mosi_io_num = SDCARD_PIN_NUM_MOSI, .miso_io_num = SDCARD_PIN_NUM_MISO, @@ -489,6 +490,18 @@ slot_config.host_id = host.slot; /* + * Since IDF 5.0 the SD card is dead slow. Use pullup resistors + * on the board, see schematic. + * Or just use gpio pullup as workaround. + * Or both (not tested). + * See https://github.com/espressif/esp-idf/issues/10493 + */ + gpio_set_pull_mode(SDCARD_PIN_NUM_MOSI, GPIO_PULLUP_ONLY); + gpio_set_pull_mode(SDCARD_PIN_NUM_MISO, GPIO_PULLUP_ONLY); + gpio_set_pull_mode(SDCARD_PIN_NUM_CLK, GPIO_PULLUP_ONLY); + gpio_set_pull_mode(SDCARD_PIN_NUM_CS, GPIO_PULLUP_ONLY); + + /* * No errors from the sdspi_transaction driver. */ esp_log_level_set("sdspi_transaction", ESP_LOG_NONE); @@ -506,10 +519,10 @@ ret = my_vfs_fat_sdspi_init("/sdcard", &host, &slot_config); if (ret == ESP_OK) { - ESP_LOGI(TAG, "SPI card interface ready"); + ESP_LOGI(TAG, "SD card interface ready"); sdcard_state->host_ok = true; } else { - ESP_LOGE(TAG, "SPI card interface failed, abort task"); + ESP_LOGE(TAG, "SD card interface failed: %s, abort task", esp_err_to_name(ret)); vTaskDelete(NULL); return; }