Quality RTOS & Embedded Software
About   Contact   Support   FAQ

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

Last site update June 02 2015

Embedded TCP/IP stack for RTOS advert



Posted by Ander on May 11, 2011

I have been studying the Architectures of Cortex M3 and the Cortex M4, ARM V7-M and ARM V7-EM and I havenĀ“t found lots of differences. I have to do something for the university, and my question is if I can use the FreeRTOS DEMO for Cortex M3, with a Cortex M4, because I want to have the Free RTOS in my Cortex M4. Thank you very much.



Posted by Richard on May 11, 2011
As far as the kernel is concerned, if there is no FPU (Floating Point Unit) on the M4, then they are the same and the FreeRTOS M3 port runs fine on the M4 too. If there is an FPU, then the M3 port cannot be used if the MPU is used.



Posted by Gianluigi Forte on October 6, 2011
I have tried to run Free RTOS on a M4 + FPU microcontroller and I get a hardfault error inside PendSV_Handler.
I have tried also to disable the compiler option in IAR (FPU none) with the same result.
It is plan to extend the support of the free RTOS to M4+FPU architecture?


Posted by Richard on October 6, 2011
“It is plan to extend the support of the free RTOS to M4+FPU architecture?”

Definitely. An efficient implementation is not as simple as you might think though.

“I have tried also to disable the compiler option in IAR (FPU none) with the same result.”

If you are sure that the compiler is not outputting any floating point instructions, and you are sure you have not accidentally turned the floating point unit on, then it is very likely your problem is not connected to the device being an M4F, as the M3 code does not itself use any floating point instructions and should (does) run on M4F silicon (without the FPU being used).



Posted by Peter Smith on November 14, 2011
I have just started to look at ARM CM4+MPU+FPU and was wondering when a port of FreeRTOS might be available?

Also can some one clear up why you can't enable the FPU if you are using the MPU on a CM4 please?


Posted by Richard on November 14, 2011
The Cortex-M4F can be configured to use the FPU in several ways.

0) Turn the FPU off. Then you can use the M3 port.

1) Turn the FPU on, but set the hardware not to save its context.

This is fine if only one task uses the FPU, and no interrupts use the FPU. It is also fine if you want to save the FPU context manually for just those tasks that have registered as FPU users. It breaks when interrupts start using the FPU too, and is inefficient whatever as most of the time the FPU context is being saved and restored unnecessarily.

1) Set the processor to save the entire FPU context on every interrupt.

This is a really easy way of using it. You would require some changes to the port layer to setup the initial stack to have an FPU context, but that is not difficult. However, it is *massively* inefficient and *horrendous* in run time and RAM usage, especially when you consider that very few tasks will actually use the FPU, and when interrupts start nesting and each has its own FPU context.

2) Set the processor to use the lazy save mechanism so space is allocated to the stack for the FPU context, but a context save is only triggered if an FPU instruction is actually executed.

This is a clever and brilliant mechanism for efficient FPU usage, with interrupts, in a *single threaded* environment. Think through the consequences in a mult-threaded environment, with nested interrupts that also use FPU instructions, and you will soon see this is *massively* complex, with lots of corner cases, and near impossible to test, and almost unworkable with any sort of reasonable code base, size, run time limits, etc..

Then take into account that you need to inspect the output of your compiler extremely carefully, as some versions will output FPU instructions in the prologue and epilogue of function calls, even when the task makes no use of the FPU at all.

There is a plan to support M4F however, it is just a matter of finding the time.



Posted by Peter Smith on November 14, 2011
Thanks for the comprehensive answer....


Posted by Dr. Klaus Schaefer on April 8, 2013
I have now created a FreeRTOs port making use of the MPU and FPU. The trick is not to stack/unstack the FPU context on every interrupt but do this if neccessary whithin the context switch. The files can be found in the FreeRTOS contribution site:

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2015 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 - New Book Edition!

Receive a complimentary pre-release pdf of our up-coming book "Mastering the FreeRTOS Real Time Kernel, a Hands-On Tutorial Guide" with every purchased copy of the existing "Using the FreeRTOS Real Time Kernel" book.

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

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