2020-10-27 01:12 AM
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.
2020-10-27 06:31 AM
Unrelated to shown code.
Would be related to a card/sdmmc interaction, likely timing related. Make sure you're not yielding focus at a critical point.
2020-10-27 09:19 PM
How do I get the timing right?
2020-10-29 04:26 AM
2020-10-29 04:50 AM
Not just me then, my thread is https://community.st.com/s/question/0D53W00000Ip7vMSAR/fatfs-on-sd-card-with-freertos-does-it-insist-on-using-dma
ST really need to provide some documentation on how to get SD+FATFS+FreeRTOS working.
2020-10-29 04:28 PM
Haven't you solved it yet?
2020-10-29 05:02 PM
So this is the manufacturer's problem?
2020-10-30 02:52 AM
I don't see ST taking ownership of this any time soon. Their cop out is that "CubeMX and HAL libraries are for demonstration only". This may be fairly standard across the industry, but the number of bugs is distressingly high. If we accept that code will have bugs then the mitigation should be that they are at least documented once discovered, but ST documentation is also disappointing.
I've started another thread on my problems here https://community.st.com/s/question/0D53W00000MgE7qSAF/stm32f767-sdmmc-dma-read-missing-first-16-bytes
2020-11-01 03:44 PM
Please let me know if this problem is solved.
I'll keep trying and let you know when I solve it.
2020-11-02 06:10 AM
I've posted an update as I'm making progress!