cancel
Showing results for 
Search instead for 
Did you mean: 

Bug (or at least a limitation) in CUBE / Fat File System found and solved

mycall
Associate II

I hope this is a good place for this.

I had difficulty getting an SD card read to work with FATFs code generated by CUBE. The file at first appeared to get corrupted after about 20K bytes and I spent considerable time trying to figure out what I was doing wrong.

It turned out to be an issue with the function sd_read_block in file sd.c. Specifically there is a call to sd_delay with an argument of 5. This would cause 5 nulls to be sent to the SD card to pump its internal state machine. In my case I needed to change the delay to 10.

Using Windows 10, CUBE version 5.6.1 and Keil 5.34.0.0.

My SD card is embedded in the HW and I am unable to get to it so I can't report the brand but it is a 4GB card.

I hope this helps someone else.

2 REPLIES 2
BParh.1
Senior III

Thanks @mycall​  for the initiative to potentially help other developers to save form potential trouble :thumbs_up:

Amel NASRI
ST Employee

Hi @mycall​ ,

Thanks for reporting this issue.

In order to confirm it and fix it for all other users who may face such a problem, could you please;

  • confirm that issue is still there with latest STM32CubeMX version?
  • precise the selected STM32 part number?

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.