From b333d4c703b30cabcb7d3e5fd4c5a830eadcf8a9 Mon Sep 17 00:00:00 2001 From: Larry Bernstone Date: Mon, 17 Nov 2025 11:59:43 -1000 Subject: [PATCH 1/3] feat(sd_mmc): Make UHS-I SDR the default for ESP-P4 SD_MMC --- libraries/SD_MMC/src/SD_MMC.cpp | 4 ++++ libraries/SD_MMC/src/SD_MMC.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libraries/SD_MMC/src/SD_MMC.cpp b/libraries/SD_MMC/src/SD_MMC.cpp index 12ab2b565eb..a76377d321d 100644 --- a/libraries/SD_MMC/src/SD_MMC.cpp +++ b/libraries/SD_MMC/src/SD_MMC.cpp @@ -246,6 +246,10 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_ .width = 4, .flags = 0, }; +#ifdef SOC_SDMMC_UHS_I_SUPPORTED + host.flags &= ~SDMMC_HOST_FLAG_DDR; + slot_config.flags = SDMMC_SLOT_FLAG_UHS1; +#endif #else host.slot = SDMMC_HOST_SLOT_1; #endif diff --git a/libraries/SD_MMC/src/SD_MMC.h b/libraries/SD_MMC/src/SD_MMC.h index 7192d466b89..e20c6ccfaa9 100644 --- a/libraries/SD_MMC/src/SD_MMC.h +++ b/libraries/SD_MMC/src/SD_MMC.h @@ -30,8 +30,12 @@ // you can define BOARD_MAX_SDMMC_FREQ with lower value (Ex. SDMMC_FREQ_DEFAULT) // in pins_arduino.h for your board variant. #ifndef BOARD_MAX_SDMMC_FREQ +#ifdef SOC_SDMMC_UHS_I_SUPPORTED +#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_SDR50 +#else #define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_HIGHSPEED #endif +#endif namespace fs { From bca5f68a172fc846fd4958e3519d40c3742237b9 Mon Sep 17 00:00:00 2001 From: Larry Bernstone Date: Sat, 6 Dec 2025 12:11:46 -1000 Subject: [PATCH 2/3] Allow setting DDR, and only enable UHS for higher frequencies --- .../SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino | 20 +++++++++++++++++++ libraries/SD_MMC/src/SD_MMC.cpp | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino b/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino index e03f5ceb25e..ffa8160be77 100644 --- a/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino +++ b/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino @@ -211,6 +211,25 @@ void testFileIO(fs::FS &fs, const char *path) { file.close(); } +void testRawIO(uint32_t sectors, uint8_t sequential) { + uint32_t readSect = 0; + uint32_t startTime = millis(); + uint8_t* buf = (uint8_t*)heap_caps_malloc(SD_MMC.sectorSize(), MALLOC_CAP_DMA); + for (uint32_t x=0; x Date: Sat, 6 Dec 2025 12:22:39 -1000 Subject: [PATCH 3/3] Fix indentation --- libraries/SD_MMC/src/SD_MMC.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/SD_MMC/src/SD_MMC.cpp b/libraries/SD_MMC/src/SD_MMC.cpp index dd7c92eb077..5d15c12d7f4 100644 --- a/libraries/SD_MMC/src/SD_MMC.cpp +++ b/libraries/SD_MMC/src/SD_MMC.cpp @@ -247,13 +247,13 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_ .flags = 0, }; #ifdef SOC_SDMMC_UHS_I_SUPPORTED -if (sdmmc_frequency == SDMMC_FREQ_DDR50) { - host.flags |= SDMMC_HOST_FLAG_DDR; - slot_config.flags = SDMMC_SLOT_FLAG_UHS1; -} -if (sdmmc_frequency == SDMMC_FREQ_SDR50) { - slot_config.flags = SDMMC_SLOT_FLAG_UHS1; -} + if (sdmmc_frequency == SDMMC_FREQ_DDR50) { + host.flags |= SDMMC_HOST_FLAG_DDR; + slot_config.flags = SDMMC_SLOT_FLAG_UHS1; + } + if (sdmmc_frequency == SDMMC_FREQ_SDR50) { + slot_config.flags = SDMMC_SLOT_FLAG_UHS1; + } #endif #else host.slot = SDMMC_HOST_SLOT_1;