Loading...
 
Skip to main content

System Workbench for STM32


STM32L0538 using FATFS with SPI

Hi,
I'm trying to read a memory card with FATFS through SPI, so I generated a project with CubeMX on my board (L0538-discovery). I think my problem is that I don't give FATFS the right driver to link, because I get a FR_NO_FILESYSTEM when I try to f_open (but no error before), and the only driver I seem to have access to is USER_DRIVER. Does anyone know what is the driver I have to pass to FATSFS_LinkDriver before starting to use f_xxx function ?

Thanks

Hi,

follow the call of MX_FATFS_Init() and look what it does.

If you use a plain CubeMX generated project you have to fill the 5 skeleton functions in user_diskio.c
Then provide what these functions needs.

There are examples in STM32Cube_FW_L0... repository.

For example the IO functions:
STM32Cube_FW_L0_V1.5.0/Drivers/BSP/Adafruit_Shield/stm32_adafruit_sd.c

For example the example user_diskio.c:
STM32Cube_FW_L0_V1.5.0/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c

Dieter


Thank you for the explanations and examples !

I adapted the files you showed me to my board (pins, leds, ..), but I have an FR_DISK_ERR when mount my device. Does anyone have a solution to know where it may comes from ? (Or which function between write, read and iodl)