Skip to main content
Associate II
Sep 28, 2026 9:18 AM UTC
Question

SDMMC/FileX sample code needed for nucleo_c5a3zg.

I am working on stm32 C5A3ZG platform for one of my projects. I want to use SD card for data logging. I have working SD card module. I tried to use it with nucleo_c5a3zg board using zephyr RTOS and there infrastructure of file management that code is not working on this C5 controller which uses HAL2 driver. It works on other STM32 controllers which use HAL driver.

I tried to create a project in STM32CubeMX2 but couldn’t find configuration for SDMMC over SPI which would be required to interface SD card.

I checked in STM example library https://dev.st.com/stm32-example-library/result?filters=N4IgpgHghgtgDgGzAOVmEAuA2gXQDQgwDGArpliAMoAqAsgMwBMAwgKwj4gBGA9lAE4ATcpxgBLQYKQB3AemyjSAEX5iAbmH4iCvAYIAKUIgGsoAc3m4Cg1Rv7UAnnEs4AvkA but was not able to find any sample or SD card.
Can someone provide a sample code to me otherwise i have to look for potentially changing the platform and move to some other controller.

9 replies

ST Technical Moderator
Sep 28, 2026 3:29 PM UTC

Hello ​@Abhishek_Babhulkar 

Unfortunately, there is no example for interfacing SDMMC card over SPI in STM32CubeC5 package. 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Associate II
Oct 4, 2026 8:25 AM UTC

Hi ​@Saket_Om 

Is there some plan to have such example soon? or is there some other tutorials for cubemx2 to make such configuration so I can make my own application example where i get generated code from filex and sdmmc interfacing.

ST Technical Moderator
Oct 5, 2026 9:41 AM UTC

Hello ​@Abhishek_Babhulkar 

I would like to note that the STM32C5 MCU does not support SDMMC peripheral. 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
ST Technical Moderator
Oct 13, 2026 9:35 AM UTC

Hello ​@Abhishek_Babhulkar 

The issue has been fixed on the link below:

subsys: crc: fix crc7_be hardware result by gautierg-st · Pull Request #121925 · zephyrproject-rtos/zephyr

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Associate II
Oct 13, 2026 9:47 AM UTC

​@Saket_Om 

This issue is not fixed. In zephyr we use zephyrs own file handling implementation. Filex is stm middleware which according to my knowledge suppose to allow user have lightweight file handling middleware which can be used without OS. 

If this understanding is incorrect please correct me. The link mentioned there is of zephyr so can't be used without OS.

MFARH.1
ST Employee
Oct 20, 2026 9:32 AM UTC

Hello ​@Abhishek_Babhulkar ,

 

The STM32C5A3ZG does not include an SDMMC peripheral. To use an SD card with this device, you will need an SD card module(shield) that supports SPI.

In STM32CubeMX2, configure the SPI peripheral connected to the module. If you are using FileX, add interface and select Custom.

CubeMX will generate a driver template, which you will need to adapt to implement the required SD card operations over SPI.

 

BR,

Maher

Associate II
Oct 26, 2026 5:54 PM UTC

Hi ​@MFARH.1 

As far as I see in CubeMX2 there is no option of Custom in the interface. I am attaching the snapshot of tool and info mentioned there is also saying the same that there is no option of selecting Custom.

What I understood from your comment is that I have to implement all SD card read/write commands according to specification of SD by my self and using SPI driver from provided by STM.

I am attaching the zip of project as well if you can point me to write configuration to get it working that would be nice.

Thanks,

Abhishek Babhulkar 

AScha.3
Super User
Oct 26, 2026 7:41 PM UTC

Hello ​@Abhishek_Babhulkar ,

afaik there is no support/example by STM of using SD-card with SPI only.

You have to choose a cpu with SDMMC interface to use some ready examples for SD-card,

or program it on your own. See the examples on the web , or git, not really difficult to use.

or

You can use an SD card over an SPI interface in Zephyr by configuring the SDHC SPI Slot driver and the Disk Access / FatFS subsystem. [1]

Ask your favorite AI about it, if you want it to do it for you.

If you feel a post has answered your question, please click on " Best Answer ".
MFARH.1
ST Employee
Oct 27, 2026 6:31 AM UTC

Hi ​@Abhishek_Babhulkar ,

I’m not sure which version of the FileX pack you are using, but the Custom option is available in versions 2.2.0 and 2.2.1, as shown in the attached screenshot.

Under Interfaces → Interface 1 → Logical interface, click the Interface drop-down and select CUSTOM.

Selecting this option generates a driver interface skeleton that you need to complete with your SD card initialization and read/write implementation using the STM32 SPI driver. It does not generate a complete SD card driver over SPI.

Could you please confirm which FileX pack version you are using?

Best regards,

Maher