2022-03-02 12:34 AM
Hello,
I am using STEVAL-STWINKT1B development board and I can write and read sd card using setting to SD 4 bits Wide Bus and FATFS.
If I add on STM32CUBEMX as middleware FREERTOS I can't read the SD in fact I get back FR_NOT_READY when I execute the f_open method.
How can I solve this problem?
Solved! Go to Solution.
2022-03-02 01:49 AM
Did you adjust the heap-size and task-size enough?
For using RTOS with SDCARD, you better active DMA for SDCARD.
2022-03-02 01:26 AM
Hello,
I suggest to refer to one of examples provided in a CubeFx. For example the one provided in STM32F7 under the path: Projects\STM32F769I_EVAL\Applications\FatFs\FatFs_uSD_RTOS
2022-03-02 01:49 AM
Did you adjust the heap-size and task-size enough?
For using RTOS with SDCARD, you better active DMA for SDCARD.
2022-03-02 03:09 AM
In my project on the STM cube MX I modified the following parameters:
Freertos - config parameters- minimal stack 256
Project manage - linker settings Minimum Heap Size 0x400
Project manage - linker settings Maximum Heap Size 0x800
Moreover FatFS has the setting use dma enabled and on the SDMMC1 interface I don't have the tab to select the DMA settings (I think it's set by default but I'm not sure).
this is the task where i use FatFs:
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
FRESULT fres;
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
fres = f_mount(&SDFatFS, (TCHAR const*)SDPath, 1);
fres = f_open(&SDFile, "TEST.csv", FA_CREATE_ALWAYS | FA_WRITE);
fres = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
fres = f_close(&SDFile);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);
/* USER CODE END 5 */
}
2022-03-02 06:52 AM
Test it once with 1-Bit mode and in RTOS:
change your Stack size of your task to minimum 4KB.
Minimal Stack size 128 word
Total heap size 16000
2022-03-02 11:26 PM
thanks a lot for the help now is working properly writing to sd even in 4 bit mode
2022-10-23 06:18 AM
I created implementation with general operations for fatsfs & freertos with CubeMX u can test this code
2024-12-04 09:57 AM
I am running into the same issue how did you fix it? I also don't have the DMA tab for sdmmc and I have the following settings.
Freertos - config parameters- minimal stack 256
Project manage - linker settings Minimum Heap Size 0x1000
Project manage - linker settings Maximum Heap Size 0x1000