cancel
Showing results for 
Search instead for 
Did you mean: 

The function f_open() never return when the SD card is empty.

AFung.1
Associate II

Hello,

I have a problem of f_read in the example project FatFS_uSD_Standalone that the function has never been return when trying to read an empty SD cards.

The following Pseudocode can access sd successfully in the example project FatFS_uSD_Standalone:

f_mkfs

f_open(FA_CREATE_ALWAYS | FA_WRITE)

f_write

f_close

f_open(FA_READ)

f_read

f_close

Need to check the SD card first to see if it is empty or not:

f_open(FA_READ)

if(ok)

{

f_read

f_close

}

else

{

f_open(FA_CREATE_ALWAYS | FA_WRITE)

f_write

f_close

}

- f_open(FA_READ) never return if no file exist.

I appreciated that if you provide any suggestion regarding this issue.

Thanks,

2 REPLIES 2

Assume you'll need to instrument and debug your implementation.

Make sure stack and heap are adequate.

Media Empty or No Media in Socket?

Media Empty or Doesn't have one specific file you're looking for?

Is the media formatted?

What error/status is returned in the NOT(ok) path?

What board/STM32 are we talking about here.

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

"the function has never been return when trying to read an empty SD cards."

How, exactly, do you determine that?

Have you tried using the debugger to step through the code, and see where it gets stuck?

0693W000008xsqBQAQ.png

(including pseudo code)