Quality RTOS & Embedded Software

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




Loading

freertos fat cycle issues

Posted by e12 on May 26, 2016

I raise this question during use freertos fat. The development environment using iar compiler and MCU is using the cortex-m4. I use the hal library and the contents of FreeRTOS FAT Config.h are as follows:

define BUS_4BITS 1
define SDIOUSESDMA 1

I generated only one task, SDcard write, which write 400byte with 50hz the task is as follows:

void SDCARDWRITETask(void * pvParameters) { uint32_t PreviousWakeTime = 0;

SDcardInit(); SDcardSetFileName("FDR","/FDR");

for(;;) { HALGPIOWritePin(GPIOG, GPIOPIN6,GPIOPINSET); //pin high PreviousWakeTime = osKernelSysTick();
SDcardWrite(ucFileName, SDCARDBuffer, sizeof(SDCARDBuffer)); //wirte 400byte HALGPIOWritePin(GPIOG, GPIOPIN6,GPIOPINRESET); // pin low vTaskDelayUntil(&PreviousWakeTime, 20/portTICKPERIOD_MS ); } }

PG6, the pin is high at start, will be low state at the end of the cycle to check the processing time SDcard Write the contents of the function is as follows:

void SDcardWrite(uint8t * filename, uint8t *buf, uint16t size) { FFFILE *pxFile; int32t lItemsWritten; static int32_t cnt = 0;

pxFile = ff_fopen( (char const*)filename, "a" );        // open the file

    if ((pxFile) != 0){SDCARD_STATUS.SD_IsFileOpened = SD_FILEOPENED;}

memset( buf, 0, size);
snprintf( (char*)(buf + 5), (size-5), "FDR_%020d", cnt);
    cnt++;

*((buf + 0)) = 'S';
*((buf + (size-3))) = 'E';
*((buf + (size-2))) = '\r';
*((buf + (size-1))) = '\n';

lItemsWritten = ff_fwrite( buf, size, 1, pxFile );      // write 400 byte
    SDCARD_STATUS.SD_FileWrittenSize = lItemsWritten*400;

ff_fclose( pxFile );

    SDCARD_STATUS.SD_FileAffordSize = SDcard_Capacity_MB(pxDisk);  // check SDcard Capacity 

}

SDCARD WRITE Task oscilloscope results confirmed cases unexpected time length occurred during the test, I set it up 50hz to write 400byte but, sometime it takes 200~250ms oftenly

even if I change the length of bytes the problem still occurred

Why does this problem happen?

is there any chance I can write 512bytes with 50hz?

or is there any limitation of bytes or frequency for SDcard writing?


freertos fat cycle issues

Posted by e12 on May 26, 2016

freertos fat cycle issues

Posted by rtel on May 26, 2016

[to repeat my reply elsewhere on the web]

It looks like the timing your are measuring is related to the driver that is performing the actual write to the SD card, so I would suggest taking timings inside the driver. Also, have you tried different SD cards - our experience is that the difference in performance between different manufacturers is very large, to the point where some cards are almost unusable while others are very fast when subjected to the same tests.

One other unrelated note, PreviousWakeTime should only be initialised once, before it is used for the first time. See http://www.freertos.org/vtaskdelayuntil.html


freertos fat cycle issues

Posted by e12 on May 30, 2016

what is your sdcard? Please recommend one


freertos fat cycle issues

Posted by e12 on May 30, 2016

what is your sdcard? Please recommend one


freertos fat cycle issues

Posted by heinbali01 on May 30, 2016

About the type of card: you can take any SDHC card. +FAT is not yet prepared for SDXC cards. There are great differences in speed and difference in durability between cards. All cards can run in both 1- and 4-bit mode. Some cards showed errors when using 1-bit at higher speeds.

When developing +FAT, many different types (brands) of SDHC cards were tested.

Normally you don't need the highest class or the highest speed. For me durability would be more important. I would not choose a card in the lowest price range. They may show errors earlier and have a shorter life time.


freertos fat cycle issues

Posted by heinbali01 on May 30, 2016

is there any chance I can write 512bytes with 50hz?

I'm not sure if understand your question.

Do you want to write 512 bytes every 20 ms?

Yes but I would gather 8 or 16 sectors first, and then write them in a single call. If you write 16 sectors, you have like 320 ms between two writes. And better: make some elactic: reserve 8 sectors for filling and 8 sectors for writing.

Writing to an SD card has a lot of overhead. Writing 16 sectors is relatively much faster than writing a single sector.


freertos fat cycle issues

Posted by tlafleur on May 30, 2016

You need to look at the data sheet for the SD device your using or talk with the manufacture of the SD device, you will find that it has a finite life of write cycles as is with most NAND memory systems.

I suspect that at 50hz rate you may KILL the SD card in a few weeks or months...

Lots of good and bad info on the web about using NAND memory and SD cards.

http://www.storagesearch.com/ssdmyths-endurance.html <-- talks about SSD devices issues

On Mon, May 30, 2016 at 3:21 AM, Hein Tibosch heinbali01@users.sf.net wrote:

is there any chance I can write 512bytes with 50hz?

I'm not sure if understand your question.

Do you want to write 512 bytes every 20 ms?

Yes but I would gather 8 or 16 sectors first, and then write them in a single call. If you write 16 sectors, you have like 320 ms between two writes. And better: make some elactic: reserve 8 sectors for filling and 8 sectors for writing.

Writing to an SD card has a lot of overhead. Writing 16 sectors is

relatively much faster than writing a single sector.

freertos fat cycle issues

Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

~~ _/) ~~~~ _/) ~~~~ _/) ~~~~ _/) ~~

Tom Lafleur


freertos fat cycle issues

Posted by heinbali01 on May 30, 2016

Thanks for the URL!

I suspect that at 50hz rate you may KILL the SD card in a few weeks or months

It depends on how often the same block gets erased. If you fill your SD-card from the beginning to the end, there is no problem, but yes I would buy a good one.

The FAT gets overwritten more often, but it is located in a more robust area of the flash memory. SD cards are designed to hold a FAT which has frequent updates.

Don't forget to make the writes as big as possible, like at least 16 KB per write, the more the better.


[ 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