How to enable FPU instructions?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User11041
Level 1
Level 1
Hi everyone,

I'm struggeling with a project on a XMC4400 device in DAVE and naturally I want tu use the FPU. I turned on the full hardware floating point ABI.

The compiler is called with the flags -mfloat-abi=hard and -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 - which initially looks good to my limited experience.
However, looking into the included header files by Infineon, in "core_cm4.h" I would find the following lines:


#if defined ( __CC_ARM )

[...]

#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
#define __FPU_USED 1U
#else
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#define __FPU_USED 0U
#endif
#else
#define __FPU_USED 0U
#endif


Performing workspace-wide searches, there is not a single line in the entire workspace defining __GNUC__ nor __VFP_FP__ nor __SOFTFP__ - only __FPU_PRESENT is true.
Therefore, this code will define __FPU_USED as false - which is precisely what I don't want.

Does anybody have a clue how to fix this issue?

Best regards
Niklas
0 Likes
1 Reply
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

The __VFP_FP__ and __SOFTFP__ are macros predefined by the compiler itself depending on the command line options.
You can check them by adding the compiler options ' -dM -E' (https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines)
The __VFP_FP__ is defined as long as you specify -mfpu=fpv4-sp-d16
The __SOFTFP__ is only defined if you specify -mfloat-abi=soft. In all other cases i.e. -mfloat-abi=softfp or –mfloat-abi=hard, it is not defined.
The __FPU_PRESENT is defined in the device header file.

The difference between -mfloat-abi=softfp or –mfloat-abi=hard, is the usage of the floating point registers in the later to pass floating point parameters to functions.


Regards,
Jesus
0 Likes