2018-01-10 11:58 PM
HI
I have next configuration:STM32F405VGT MCUSDHC card connected via SDIO 4bit wide SDFreeRTOS V9.0.0 + FatFS R0.12c Project generated using CubeMXUsing FatFs_uSD_RTOS example code from STM324xG_EVAL with sd_diskio_dma_rtos as basis code for SD operationsNext part of code is used once at initialization:
// Globals
FATFS SDFatFs; /* File system object for SD card logical drive */
char SDPath[4]; /* SD card logical drive path */// Inside init function
/*♯♯-1- Link the micro SD disk I/O driver ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/
if (FATFS_LinkDriver(&SD_Driver, SDPath) != 0) SDCardErrorHandler();/*♯♯-2- Register the file system object to the FatFs module ♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/
FRESULT res = f_mount(&SDFatFs, (TCHAR const*)SDPath, 0); if (res != FR_OK) SDCardErrorHandler();And next code is used for about once a 15-60 second to write a file:
FIL file;
uint32_t byteswrite = 0;char name[16];
sprintf(name, '%u.TXT', n);FRESULT res = f_open(&file, name, FA_CREATE_ALWAYS | FA_WRITE);
if (res == FR_OK) { res = f_write(&file, to, (strlen((char*)to) + 1), (UINT*)&byteswrite); f_close(&file);}
This write is executing from several different RTOS tasks, but are surrounded by mutex so all should be ok. But after 5 hours of work I have an FR_DISK_ERR error on
f_open. Also file that I have tried to open is appears on the SD card, as file contains 0 bytes, so it is created successfully, but still I have got this error.
#sdio #fatfs #freertos2018-01-11 07:37 AM
I'm not sure any of those threads are of much value.
FatFS just propagates errors from below, you have no retry strategy in case of failure, and similarly none of the code in DISKIO.C and below has much of anything either. If you want a robust system you should probably look at retrying things when certain errors are thrown, and look at reinitializing the card when necessary. Things won't get better is the card isn't present.
At a top level you could flag the error to the user, and ask for the card to be removed/reinserted, and give the opportunity to retry the operation.
Most of the examples use the 'give up and die' approach, this usually is a bad plan for commercial products.
2018-05-14 03:02 AM
Hello,
Please refer to the following discussions:
-
https://community.st.com/0D50X00009bMM8bSAG
-
https://community.st.com/0D50X00009XkWyLSAV
KindRegards,
Imen.