MicroSD hangup
Posted: Wed Nov 14, 2018 10:43 am
Hi,
I've got a little problem and maybe someone of you has more experience working with MicroSD cards.
I'm initializing the MicroSD like this:
The errors occuring would be bearable but I need a dead safe way to reset the MicroSD into a working state.
I've got a little problem and maybe someone of you has more experience working with MicroSD cards.
I'm initializing the MicroSD like this:
I'm accessing the MicroSD only via fopen/fwrite/fflush/fclose and after some random time (sometimes days sometimes hours) it stops working. Soft reset via esp_restart does not fix the error and on next boot I get:#define DEVICE_MICROSD_MISO GPIO_NUM_26;
#define DEVICE_MICROSD_MOSI GPIO_NUM_25;
#define DEVICE_MICROSD_SCK GPIO_NUM_33;
#define DEVICE_MICROSD_CS GPIO_NUM_32;
void DeviceManager::initSD() {
sdmmc_host_t hostConfig;
memset(&hostConfig, 0, sizeof(hostConfig));
hostConfig.flags = SDMMC_HOST_FLAG_SPI;
hostConfig.slot = VSPI_HOST;
hostConfig.max_freq_khz = SDMMC_FREQ_DEFAULT;
hostConfig.io_voltage = 3.3f;
hostConfig.init = &sdspi_host_init;
hostConfig.set_bus_width = NULL;
hostConfig.set_card_clk = &sdspi_host_set_card_clk;
hostConfig.do_transaction = &sdspi_host_do_transaction;
hostConfig.deinit = &sdspi_host_deinit;
hostConfig.command_timeout_ms = 0;
sdspi_slot_config_t slotConfig;
memset(&slotConfig, 0, sizeof(slotConfig));
slotConfig.gpio_miso = DEVICE_MICROSD_MISO;
slotConfig.gpio_mosi = DEVICE_MICROSD_MOSI;
slotConfig.gpio_sck = DEVICE_MICROSD_SCK;
slotConfig.gpio_cs = DEVICE_MICROSD_CS;
slotConfig.gpio_cd = SDMMC_SLOT_NO_CD;
slotConfig.gpio_wp = SDMMC_SLOT_NO_WP;
slotConfig.dma_channel = 1;
esp_vfs_fat_sdmmc_mount_config_t mountConfig;
memset(&mountConfig, 0, sizeof(mountConfig));
mountConfig.format_if_mount_failed = true;
mountConfig.max_files = 10;
mountConfig.allocation_unit_size = 0; // sector size
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sd", &hostConfig, &slotConfig, &mountConfig, &this->microSDCard);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(LOGTAG, "esp_vfs_fat_sdmmc_mount failed");
} else {
ESP_LOGE(LOGTAG, "Initializing MicroSD card failed with error: %d", ret);
}
return;
}
}
This leaves me to believe that the MicroSD is in an invalid state because once I disconnect power and connect power again it is working again, again for a longer period.E (203) DeviceManager: Mounting MicroSD card
E (203) sdmmc_io: sdmmc_io_reset: unexpected return: 0x104
E (203) DeviceManager: Initializing MicroSD card failed with error: 260
The errors occuring would be bearable but I need a dead safe way to reset the MicroSD into a working state.