Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Readinf file from sdcard while in task

Posted by bruce4243 on August 16, 2016

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: FRDISKERR, /* (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?


Readinf file from sdcard while in task

Posted by rtel on August 16, 2016

Which file system are you using? Where did the integration come from? How is the driver written - polling or interrupt driven?


Readinf file from sdcard while in task

Posted by bruce4243 on August 16, 2016

I'm using the FAT file system. The integration came from FreeRTOS. I'm not sure how the driver is written.

The versions are: FATFS 8255 / Revision ID / tskKERNELVERSIONNUMBER "V8.0.0"

To open the file: FRESULT Res = fopen(&fil, path, flags); To read the file: FRESULT = fread((FIL)fh, dst, sizenum, &nRead);

I have no error opening it, just readig it. As a test I was able to open and read that same file before starting the scheduler.


Readinf file from sdcard while in task

Posted by rtel on August 17, 2016

I'm using the FAT file system

That doesn't narrow it down much....

FATFS

...but that does.

I'm not sure how the driver is written

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).


Readinf file from sdcard while in task

Posted by bruce4243 on August 17, 2016

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?


Readinf file from sdcard while in task

Posted by bruce4243 on August 17, 2016

The problem was, in addition to pausing the scheduler, I had not disabled the D cache, it's working now in the task. Thanks for the support.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS