cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 SDMMC1 & 4-wired MicroSD

devin-hu
Associate II

Hello,

I am currently using an STM32U5G9 and would like to connect a microSD card via SDMMC1 to expand data storage. My Zephyr device tree contains the following node:

&sdmmc1 {
    status = "okay";
    pinctrl-0 = <&sdmmc1_d0_pc8 &sdmmc1_d1_pc9 &sdmmc1_d2_pc10 &sdmmc1_d3_pc11
                 &sdmmc1_ck_pc12 &sdmmc1_cmd_pd2>;
    pinctrl-names = "default";
    disk-name = "SD";
    bus-width = <1>;
    clk-div = <8>;
};

As shown above, bus-width = <1> indicates 1-bit (1-line) mode. I would like to use 4-bit mode, but after changing this value to <4>, the microSD card can no longer be accessed.

How should this issue be resolved, and what additional configuration or considerations are required to enable 4-bit SDMMC operation correctly on STM32U5 with Zephyr?

1 REPLY 1
T_Hamdi
ST Employee

hello @devin-hu 

Assuming the hardware is correctly wired for 4‑bit mode (all D1–D3 lines properly connected with no conflicts). enabling 4‑bit mode for the microSD on STM32U5 with Zephyr is not just a matter of changing bus-width = <1> to bus-width = <4>. You also need to ensure that the Zephyr configuration and the pin settings are properly defined for a 4‑bit bus. you can try reducing the frequency to improve signal integrity and check whether the issue is related to timing.

clk-div = <32>;

 

in prj.conf :

CONFIG_DISK_ACCESS=y
CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_FILE_SYSTEM=y
CONFIG_FS_FATFS=y

 test 4‑bit mode with "clk-div = <32>" (reduced frequency). If this works, gradually lower the divider (16, 8) to increase the frequency.

If 1‑bit mode works but 4‑bit mode does not, you mainly need to check the physical wiring and the pin configuration for D1–D3 (alternate function and pull‑up).

Best regards, 

Hamdi

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Hamdi Teyeb