arch/arm/src/stm32h7: add 4-bit wide bus support for MMC/eMMC cards#19462
arch/arm/src/stm32h7: add 4-bit wide bus support for MMC/eMMC cards#1946213022591351 wants to merge 1 commit into
Conversation
The STM32H7 SDMMC driver never programs the WIDBUS bits for MMC cards: stm32_widebus() only records the requested state and the MMC transfer clock preset STM32_SDMMC_CLKCR_MMCXFR is hardwired to WIDBUS_D1. When the mmcsd layer switches an eMMC device to 4-bit mode via CMD6, the host controller stays in 1-bit mode and all subsequent data transfers fail with a bus width mismatch. Program the WIDBUS bits in stm32_widebus() so the host bus width follows the card, and add a CLOCK_MMC_TRANSFER_4BIT clock preset (enum sdio_clock_e extended accordingly). Power saving is disabled in 4-bit mode, same as for the SD 4-bit preset STM32_SDMMC_CLCKR_SDWIDEXFR. Tested on a custom STM32H743 board with eMMC (sd_bench: sequential write ~4.0 MB/s, sequential read ~6.3 MB/s). Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
|
@raiden00pl PTAL @13022591351 Do you know if other STM32 family (F7, H5, etc) also require this improvement? |
linguini1
left a comment
There was a problem hiding this comment.
Awesome! Do you have any log output from SD bench you can attach?
nsh> ver all |
Next Monday I'll analyze it using LLM tools. It's possible that even after merging, 4-bit eMMC still won't be implemented. I'm developing and testing on the PX4/NuttX branch, but the PX4 commit process requires distributed execution. For a complete reproduction of 4-bit eMMC on the H7 platform, please refer to https://github.com/13022591351/PX4-NuttX/tree/pr-fix-stm32h7-emmc_4wire After merging this commit, I will continue to check the relevant code in drivers/mmcsd/mmcsd_sdio.c. |
Summary
The STM32H7 SDMMC driver never programs the WIDBUS bits for MMC cards:
stm32_widebus() only records the requested state and the MMC transfer
clock preset STM32_SDMMC_CLKCR_MMCXFR is hardwired to WIDBUS_D1. When the
mmcsd layer switches an eMMC device to 4-bit mode via CMD6 (MMC_SWITCH),
the host stays in 1-bit mode and all subsequent data transfers fail with
a bus width mismatch.
Program the WIDBUS bits in stm32_widebus() so the host bus width follows
the card, and add a CLOCK_MMC_TRANSFER_4BIT clock preset.
Impact
SD card behavior is unchanged.
sdio_clock_e (existing values are not renumbered).
same change; left for follow-up PRs as I can only test H7 hardware.
Testing
Custom STM32H743 board with eMMC (PX4 V6X derived design), same change
verified via a backport to the PX4 NuttX 10.3 branch:
sd_bench sequential write ~4.0 MB/s, sequential read ~6.3 MB/s.