Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(sd_mmc) Make UHS-I SDR the default for ESP-P4 SD_MMC#12038

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
lbernstone wants to merge3 commits intoespressif:master
base:master
Choose a base branch
Loading
fromlbernstone:sdmmc_uhs

Conversation

@lbernstone
Copy link
Contributor

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

Shouldclose#12027

@lbernstonelbernstone requested a review froma team as acode ownerNovember 17, 2025 19:47
@github-actions
Copy link
Contributor

github-actionsbot commentedNov 17, 2025
edited
Loading

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message"Allow setting DDR, and only enable UHS for higher frequencies":
    • summary looks empty
    • type/action looks empty
  • the commit message"Fix indentation":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • followConventional Commits style
  • correct format of commit message should be:<type/action>(<scope/component>): <summary>, for examplefix(esp32): Fixed startup timeout issue
  • allowed types are:change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses theConventional Precommit Linter).

👋Hello lbernstone, we appreciate your contribution to this project!


📘 Please review the project'sContributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you haveread and signed theContributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by thePR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with eachpush event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger isnot a substitute for human code reviews; it's still important to request a code review from your colleagues.
-Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manuallyretry these Danger checks, please navigate to theActions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫dangerJS against4716fc0

@github-actions
Copy link
Contributor

github-actionsbot commentedNov 17, 2025
edited
Loading

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.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32P40⚠️ +7060.00⚠️ +0.17000.000.00
ESP32S30⚠️ +4760.00⚠️ +0.13000.000.00
ESP320⚠️ +7120.00⚠️ +0.190⚠️ +1080.00⚠️ +0.49
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32P4ESP32S3ESP32
ExampleFLASHRAMFLASHRAMFLASHRAM
libraries/ESP_I2S/examples/Record_to_WAV⚠️ +1600000
libraries/SD_MMC/examples/SD2USBMSC⚠️ +16000--
libraries/SD_MMC/examples/SDMMC_Test⚠️ +7060⚠️ +4760⚠️ +712⚠️ +108
libraries/SD_MMC/examples/SDMMC_time⚠️ +1600000

@github-actions
Copy link
Contributor

github-actionsbot commentedNov 17, 2025
edited
Loading

Test Results

 83 files   83 suites   26m 19s ⏱️
 55 tests  54 ✅ 0 💤 1 ❌
598 runs  597 ✅ 0 💤 1 ❌

For more details on these failures, seethis check.

Results for commit4716fc0.

♻️ This comment has been updated with latest results.

@lucasssvaz
Copy link
Member

Please add a check for IDF versions greater than 5.3:

https://github.com/espressif/arduino-esp32/actions/runs/19442524813/job/55629051409?pr=12038

@P-R-O-C-H-YP-R-O-C-H-Y self-requested a reviewNovember 18, 2025 07:41
@P-R-O-C-H-Y
Copy link
Member

On P4 EV Board card is no longer mounting with the changes in PR.

@P-R-O-C-H-Y
Copy link
Member

@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-YP-R-O-C-H-Y added Status: In Progress ⚠️Issue is in progress Area: LibrariesIssue is related to Library support. labelsNov 18, 2025
@TD-er
Copy link
Contributor

@P-R-O-C-H-Y What kind of SD card do you have?
Does it have UHS markings on the card or is it just a SDHC/SDXC card? (or even just SD, which is really a collectors item these days)

@P-R-O-C-H-Y
Copy link
Member

@P-R-O-C-H-Y What kind of SD card do you have? Does it have UHS markings on the card or is it just a SDHC/SDXC card? (or even just SD, which is really a collectors item these days)

Its a Kingston 16GB with USH-1 marking on it.

@P-R-O-C-H-Y
Copy link
Member

Weird is, that the SD card is not working on the P4-EYE board I got. Even with/without the changes in this PR.

@TD-er
Copy link
Contributor

Can you try to format it using some SD-format tool?
Or format it using some non-PC device like a camera.
It might be the partitioning is unconventional and/or the file system already present is not supported by the libraries we use.
Or maybe the "P4 EYE" doesn't use all 4 pins? For example DAT3 is wired as card detection?

@P-R-O-C-H-Y
Copy link
Member

The P4-eye have identical SD card schema as the P4-EV board. Will try with formatted card and also with different one.

@TD-er
Copy link
Contributor

Maybe also try some SDHC/SDXC card?
Those UHS cards may want to negotiate a lower signal level of 1V8. Not sure if this is expected or required. I know it is a feature of the standard.

@me-no-dev
Copy link
Member

in all cases, we want to support more cards, not less. If these options make cards not work, we need to make them optional

Jason2866 reacted with thumbs up emoji

@TD-er
Copy link
Contributor

I'm not sure if SDHC uses DDR signalling.
If I'm not mistaken, this was initially only a protocol update to support cards > 2 GB.
There is a "high speed" variant for SDHC/XC/UC which doubles the bus speed, so I guess that does look like DDR.

Looking here:https://www.sdcard.org/developers/sd-standard-overview/bus-speed-default-speed-high-speed-uhs-sd-express/
I see there is a 50 MHz and 104 MHz signalling for UHS-I, where there doesn't seem to be a DDR104.
I have no idea what frequency is being used here?

@lbernstone
Copy link
ContributorAuthor

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.

@lbernstone
Copy link
ContributorAuthor

lbernstone commentedNov 18, 2025
edited
Loading

Weird is, that the SD card is not working on the P4-EYE board I got. Even with/without the changes in this PR.

P4-eye (waveshare) has BOARD_SDMMC_POWER_PIN on 46

@TD-er
Copy link
Contributor

TD-er commentedNov 18, 2025
edited
Loading

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 so then I am quite curious to why it is improving the speed.

If it is indeed increasing the transfer speed, then it sounds like a timing issue, or maybe some signal is inverted?

@TD-er
Copy link
Contributor

Hmm these defines for sure would be a lot more clear with quite a bit more comments...
https://github.com/espressif/esp-idf/blob/8f1e7bc4e08878f5a2aab55fdf302789d3a3eac4/components/sdmmc/include/sd_protocol_types.h#L198-L205

#defineSDMMC_FREQ_DEFAULT20000/*!< SD/MMC Default speed (limited by clock divider)*/#defineSDMMC_FREQ_HIGHSPEED40000/*!< SD High speed (limited by clock divider)*/#defineSDMMC_FREQ_PROBING400/*!< SD/MMC probing speed*/#defineSDMMC_FREQ_52M52000/*!< MMC 52MHz speed*/#defineSDMMC_FREQ_26M26000/*!< MMC 26MHz speed*/#defineSDMMC_FREQ_DDR5050000/*!< MMC 50MHz speed*/#defineSDMMC_FREQ_SDR50100000/*!< MMC 100MHz speed*/#defineSDMMC_FREQ_SDR104200000/*!< MMC 200MHz speed*/

The names of those defines don't appear to match the frequency numbers.
I assume the "DDR50", "SDR50" and "SDR104" refer to the bus speeds onthis page
If so, then both DDR50 and SDR50 refer to 50 MByte/sec.
And since there are 4 bits per transfer on UHS-I cards (not sure about the others as they do have 2 rows of pads, always thought those were for differential signalling, but not 100% sure), you need 2 transfers per byte.
So for SDR50 -> 100 MHz and DDR50 -> 50MHz

Then the most important change of this PR is setting the clock?
And then not disabling DDR and setting the max. freq toSDMMC_FREQ_DDR50 would result in the same speed improvement, right?
Likely with less RF noise and better timings.

@lbernstone
Copy link
ContributorAuthor

Hmm these defines for sure would be a lot more clear with quite a bit more comments...espressif/esp-idf@8f1e7bc/components/sdmmc/include/sd_protocol_types.h#L198-L205

#defineSDMMC_FREQ_DEFAULT20000/*!< SD/MMC Default speed (limited by clock divider)*/#defineSDMMC_FREQ_HIGHSPEED40000/*!< SD High speed (limited by clock divider)*/#defineSDMMC_FREQ_PROBING400/*!< SD/MMC probing speed*/#defineSDMMC_FREQ_52M52000/*!< MMC 52MHz speed*/#defineSDMMC_FREQ_26M26000/*!< MMC 26MHz speed*/#defineSDMMC_FREQ_DDR5050000/*!< MMC 50MHz speed*/#defineSDMMC_FREQ_SDR50100000/*!< MMC 100MHz speed*/#defineSDMMC_FREQ_SDR104200000/*!< MMC 200MHz speed*/

The names of those defines don't appear to match the frequency numbers. I assume the "DDR50", "SDR50" and "SDR104" refer to the bus speeds onthis page If so, then both DDR50 and SDR50 refer to 50 MByte/sec. And since there are 4 bits per transfer on UHS-I cards (not sure about the others as they do have 2 rows of pads, always thought those were for differential signalling, but not 100% sure), you need 2 transfers per byte. So for SDR50 -> 100 MHz and DDR50 -> 50MHz

Then the most important change of this PR is setting the clock? And then not disabling DDR and setting the max. freq toSDMMC_FREQ_DDR50 would result in the same speed improvement, right? Likely with less RF noise and better timings.

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.

@lucasssvazlucasssvaz self-requested a reviewNovember 19, 2025 13:22
@lbernstone
Copy link
ContributorAuthor

lbernstone commentedDec 5, 2025
edited
Loading

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.

@TD-er
Copy link
Contributor

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.

@lbernstone
Copy link
ContributorAuthor

The thing that really needs to be tested is if this works on a device that is not capable of 1V8 operation.

@lucasssvazlucasssvaz added the Status: Community help neededIssue need help from any member from the Community. labelDec 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@me-no-devme-no-devme-no-dev approved these changes

@P-R-O-C-H-YP-R-O-C-H-YAwaiting requested review from P-R-O-C-H-Y

@lucasssvazlucasssvazAwaiting requested review from lucasssvaz

Assignees

No one assigned

Labels

Area: LibrariesIssue is related to Library support.Status: Community help neededIssue need help from any member from the Community.Status: In Progress ⚠️Issue is in progress

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

SD_MMC is unexpectedly slow in ESP32-P4

5 participants

@lbernstone@lucasssvaz@P-R-O-C-H-Y@TD-er@me-no-dev

[8]ページ先頭

©2009-2025 Movatter.jp