Quality RTOS & Embedded Software

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




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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists