Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdmmc_host_t max_freq_khz limitation breaks SD card compatibility (IDFGH-14477) #15250

Open
2 of 3 tasks
KenVanHoeylandt opened this issue Jan 21, 2025 · 2 comments
Open
2 of 3 tasks
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@KenVanHoeylandt
Copy link

KenVanHoeylandt commented Jan 21, 2025

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.3.2 and earlier

Espressif SoC revision.

ESP32, ESP32-S3

Operating System used.

Linux

How did you build your project?

Command line with CMake

If you are using Windows, please specify command line type.

None

Development Kit.

LilyGo T-Deck, M5Stack Core2, CYD 2432S024C, unPhone

Power Supply used.

USB

What is the expected behavior?

When setting the sdmmc_host_t::max_freq_khz to a value that is higher than allowed, the firmware automatically limits the frequency to 20 MHz as expected. This is reported in the idf.py monitor output.

However, as a side-effect, SD card compatibility is broken for most SD cards. I tried various SDHC cards from various brands and sizes (all SDHC) and only could get 1 card working.

When setting max_freq_khz to 20000 then all devices work fine and all SD cards are detected as normal.

 sdmmc_host_t host = SDSPI_HOST_DEFAULT();
 host.max_freq_khz = config->spiFrequencyKhz; // uint32_t with the value 800000
 host.slot = config->spiHost;

What is the actual behavior?

There should not be a side-effect that breaks compatibility, as all the cards work fine when setting 20 MHz manually.

Steps to reproduce.

  1. Create host config: sdmmc_host_t host = SDSPI_HOST_DEFAULT();
  2. Override frequency with unusually high value host.max_freq_khz = 800000; // 800 MHz!
  3. Boot firmware and observe in monitor log that the frequency input was limited to 20 MHz
  4. Observe how many/most SD cards don't mount anymore.
  5. Change frequency manually to host.max_freq_khz = 20000; // 20 MHz
  6. Observe how previously problematic SD cards now work fine

Debug Logs.


More Information.

I have not updated to ESP-IDF 5.4 yet, but I expect to do that in the coming month.

@KenVanHoeylandt KenVanHoeylandt added the Type: Bug bugs in IDF label Jan 21, 2025
@github-actions github-actions bot changed the title sdmmc_host_t max_freq_khz limitation breaks SD card compatibility sdmmc_host_t max_freq_khz limitation breaks SD card compatibility (IDFGH-14477) Jan 21, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 21, 2025
@adokitkat
Copy link
Collaborator

adokitkat commented Jan 23, 2025

Hello. Could you please provide a log from idf.py monitor with log level set to debug and your sdkconfig file here please?

@KenVanHoeylandt
Copy link
Author

I've attached everything you asked, but here's a summary:

With host.max_freq_khz = 800000; and that 1 SD card that I got working:

Name: SD32G
Type: SDHC/SDXC
Speed: 20.00 MHz (limit: 20.00 MHz)
Size: 30436MB
CSD: ver=2, sector_size=512, capacity=62333952 read_bl_len=9
SSR: bus_width=1

With host.max_freq_khz = 800000; and rare compatible SD card:

E (1336) sdmmc_sd: sdmmc_enable_hs_mode_and_check: send_csd returned 0x108
E (1336) vfs_fat_sdmmc: sdmmc_card_init failed (0x108).
HINT: Please verify if there is an SD card inserted into the SD slot. Then, try rebooting the board.
I (1338) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
E (1348) spi_sdcard: Mounting failed (ESP_ERR_INVALID_RESPONSE)
E (1354) spi_sdcard: Mount failed for /sdcard
W (1359) hal: SD card mount failed (init can continue)

The monitor.txt attached is also with host.max_freq_khz = 800000 and with one of the many problematic SD cards.

monitor.txt
sdkconfig.board.lilygo-tdeck.txt
sdkconfig.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants