ESP32 and SDMMC working only in 1 bit

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

ESP32 and SDMMC working only in 1 bit

Postby jpquan » 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:

Image

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
As IO2 needs to be attached to GND for Flashing, I have a switch on the board to switch it back to pull-up when flashing is done.

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);
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:
  • 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
So I tried to reduce the width of the SDIO, by using the following flag:

Code: Select all

    host.flags = SDMMC_HOST_FLAG_1BIT;
With this configuration, results of test are the following:
  • 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!
So it seems I have something wrong either in my GPIO config or in my wiring. Wiring seems correct though, so is there somebody who can help me and tell me what is wrong here?

In logs, notably, I see a interrupt that is setup on GPIO13:
I (8114) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
can this be the cause of my troubles?

Thanks in advance for your help!

ESP_LJH
Posts: 387
Joined: Tue May 18, 2021 9:21 am

Re: ESP32 and SDMMC working only in 1 bit

Postby ESP_LJH » Wed Jul 27, 2022 10:00 am

Since GPIO12 is pulled high, when you use then module, do you burn efuse to set VDDSDIO to 3.3 V?

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

Re: ESP32 and SDMMC working only in 1 bit

Postby jpquan » Wed Jul 27, 2022 7:58 pm

Hello! Thank you for answering!

Short answer is: no.

Longer answer is: well I did some research upon your question. It appears that, following WROVER-IE datasheet (available here), the effect of my pull-up on GPIO12 is to have MTDI at 1 at reset, thus selecting VDD_SDIO to 1.8V. Hoping I am on the right datasheet :roll:

It also appears that this same datasheet states :"Internal pull-up resistor (R9) for MTDI is not populated in the module, as the flash and SRAM in the module only support a power voltage of 3.3 V (output by VDD_SDIO)."

This would suggest 2 continuations, please help me to continue my quest :?: :
  • My system seems to run with Voltage of Internal LDO at 1.8V that should prevent flash and SRAM to work; though my setup works OK (I use other functions like connection to Wifi, etc and the system will run OK), why?
  • Another documentation (esp32_datasheet) state that GPIO12 runs in VDD3P3_RTC anyway, to 3.3V, which means that it should not be affected by VDD_SDIO running 1.8 or 3.3; so I see no exact solution in this direction or do I miss something here?
I understand that by eFusing VDD_SDIO to 3.3 my system would then run with the "correct" VDD_SDIO, whatever the pull-up on GPIO12. But I do not see why it may solve my SDIO / slot 1 issue, can you explain?

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 and SDMMC working only in 1 bit

Postby chegewara » Wed Jul 27, 2022 10:37 pm

https://docs.espressif.com/projects/esp ... l#overview
In old esp32 SDMMC driver in 1-bit mode allows to assign any pins with IOMUX, n-bit mode (slot 0) does not allow that (hardware limitation):
Screenshot from 2022-07-28 00-34-56.png
Screenshot from 2022-07-28 00-34-56.png (33.23 KiB) Viewed 6165 times

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

Re: ESP32 and SDMMC working only in 1 bit

Postby jpquan » Thu Jul 28, 2022 8:23 pm

Well yes I am using Slot 1 and on this version of ESP32 I have to use the one listed on the table, which I do.

I did some tests today using a switch on GPIO12, so that it is floating at boot, then I connect it to D2 of the SD Card, and this produced no change at all: still not working in 4 bits mode on Slot 1 for the 32 GB card.

Any clue anyone?

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

Re: ESP32 and SDMMC working only in 1 bit

Postby jpquan » Fri Jul 29, 2022 7:38 pm

Hello! Some news on SDIO / Micro SD Card & 4 bits.

I have 2 ESP 32, one on a PCB (layout was posted at start) and another one on a breadboard.

On the breadboard so far it did not work at all, but checking it today I realized that I had no pull-up on the CLK of the Micro SD peripheral; adding a 10K pull-up here made that work in 20 MHz & 4 bits! So solution on the breadboard is to pull-up all 6 pins (CLK, CMD, D0, D1, D2, D3).

On the PCB everything is pulled-up at 10K and still it does not work in 4 bits (only in 1 bit). So I wonder if 20 MHz may require some particular track width? I did the PCB with 0.254mm track width.

Would anybody have any advice, given this information?

Thanks!

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 and SDMMC working only in 1 bit

Postby chegewara » Mon Aug 01, 2022 6:07 am

Time to use oscilloscope?

ESP_LJH
Posts: 387
Joined: Tue May 18, 2021 9:21 am

Re: ESP32 and SDMMC working only in 1 bit

Postby ESP_LJH » Mon Aug 01, 2022 9:01 am

Could you send layout again? I could not see it.

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

Re: ESP32 and SDMMC working only in 1 bit

Postby jpquan » Fri Aug 05, 2022 10:55 am

chegewara wrote:
Mon Aug 01, 2022 6:07 am
Time to use oscilloscope?
Yes I am going to use my brand new Hantek 6022BL ... keep you posted! :)

jpquan
Posts: 11
Joined: Wed Feb 09, 2022 10:04 am

Re: ESP32 and SDMMC working only in 1 bit

Postby jpquan » Fri Aug 05, 2022 10:55 am

ESP_LJH wrote:
Mon Aug 01, 2022 9:01 am
Could you send layout again? I could not see it.
You should be able to see the layout at this URL: http://drive.google.com/uc?export=view& ... hYeLukFc8N

Maybe my SDIO tracks are too close from each other??

Who is online

Users browsing this forum: No registered users and 32 guests