FREE RTOS / SDCARD / SDIO / FATFS f_open Problem



I am using STM32F767NIH6 board.
I would like to apply SD card this time.
It works well in non os, but in free rtos, the sd card fails.
if(HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == 0)
{
if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0)!=FR_OK)
printf("mount err\r\n");
else
{
printf("mount ok\r\n");
if(f_open(&SDFile, "test.txt", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
printf("Failed to open Write file\r\n");
}
else
{
printf("Opened Write file successfully\r\n");
//Write data to text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
printf("Failed to write file!\r\n");
}
else
{
printf("File written successfully\r\n");
printf("Write Content: %s\r\n", wtext);
}
f_close(&SDFile);
}
f_open(&SDFile, "test.txt", FA_READ);
memset(rtext,0,sizeof(rtext));
res = f_read(&SDFile, rtext, sizeof(rtext), (UINT*)&bytesread);
if((bytesread == 0) || (res != FR_OK))
{
printf("Failed to read file!\r\n");
}
else
{
printf("File read successfully\r\n");
printf("File content: %s\r\n", (char *)rtext);
}
f_close(&SDFile);
}
}
When applied in freertos, an error occurs with a return value of 3 in f_open.
FR_NOT_READY, /* (3) The physical drive cannot work */
I don't know what to do when a problem like this happens.
Please understand even if the translation is a little strange.
