2020-03-12 07:37 AM
I'm using the MCU STM32F476VGT on a custom board, my problem is that I recive FR_DISK_ERROR from command f_mount. I have verified that the SD works because I've tested it in a code without FreeRTOS on the same board and i write on the SD without problems, but when I implement the same code on a FW with FreeRTOS it doesn't work (I'm using only defaultTask with SD procedure in it).
EDIT: debugging the code I get the error from the function in cmsis_os.c
xQueueReceive(queue_id, &event.value.v, ticks)
that returns errQUEUE_EMPTY
I get that the error is in something that regards FreeRTOS configurations, but I followed many tutorials and I didn't see particular configurations to use with SD
I'm using STM32CubeMX Version: 5.6.0-RC6 and STM32CubeIDE Version: 1.3.0
Kind Regards
Flavio
2020-03-12 09:00 AM
My guess is you have a race condition where you are trying to read data from a queue before the data was posted to it. Check to see if the queue is used to handle data from the SD card, in particular for data or status transfers,and look at the trace back to see where the xQueueReceive call is made.
The other possibility is the queue read is timing out. Check the event.value.v, ticks variable to see how long it's waiting. This is essentially the same race condition, no data arrived within the expected time period.
Jack Peacock
2020-03-12 09:04 AM
The SDIO and FIFO are intolerant of you wandering off and doing other things when time critical activities are occurring. This can be especially problematic with polled mode operation.
2020-03-12 09:45 AM
Thanks for the reply, event.value.v is 30000 and I get osEventTimeout. I'm only calling the function "f_mount" in the default task and I haven't other task in the program.
the call of xQueueReceive is made by the function SD_read that calls "event = osMessageGet(SDQueueID, SD_TIMEOUT);" and event is equal to "osEventTimeout" and than I get FR_DISK_ERROR in response to my f_mount.
Thanks in advance for the help, I'm not so expert in stm32 programing and I'm learning by myself
Flavio