esp32/machine_sdcard: Move SDMMC slot/width defaults to per-board config - #19620
Open
pavelrevak wants to merge 2 commits into
Open
esp32/machine_sdcard: Move SDMMC slot/width defaults to per-board config#19620pavelrevak wants to merge 2 commits into
pavelrevak wants to merge 2 commits into
Conversation
Move MICROPY_HW_SDMMC_DEFAULT_SLOT and MICROPY_HW_SDMMC_DEFAULT_WIDTH out of mpconfigport.h and into machine_sdcard.h, next to the SD card SPI pin defaults. These defines are only used by machine_sdcard.c, so they belong with the rest of the SD card configuration. The defaults are now the conservative slot 1, 1-bit values, leaving per-board wiring to each board to override. Signed-off-by: Pavel Revak <pavelrevak@gmail.com>
The ESP32-P4 has two equally capable SDMMC slots, so which slot is used and how many data lines are wired is a board property rather than a SoC one. This board connects the SD/MMC card to slot 0 with a full 4-bit bus, so set the default slot to 0 and the default bus width to 4. Signed-off-by: Pavel Revak <pavelrevak@gmail.com>
pavelrevak
force-pushed
the
machine_sdcard
branch
from
August 14, 2026 05:17
bd0d93f to
60dbe80
Compare
|
Code size report: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #19533. In that PR @dpgeorge suggested moving the
MICROPY_HW_SDMMC_DEFAULT_SLOTandMICROPY_HW_SDMMC_DEFAULT_WIDTHdefaults out of
mpconfigport.h:(#19533 (comment))
This does that, and goes one step further. These defines are only used by
machine_sdcard.c, so the first commit moves them next to the SD card SPIpin defaults in
machine_sdcard.h.While moving them I checked the SoC capabilities: the ESP32-P4 exposes two
equally-capable SDMMC slots (
SOC_SDMMC_NUM_SLOTS == 2, both up to 8-bit),so the previous
slot 0 / 4-bitvalue for P4 was not a silicon propertybut a description of how the reference board is wired. The old
#if CONFIG_IDF_TARGET_ESP32P4special-case in the shared header wastherefore misleading.
So the second commit keeps only a conservative generic default in the
header (
slot 1,1-bit) and moves the P4-specificslot 0 / 4-bitwiring into
boards/ESP32_GENERIC_P4/mpconfigboard.h, next to the existingSDMMC LDO config. Any board can still override both defines via the
existing
#ifndefguards.No functional change:
ESP32_GENERIC_P4keepsslot 0 / 4-bitand allother targets keep
slot 1 / 1-bit; the values are just defined in moreappropriate places.
Tested on hardware:
ESP32_GENERIC_P4: defaultmachine.SDCard()reads at ~6.8 MiB/s vs~2.3 MiB/s when forced to
width=1, confirming the 4-bit default isapplied from the board config.
ESP32_GENERIC_S3(XIAO ESP32-S3): SPI-modemachine.SDCard(slot=2)with the default pins still mounts and reads correctly (~1.5 MiB/s),
confirming the refactor didn't regress the other targets.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.