Quality RTOS & Embedded Software

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


Loading

Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by owaisfazal on January 28, 2015

Hello everyone,

I am running FreeRTOS v8.2.0 with FreeRTOS+FAT SL on Atmel Cortex M4 SAM4SD16C. I am using Atmel Studio for my project. Recently I have noticed that if I change the optimization level in Atmel Studio to None(-O0) from Optimize(-O1) the FreeRTOS+FAT SL is unable to open a file on SD card. However, If I use Optimize (-O1) the file system can access the file on SD card without any problem. Is there some recommendation for optimization level in Atmel Studio while useg FreeRTOS+FAT SL or FreeRTOS in general? Has anyone experienced this issue before? Please do share.

Regards, Owais


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by rtel on January 28, 2015

Hi Owais,

I have never noticed this before. It should work at all optimisation levels, but if there is ever a problem it is normally the other way around - things working with no optimisation but failing at high optimisation.

As it is low optimisation that is causing the problem could it be a stack issue? Low optimisation will presumably use more stack. Do you have stack checking turned on?

Which driver are you using? SD card driver from the ASF?

Can you step through the code to see where it fails? It might be in the FAT code itself, or possibly in the driver.

Regards.


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by owaisfazal on January 28, 2015

Thanks for the response,

I am using the FreeRTOS+FAT FS so the file system is designed for RAM but I have modified it to work with SD card by providing read and write low level functions. i am not sure how to do the stack checking if you could please guide me in this regard. Also the problem does not occur while initializing the SD card which is the following part

void vInitializeSDCard( void ) { unsigned char ucStatus; //! Initialize the SD card and create the volume //! @code ucStatus = finitvolume( sdinit ); //! @endcode

// It is expected that the volume is not formatted.
if( ucStatus == F_ERR_NOTFORMATTED )
{
	//! Format the created volume with FAT32 FS.
	//! @code
	ucStatus = f_format( F_FAT32_MEDIA );
	//! @endcode
}

if( ucStatus == F_NO_ERROR )
{
	pstring("SD card initialized");
}
else if( ucStatus != F_NO_ERROR )
{
	printf("Error No. %d occurred in SD Card initialization\r\n", ucStatus);
}

}

after this I try to open a file on my SD card which in case of optimization level (-O1) opens successfully whereas in case of optimization set to None(-O0) the following call returns a NULL

pxFile = f_open( cFileName, "r" );

I believe there is something I am missing. If so, please do let me know.

Regards.


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by rtel on January 28, 2015

Can you step through the f_open() call to see if it gives a clue as to why it is not happy - that might give a clue as to what went wrong with the initialisation (mounting, formatting, etc.). With optimisation 0 it should be easy to step through.

Regards.


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by owaisfazal on January 28, 2015

Thanks again,

One more thing I should mention is that I am accessing the file before the scheduler is started and once I run it on optimization level 1 it is running without any problem until i change the optimization to None and rebuild the project. Note that if i change optimization to None from Level 1 and without rebuilding the solution directly start the project it also runs.

That being said i have stepped into the code and found out that the function

rc = fn_open( filename, mode );

is returning a 0.

Any clue what could be happening?

Regards.


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by rtel on January 28, 2015

If you are accessing the file before the scheduler has started then I think you will need to have FFSTHREAD_AWARE set to 0. Is that the case?

Regards.


Recommendation for optimization level in Atmel Studio for FreeRTOS+FAT SL

Posted by owaisfazal on January 29, 2015

Yes that is exactly the case I have set the FFSTHREAD_AWARE to 0.

Regards.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner