cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX, FatFS and SDIO?

antonius
Senior
Posted on February 20, 2017 at 22:57

Everyone,

How can I use cubeMX for SDcard ? I have generated for MDK but :

this function doesn't work , from UM1721

User manual

Developing Applications on STM32Cube with FatFs page 21.

:

uint32_t wbytes; /* File write counts */

uint8_t wtext[] = 'text to write logical disk'; /* File write buffer */

if(FATFS_LinkDriver(&mynewdisk_Driver, mynewdiskPath) == 0)

{

if(f_mount(&mynewdiskFatFs, (TCHAR const*)mynewdiskPath, 0) == FR_OK)

{

if(f_open(&MyFile, 'STM32.TXT', FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)

{

if(f_write(&MyFile, wtext, sizeof(wtext), (void *)&wbytes) == FR_OK);

{

f_close(&MyFile);

}

}

}

}

FATFS_UnLinkDriver(mynewdiskPath);

This variable :

&mynewdisk_Driver doesn't exist, which file is related ?

Thank you

54 REPLIES 54
Posted on April 27, 2017 at 20:38

0690X00000606tGQAQ.png
cory
Associate
Posted on May 26, 2017 at 21:33

Hey guys, I think the issue is that Cube is generating sdio.c init code that has the hardware flow control option set to off. This is different than the examples provided in the cube driver and example distro, which has flow control enabled:

hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE;

Lowering the clock speed does appear to work also, because flow control is not needed when you get low enough.

Posted on August 15, 2017 at 15:47

I have SDIO 4bit FatFS working, but only with delays between block writes.

https://community.st.com/0D50X00009XkYXYSA3

I foundyour topic. MyCUBE code also had;

hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;�?�?�?�?�?

I thought it was worth enabling the flow control, to see if it would allow getting rid of my delays.

With it enabled, my app fails with and without thewithout the delays that i am trying to eliminate.

In my case, it appearsto make things worse.

Posted on September 01, 2017 at 12:14

Hello sir\mam,

I am trying to interface SD card with STM32 using FATFS but i am having some difficulty in doing so.

I  have written user defined functions for initialization, read and write as mentioned in your code but I am having trouble regarding Status and ioctl functions.

Hoping for some help from you.

Thank you.

Posted on July 12, 2018 at 11:35

Going to note that the F2 part I'm working on today doesn't function properly with flow control enabled, just locks up on writes. Looks to be an errata issue. Reads were working. Just wrote ~15GB with it disabled.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..