cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX SD CARD Code Bug

Altamash Abdul Rahim
Associate II
Posted on January 31, 2018 at 12:48

Hello,

A while I used stm32cubemx for generating a code for SD card connection to my stm32f4 with SDIO and FATFS middleware and it worked fine but after the recent cube update the similar code does not works for sd card. Luckily i found out the problem. It seems they have not initialized the card in SD_DISKIO.c in SD_initialize()  function change the function to

DSTATUS SD_initialize(BYTE lun)

{

  Stat = STA_NOINIT;

  if(BSP_SD_Init() == MSD_OK)

  {

    Stat &= ~STA_NOINIT;

  }

  return Stat;

}

and it works fine also pull up the SDIO PINS.@@@

NOTE: DISABLE DMA IN FATFS IF NOT USING DMA IN SDIO. IT IS ENABLED BY DEFAULT IN FATFS contrary to previous versions.♯

#tipsandtricks
6 REPLIES 6
Posted on January 31, 2018 at 15:22

There isn't an inherent problem using SDIO+DMA on the STM32F4 platform.

Would be interested in read/write statistic you're seeing in your implementation, say 32MB file in 32KB blocks?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 28, 2018 at 11:05

No, this issue is in Middleware Generated by newer version of Cube .

Posted on June 28, 2018 at 18:54

Hello

 

altamash.ar96

 

This is known issue is already reported for fix and a

workaround 

is suggested there:

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

 

You can test it. Then, let us know if it is working for you or i

f you still have problems.

With Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
ESami
Associate II

@ Altamash Abdul Rahim: It is really helpful if you can mention in your post "which version" of stmcubemx you had been used.

I actually, have the similar problem. I am using stmcubemx version 4.21.0. and stm32f407vgt discovery. I could attach the micro SD slot, create file and write to it. But I couldn't see its contents by PC using usb device mass storage!! Now, post probably, I think that SD initialization is not truly done! This really blocks me this week:((

Do you guys know whether this problem is solved in stmcubemx version 4.21.0 or not? Or perhaps, do you know any better version?

@Imen DAHMEN

Thank you,

Edmond

Hello,

The issue which i mentioned above, appeared in an CubeMx update which was 2-3 releases behind the current version (I do not remember the exact version). The issues were resolved in the newer versions.

ESami
Associate II

Thank you all for your comments!

The problem is solved; this time in STMcubemx, I didn't check the Middlware/FATFS/SD! Only check the Middleware/USB/Mass Storage!

I think when FATFS is included (initialized), then USB mass storage doesn't work properly!

Do you guys have some suggestions how to use both (FATFS & USB device mass storage) in a single project (in a way that at first use FATFS to store data into SD card and then de-initialize FATFS and active USB MS)? Is it possible by STM32Cubemx?

Regards

Edmond