cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 and SDMMC/FatFs

TCash.1
Associate III

Hello Everyone,

I have an STM32H7 interfacing with an SD card Using FatFs. I am using the cube ide, latest drivers etc. (embedded packages version 1.9.0) (FatFs Middlewhere version: R0.12c)

I am facing an issue where sometimes (50% of the time?) The Card Does not apear to initialize when I boot up the board.

There are 2 problems I see, the 1st:

  1. Many Times there is a timeout (default 30secs) in SDMMC_GetCmdResp1. This is from an initial call to f_open(). I have seen other threads about this being an issue with RTOS. But I am not using RTOS. This happens when I open I file on bootup.
  2. Sometimes the above works fine, and my first call to FRESULT res = f_lseek(&file, address); Returns FR_DISK_ERR. this is right after a "successful" opening of the file. (with no errors thrown there)
  3. sometimes no errors are thrown and everything is initialized properly.

My current hack way of handling this is to reboot the entire board until non of these startup errors happen. Which for whatever reason sometimes there are no errors and things run fine.

I am using the DMA template for FatFs, and Hardware Flow Control Enabled. Any Ideas on why this sometimes would fail? My MMC clock rate is 40mhz. Everything is 3.3v. I have tried lower clock rates but that does not seem to help.

Power Cycling does not always start correctly either.

Thanks for any Ideas or help,

Trevor

4 REPLIES 4
TCash.1
Associate III

These errors no longer occur when I use a more expensive SanDisk microSD. I was using a OLEVO microSD from AliExpress. So attributing this to bad sdcards.

-Trevor

The middleware is like 3-4 years old, and has known failure modes for large media. And while this is different to media or comms errors, should be reviewed.

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

Some (perhaps useful?) Data: I had tested about 10 of these OVEVO Cards. and the errors would happen for about 3 in 10. Sometimes I could get get one of these "non-working" cards to work again for a short time after a reformat. (and perhaps a cooldown?) But soon the same card would stop working again. I came to the conclusion that some of the cards just were not working (at least with this interfacing firmware). I don't have the cards any more.

T J
Lead

I always think of the hardware first...

Connectors, how do they look on the card itself ?

Is the insertion compression good enough ?

Did you get the Card reader from Aliexpress ?

How many insertions is the Card Reader good for ?

and secondly the reset time.

I use a reset chip on every board, at least 140mS reset after 2.7V is the minimum I use.

Some boards I use 1 Second Reset

I have Zero issues on startup on all my boards.

Having said that, the card readers are still definitely flaky.

Inserting in and out sometimes to make it work.

I got those readers from Aliexpress.

That is ok for prototypes but not production.