ESP32 and SDMMC working only in 1 bit
Posted: Tue Jul 26, 2022 9:02 pm
Hello all!
I am trying since several weeks to get working a Micro SD card peripheral with a ESP32-DevKitCVIE.
Here is the layout of my PCB, on the right is the peripheral with the pin names for SDIO:
I checked everything and 10K pull-ups are set up everywhere, with following connections:
Here is the portion of code that mount the SD card:
I have formatted 2 different Micro SD cards (SDHC ones) using the official SD tool. One is 16GB, the other one is 32GB.
Results of my tests are the following:
With this configuration, results of test are the following:
In logs, notably, I see a interrupt that is setup on GPIO13:
Thanks in advance for your help!
I am trying since several weeks to get working a Micro SD card peripheral with a ESP32-DevKitCVIE.
Here is the layout of my PCB, on the right is the peripheral with the pin names for SDIO:
I checked everything and 10K pull-ups are set up everywhere, with following connections:
- CLK => IO14
- CMD => IO15
- D0 => IO2
- D1 => IO4
- D3 => IO13
- Dat2 => IO12
- DET => not connected
Here is the portion of code that mount the SD card:
Code: Select all
esp_vfs_fat_sdmmc_mount_config_t mount_config;
mount_config.max_files = 5;
mount_config.format_if_mount_failed = true;
mount_config.allocation_unit_size = 2 * 1024;
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
host.slot = SDMMC_HOST_SLOT_1;
host.max_freq_khz = SDMMC_FREQ_DEFAULT;
// host.max_freq_khz = SDMMC_FREQ_PROBING;
// This initializes the slot without card detect (CD) and write protect (WP) signals.
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
// To use 1-line SD mode, change this to 1:
slot_config.width = 4;
// Enable internal pullups on enabled pins. The internal pullups
// are insufficient however, please make sure 10k external pullups are
// connected on the bus. This is for debug / example purpose only.
// slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
// Disabling all pull down on GPIO pins used for SDIO slot 1 : 2, 4, 12, 13, 14, 15
gpio_pulldown_dis(GPIO_NUM_2);
gpio_pulldown_dis(GPIO_NUM_4);
gpio_pulldown_dis(GPIO_NUM_12);
gpio_pulldown_dis(GPIO_NUM_13);
gpio_pulldown_dis(GPIO_NUM_14);
gpio_pulldown_dis(GPIO_NUM_15);
esp_vfs_fat_sdmmc_mount(mountPoint.data(), &host, &slot_config, &mount_config, &card);
Results of my tests are the following:
- 16GB card, with host.max_freq_khz = SDMMC_FREQ_DEFAULT (= 20 MHz)=> failure (sdmmc_req: process_data_status: error 0x109 (status=00000080))
- 32GB card, frequency SDMMC_FREQ_DEFAULT => same failure
- 16 GB card, with host.max_freq_khz = SDMMC_FREQ_PROBING (= 400 KHz) => success
- 32GB card, frequency SDMMC_FREQ_PROBING => failure
Code: Select all
host.flags = SDMMC_HOST_FLAG_1BIT;
- 16 GB card, with host.max_freq_khz = SDMMC_FREQ_PROBING (= 400 KHz) => success
- 16GB card, with host.max_freq_khz = SDMMC_FREQ_DEFAULT (= 20 MHz)=> success!
- 32GB card, frequency SDMMC_FREQ_DEFAULT => success!
In logs, notably, I see a interrupt that is setup on GPIO13:
can this be the cause of my troubles?I (8114) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Thanks in advance for your help!