I’m able to open and read files from an sdcard during an initialization section of code before starting the scheduler. I try to open and read a file from the same sdcard within a task after the scheduler is started and am not able to perform the read.
I don’t get an error opening the file; however, when attempting a read I get an error:
FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
I tried suspending the scheduler before the read, using critical sections etc, but am not able to perform a read. Any suggestions on how to proceed?
Hmm. I think you are going to have to look at that as, without knowing what it is doing, you will not know if it is safe to use in a mult-threaded application.
FATFS itself has a configuration parameter that, with the provision of a small FreeRTOS port layer, wraps its API functions with macros that take and then give a semaphore to make the API functions thread safe, but the driver needs to be thread safe too (and compatible with FreeRTOS if it is using interrupts).
I checked more about the FATFS integration and found it is from Xilinx for the zynq chip, not FreeRTOS. The driver that it reads the sdcard in ADMA2 polled mode.
This is not a perminate piece of code, it’s a stop-gap until other functionality is ready. If it’s a threading issue I’m fine with pausing the scheduler, but when I tried that it still did not work. Shouldn’t it be enough to halt the scheduler when doing the read from sdcard?