2018-07-12 02:39 AM
I am using system workbench (eclipse) as IDE and cubemx to provide setup code for both SDIO(1 bit mode) and FATFS middleware. I am using a STMF407VE and have double checked the SD adapter has correct pin-out.
FATFS myfats;
if(f_mount(&myfats, SDPath, 1)== FR_OK){
returns false
and
FATFS myfats;
if(f_mount(&myfats, SDPath, 1)== FR_NO_FILESYSTEM){
always returns true
2018-07-12 05:43 AM
FR_NO_FILESYSTEM is an indication that the media needs to be formatted with f_mkfs().
2018-07-12 07:50 AM
It might also indicate that you're reading junk from the media, or the block addresses are being shifted.
How large is the card in question? Is it EXFAT formatted? Have you enabled support for EXFAT?
2018-07-13 01:04 AM
I have tried using an older version of cubemx as there is a number of posts about problems with latest version of cubemx generation of SD code. I have now gone to cubemx version 4.21.
Using this version of cubemx and system work bench as IDE on a STM32F$107VE I now have got it to mount and open but it won't write or close.
both
if(f_mount(&myfats, SD_Path, 1)== FR_OK)
and
if(f_open(&my__file, f_name, FA_WRITE | FA_CREATE_ALWAYS)== FR_OK)
return true
but both
if(f_write(&my__file, my_data, sizeof(my_data), &num_written) == FR_OK)
and
if(f_close(&my__file) == FR_OK)
return false.
Even if I just try to open then close a file without writing the close will return false.
2018-07-13 01:14 AM
STM32F407VE is MCU use sorry for the typo
:)
2018-07-13 03:06 AM
I tried a fresh reformat using FAT32 and also tried a couple of different cards. Size of card is 16GB
2018-07-13 05:56 AM
This is all rather top-level stuff. The failure is occurring at the DISKIO layer, I don't use CubeMX, but there are an abundance over issues reported over the SDIO/SDMMC and FatFS code it outputs. Missing call-backs, and using polled mode are problems I've seen reported.
The current version of CubeMX is V4.26.0, the F4 library V1.21.0
The examples in the HAL code tree work a lot better