Skip to main content
sashaa
Associate
March 10, 2015
Question

initialize FatFS with SPI In stm32cubeMX

  • March 10, 2015
  • 5 replies
  • 3434 views
Posted on March 10, 2015 at 21:34

Hi,

I want to read/write data to SD card via SPI. is it possible to initialize the FatFS module to work with SPI interface in cubeMX tool?

The SD card option in the FatFS middleware is available only when I am enabling the SDIO peripheral.

I am using STM32F4-DISCOVERY board and STM32CubeMX ver. 4.6

Thanks

#stm32cubemx #stm32 #spi #fatfs #sd #sdio
This topic has been closed for replies.

5 replies

Mnemocron
Associate III
June 9, 2016
Posted on June 09, 2016 at 07:37

Exatly what I've been up to the last week. And I haven't figured it out yet.

If anyone knows how to interface SPI SD cards with STM32, please answer.

I am using STM32F4-Discovery (STM32F407), Keil uVision 5 and STM32CubeMX 1.0 (4.12.0).

Till date, I tried:

- translating the Arduino SD libraries (C++) to work with HAL_SPI_x() funtions

  gave up this one, because everything is deeply wired to the Arduino environment

- implementing the ElmChan FatFs library on my own

  didn't work, or at least it threw no errors, but still didn't work

- implementing the TM libraries from http://stm32f4-discovery.net/

  I don't get how to implement these correctly, ended up like the one above

  or with several L6218e errors from the linker

slimen
Visitor II
June 9, 2016
Posted on June 09, 2016 at 11:06

Hi,

I suggest you to use the last version of CubeMx v4.15 andhave a look to this example using most of the features offered by FatFs toconfigure a microSD drive:

STM32Cube_FW_F1_V1.4.0\Projects\STM3210C_EVAL\Applications\FatFs\FatFs_uSD

You'll still have to own the integration with this application which can help you as an implementation example and get inspiration to achieve you goal.

You can refer to this

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20Discovery%20-%20interfacing%20SD%20card%20with%20SPI%20%20FatFS&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=150

it may be helpful for you.

Regards

Taylor Welsh
Associate II
November 22, 2018

i found kiwih's drivers very useful, it's an easy drop in implementation for existing CubeMX projects.

https://github.com/kiwih/cubemx-mmc-sd-card

Taylor Welsh
Associate II
November 22, 2018

i found kiwih's drivers very useful, it's an easy drop in implementation for existing CubeMX projects.

https://github.com/kiwih/cubemx-mmc-sd-card

yoheeb
Visitor II
May 7, 2019

Hi, new to the forums. Maybe someone can help me here. I am also new to ST/CubeMX. I have a quick little project I am trying to put togther, and thought I could just uses this cubemx-mmc-sd-card you mention, but I don't understand how I take it from a dev board, to a different MCU "easily". CubeMX is not intuative on this. If I go back to board/mcu selection it's restarting the project. Do I import? I did that, but resulted in import errors, and generating code there is a ton missing (of course, it also crashed the first try so...). Anyway, any help is appreciated. I just need to use SPI to an sd card in the most basic way. I was hoping to use CubeMX to generate the guts, then read/write some files. I have some GPIO interrupts etc. already running that I need to trigger on.

Maybe I am better of just doing it from scratch?

Thanks in advance.

Jay

Tesla DeLorean
Guru
May 8, 2019

The HAL has Nucleo based SPI examples, using the AdaFruit shield code in the HAL/BSP code trees.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MWATS
Visitor II
January 14, 2019