feat(sd_mmc) Make UHS-I SDR the default for ESP-P4 SD_MMC#12038
feat(sd_mmc) Make UHS-I SDR the default for ESP-P4 SD_MMC#12038lbernstone wants to merge 3 commits intoespressif:masterfrom
Conversation
👋 Hello lbernstone, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Test Results 83 files 83 suites 26m 19s ⏱️ For more details on these failures, see this check. Results for commit 4716fc0. ♻️ This comment has been updated with latest results. |
|
Please add a check for IDF versions greater than 5.3: https://github.com/espressif/arduino-esp32/actions/runs/19442524813/job/55629051409?pr=12038 |
c38ee43 to
b333d4c
Compare
|
On P4 EV Board card is no longer mounting with the changes in PR. |
|
@lbernstone If I comment out the UHS-1 flag, the sdmmc starts working again and the speed is improved with the DDR flag only. |
|
@P-R-O-C-H-Y What kind of SD card do you have? |
Its a Kingston 16GB with USH-1 marking on it. |
|
Weird is, that the SD card is not working on the P4-EYE board I got. Even with/without the changes in this PR. |
|
Can you try to format it using some SD-format tool? |
|
The P4-eye have identical SD card schema as the P4-EV board. Will try with formatted card and also with different one. |
|
Maybe also try some SDHC/SDXC card? |
|
in all cases, we want to support more cards, not less. If these options make cards not work, we need to make them optional |
|
I'm not sure if SDHC uses DDR signalling. Looking here: https://www.sdcard.org/developers/sd-standard-overview/bus-speed-default-speed-high-speed-uhs-sd-express/ |
|
I'll see if I can find some old cards around here and test an array of them. Not sure if I have really small & slow ones around any more. |
P4-eye (waveshare) has BOARD_SDMMC_POWER_PIN on 46 |
|
Hmm I took another look at the source code of this PR and host.flags &= ~SDMMC_HOST_FLAG_DDR;looks like it is disabling DDR? If it is indeed increasing the transfer speed, then it sounds like a timing issue, or maybe some signal is inverted? |
|
Hmm these defines for sure would be a lot more clear with quite a bit more comments... #define SDMMC_FREQ_DEFAULT 20000 /*!< SD/MMC Default speed (limited by clock divider) */
#define SDMMC_FREQ_HIGHSPEED 40000 /*!< SD High speed (limited by clock divider) */
#define SDMMC_FREQ_PROBING 400 /*!< SD/MMC probing speed */
#define SDMMC_FREQ_52M 52000 /*!< MMC 52MHz speed */
#define SDMMC_FREQ_26M 26000 /*!< MMC 26MHz speed */
#define SDMMC_FREQ_DDR50 50000 /*!< MMC 50MHz speed */
#define SDMMC_FREQ_SDR50 100000 /*!< MMC 100MHz speed */
#define SDMMC_FREQ_SDR104 200000 /*!< MMC 200MHz speed */The names of those defines don't appear to match the frequency numbers. Then the most important change of this PR is setting the clock? |
Yes, you should be able to force to lower rates by setting a lower frequency, and the PR as written sets SDR (by turning DDR off). But, I do think the process should be backwards compatible, such that if the fastest speed fails, it drops down to try to init at a rate that the card understands, like happens transparently on your PC. I just don't have the hardware available to code & test that. |
|
Ok, the dev board I got doesn't break out the SDIO pins, so I still have no way to test the old (standard SD) cards I have. Does anybody have old microsd cards and a working P4 that can test if the code as written fails back to lower rates automatically? Ideally, it needs to be tested on a non-UHS SDHC (eg 4GB), and then an old 64MB capacity card. |
That would be extremely hard to find, as I have never seen non-SDHC cards in the micro-SD ("TF") format. |
|
The thing that really needs to be tested is if this works on a device that is not capable of 1V8 operation. |
Description of Change
SD_MMC driver had been updated to support UHS-I on ESP-P4, but didn't have the flags quite right. This updates the driver to use UHS SDR by default.
Test Scenarios
ESP32-P4-EYE reading a file off SD card. Speed is improved about 300%.
Related links
Should close #12027