[En-Nut-Discussion] Will the FPU from the STM32F4xx supported (context.c)?

Henrik Maier hmnews at proconx.com
Tue Sep 3 02:11:40 CEST 2013

Not all Cortex M4 will have a FPU (its an optional peripheral) and its 
usage depends what options you pass to the compiler
(eg -mfloat-abi=hard, -mfpu=fpv4-sp-d16 and so forth). I am not aware if 
these FPU settings are reflected in a compiler macro so we can test 
during compile time.

So we have two conditions to check against. a) Is the Cortex-M4 equipped 
with an FPU or not and b) is the code compiled with hard floating point 
or not. Only if both conditions are true it makes sense to save the 
additional registers.

One suggestion would be to add a HAS_FPU flag to the configurator which 
is set automatically when a specific CPU is selected, for example in 
case of the STM32F4xx series. That would satisfy the first condition a). 
What to do best if the code is not compiled with FPU instructions I am 
not certain. I can see issues when Nut/OS is compiled without FPU 
support (and hence no FPU context is saved) but then the user code with 
FPU support. I think it would be safer to save the FPU context in any 
case. I can't imagine having a FPU and not wanting to use it...


On 2/09/2013 7:12 PM, Ole Reinhardt wrote:
> If the FPU is available, how can you be sure _not_ to use the FPU? Won't
> it be used implicitly by the compiler if a flotingpoint calculation is
> executed? This may even be used by a library which you are not aware of.
> So i would suggest to add the FPU registers to the context switch by
> default and add a configuration option to _not_ save them if really wanted!

More information about the En-Nut-Discussion mailing list