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

How does FreeRTOS deal with RAM Functions

Posted by jphilippi on October 20, 2016

Hello,

I am working on a OTA Firmware update for my boards, and I have to copy my flash functions into RAM. I run into the problem when running a RAM Function. If I step through the code by assembly instructions, I can get through the RAM function. If I don't, my board resets. I am assuming a context switch or interrupt is messing with where the RAM function left off, and is causing a reset. The RAM functions are copied to a declared global array that is of a fixed size. So I don't think I have some scope problem.

How does FreeRTOS deal with RAM Functions?

Thank you, Jason P


How does FreeRTOS deal with RAM Functions

Posted by rtel on October 20, 2016

I don't think FreeRTOS itself adds any additional requirement over and above what would have to be considered in a bare metal (no OS) application. As you know, when you are writing to flash, in most cases you cannot simultaneously read from or execute from the same flash - hence your copying of the code to RAM. So you have to take care of first ensuring your RAM functions can be relocated (compiler options, or simply have the functions declared as RAM functions using any compiler or linker extensions that permit that), and second nothing other than the code you copied to RAM can execute for the duration of the write to flash - and that will mean ensuring no interrupts can execute unless you move the vector table and handlers to RAM too. The RTOS has a tick interrupt, and it would be fiddly to try and stop just that interrupt by itself. It is far simpler to just globally disable interrupts while the flash is being programmed, and then enable interrupts again when the programming is complete. That can be done on a flash page by flash page basis, or if you application can cope with it, on the entire write.


How does FreeRTOS deal with RAM Functions

Posted by heinbali01 on October 21, 2016

What MCU are you using? Are you using the fast internal (S)RAM or external SDRAM? I know that some platforms indeed have problems restoring the context after an interrupt.


How does FreeRTOS deal with RAM Functions

Posted by heinbali01 on October 21, 2016

The RAM functions are copied to a declared global array that is of a fixed size. So I don't think I have some scope problem.

Isn't the compiler doing all this work for you?

I made a such a routine running from SRAM in one project. But as re-programming the flash is the last thing to do before rebooting, I completely disabled all interrupts during the process. And as Richard mentioned, you're not allowed to access some (or all) parts of the flash while re-programming it.


How does FreeRTOS deal with RAM Functions

Posted by jphilippi on October 21, 2016

Freescale/NXP K24F with Flash Swap. I am using a function RelocateFunction to write the functions to RAM. I just recently disable interrupts and that doesn't seem to be helping. I might have a problem not related to FreeRTOS.

I am using taskDISABLEINTERRUPTS() but I might need to use INTSYS_DisableIRQGlobal() instead.


How does FreeRTOS deal with RAM Functions

Posted by jphilippi on October 21, 2016

Hein Tibosch,

I'm using a function from a KSDK 1.3.0 library called RelocateFunction.

I'm okay with disabling all interrupts for the active block that I am in. I understand that I can't read and write to the same active block. I only need to do that once for some swap indicator. I can write to the inactive portion of the flash while working in the active flash. It's a feature of this chip, a dual program bank with a swap mechanism. Other than one erase and one write, I will want to flash the other bank while running the current program.

Thank you, Jason Philippi


How does FreeRTOS deal with RAM Functions

Posted by heinbali01 on October 23, 2016

Hi Jason, I'm afraid I'm not experienced with the part that you are using. It does not sound like a FreeRTOS problem. I just read 'AN4533': Program Flash Memory Swap, interesting.

Have you tried to run a different function in RAM, a function that does not program the flash and that does take a long time to complete? When programming the 'inactive sector', you say that the part will reset. Does that happen immediately? Have some bytes been programmed successfully? Is there a randomness in when it resets?


How does FreeRTOS deal with RAM Functions

Posted by dibosco on October 23, 2016

One thing that occurs to me and has caught me out in the past - when I've had a part resetting - is I've forgotten about the watchdog and it's been kicking in. Is that enabled?


How does FreeRTOS deal with RAM Functions

Posted by jphilippi on October 24, 2016

No, that has not been enabled in my design yet. Always a good thing to look out for.


How does FreeRTOS deal with RAM Functions

Posted by jphilippi on October 25, 2016

I successfully used their RelocateFunction for multiple functions in different tasks. This must be a flash library problem.


How does FreeRTOS deal with RAM Functions

Posted by jphilippi on January 5, 2017

Hello Everybody,

I would like to update you all that the problem wasn't from FreeRTOS as you all suspected. I figured I did something wrong but I couldn't figure it out at the time. Here is the link just in case anybody else runs into a similar problem. https://community.nxp.com/thread/437197 I didn't use their SIZE_OPTIMIZATION to define my callback and I didn't have enough heap space.

Thank you all for help and suggestions. -Jason P


How does FreeRTOS deal with RAM Functions

Posted by rtel on January 5, 2017

Thanks for taking the time to report back.


[ 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