cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX support for SD+FatFS+SPI

John Craven
Senior
Posted on October 10, 2017 at 21:22

I would like to see CubeMX support for SD cards + FatFS using an SPI driver option. Both for MCUs that don't don't support SDIO and also on MCUs that have SDIO but where SPI fits the project better.

FatFS is there as 'user defined' forall.

SDIO option is there where supported.

Why not add SPI option under FatFS?

Seems like would be pretty minor to the follow the templates used in SDIOfor SPI.

Certainly would make it easier to get an stm32 project doing FatFS on SD!

#cubemx #sdio #spi #sd-card

Note: this post was migrated and contained many threaded conversations, some content may be missing.
23 REPLIES 23
Imen.D
ST Employee
Posted on October 20, 2017 at 15:29

Hello

Craven.John

I raised your request internally to CubeMx team.

All your suggestion and comments are welcome.

Kind Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on October 20, 2017 at 16:06

That's great! I have got SDIO working, but never bulletproof, and getting started on a breadboard or with breakouts is pretty dodgy to impossible. As a new STM32 user, my biggest frustration, has been getting SD and file IO going in my projects! Seems i am not alone. At least one new SDIO/fatfs thread pops up every week, Pretty much all the same, can't get it working without spending lot on proper pcb trace design.

I follow a couple open source projects, based on F3/F4/F7, and they all use SPI for SD/fatfs with zero issues. PCBs are simple. The SD card access is bulletproof. It seems it would be much simpler getting going with SPI. Sure there is may be a sacrifice on read/write rates, but full 4bit SDIO rates of 10MB/s are not always required.

When i look at my whole STM32 and CubeMX experience to date, and i could add one thing to cubemx, it would be a checkbox for FatFS/SPI, and simple SD card access on breadboard or with breakout, that worked as good as the many SPI device breakouts i have and use without any issues.

Seems the cubemx generated files for SDIO/FatFS, don't require many changes to support an SPI option.

Certainly, given the number of users on here with SDIO issues, i figure a many would rather have slower SPI SD access, than none or headaches with unreliable fast SDIO.

Anyways, thx for passing it on! I hope it get into CubeMX soon.

Posted on October 21, 2017 at 23:27

Yes, I need a support in this regard. I'm waiting for that support.

John Craven
Senior
Posted on November 30, 2017 at 03:57

Until STM adds SPI based SD/FatFS, this may help some user get started.

I stumbled on a Demo project in the ST32CubeMX firmware specifically for Nucleo F3 boards.

The project uses the Adafruit 1.8' TFT shield (which includes SPI SD and a joystick).

Project is located at 'STM32Cube_FW_F3_V1.8.0\Projects\STM32F3XXXX-Nucleo\Demonstrations\Adafruit_LCD_1_8_SD_Joystick'

Project loads a series of images for SD and displays them. 

After way too many frustrating hours of trying to get reliable SDIO/SD/FatFS working, this worked demo worked in a couple minutes with zero hassles.The project is a great template for SPI/SD/FatFS.

Hope it helps others who just want SD/FatFS to be simple!

pinballsp
Associate II
Posted on December 09, 2017 at 15:17

I am also very interested in SD / SPI / FatFS. I do not understand why it is not available for some time in Cubemx, it is a basic and essential device.

With SDIO I had problems, some time ago I made a design, with Cubemx SDIO / FatFS and it only worked with SD cards of the Kingston brand and another little-known brand that I do not remember now, with the rest of the brands it did not work with any (for example, Sandisk).

So I decided to do the following design with SD for SPI, but for my surprise Cubemx does not support it, and searching for Google there is very little information, and no example ready to try and use.

I hope that soon SD is available for SPI in Cubemx, or if in the meantime someone could provide a practical example with a source that works, I would appreciate it.

Posted on December 09, 2017 at 15:29

Probably because support is such a headache?

Most Cube releases include an SPI/SD implementation

\Drivers\BSP\Adafruit_Shield\stm32_adafruit_sd.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 09, 2017 at 20:26

I saw those sources, but it seems a low level access, read / write data blocks, do not access with Fatfs to read / write files on a FAT / FAT32 SD card. I suppose that the user must implement it in some source file of Fatfs, diskio.c or similar, but at this moment I do not have the knowledge to do it.

I'm looking for, just an SD / SPI example with Fatfs to read and write to files. I thought it would be easier to find something like that, but for now it is impossible.

Posted on December 09, 2017 at 21:46

In ST's scheme of things you might have to change a few function names in the diskio.c layer, and make sure the parameters are in consistent units. Last I checked things were reasonably coherent, that was the whole point of having the BSP layers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 10, 2017 at 14:32

I will have to investigate and do it by myself, the problem is when one does not have the knowledge and full information necessary to do it, and it is also strange that it is not available to download and run.

I have some web links with some sources, but it seems that they need to add additional CMSIS or HAL sources to compile, in addition to modifying the diskio.c source.

In any case, I consider it essential that ST put it in Cubemx to generate everything ready to work, as now happens with SDIO. The option is, but not linked to SPI, it seems that the FATFS library is added, but the user has to modify the sources, without giving any information on how to do it.