cancel
Showing results for 
Search instead for 
Did you mean: 

Error: Compiler generates FPU instructions without an FPU - How to fix this?

White_Fox
Associate III

Hi guys

I made a project with CubeMX for a STM32F334. This project built fine already multiplet times.

Now, I get suddenly this error message:
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"

As I said, the project was built fine most times, and in the SystemInit function in system_stm32f3xx.c, there is the fpu present check. I do not see any reason why this message comes up.

As I looked for an explanation, I found someone whith this problem, and it seemed to be about wrong including order. If this is a reason: How can I ensure the right order?

I already regenerated the code by CubeMX multiple times. If I accidently removed an include file or did other things wrong, I assumed that this will fix the problem, but it does not. Does anyone have any other ideas how to solve?

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions

I don't know how would including a header file (stm32f3xx.h) would lead to a complaint on missing library, there should be no such relationship. That file btw. is the standard CMSIS-mandated device header (more precisely a header which includes it), i.e. the header which provides you symbols like GPIOA, USART1, etc.

But instead of including that file, you can alternatively just simply add

#define __FPU_PRESENT  1U

before including arm_math.h

JW

View solution in original post

24 REPLIES 24
Pavel A.
Evangelist III

Check the compiler options in project settings? Is floating point selected there?

STM32F3 does not have a FPU so FPU instructions should not be generated.

 

 

It would likely be a mismatch in -cpu, -arch or --fpu command line options, where by it thinks its build for a cm3 vs cm4, or a soft fp

The Linker can also complain if objects or libraries mismatch.

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi guys

Thanks for replying.

I'm quietly sure that my F334 has a fpu. Even though it was a long time ago, but I used it already, and in the current project I'm working with arm_math.h and it's float32_t types, and it built fine yesterday and today morning.

The error message in my first post contains a link to a file "Drivers/CMSIS/include/core_cm4.h". I think, as the F334 bases on a M4 core, this should be fine (shouldn't it?).

The compiler settings does also not looking wrong to me, but to be hornest I have no idea what really would right or wrong, so I better attach a screenshot of them.

Pavel A.
Evangelist III

Sorry, my bad. It has FPU, per the data sheet.

Your project path has spaces. Better avoid this.

Show the command line used to compile and the complete output of compilation (copypaste text, don't screenshot).

JW

Here is the whole console output after a build run:

15:57:26 **** Incremental Build of configuration Debug for project SPV ****
make -j32 all
arm-none-eabi-gcc "../Core/Src/trs.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DARM_MATH_CM4 -DSTM32F334x8 -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=8000000 -DHSI_VALUE=8000000 -DLSI_VALUE=40000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -c -I../Core/Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/STM32F3xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F3xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/trs.d" -MT"Core/Src/trs.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/trs.o"
In file included from ../Drivers/CMSIS/DSP/Include/arm_math.h:322,
from ../Core/Inc/trs.h:12,
from ../Core/Src/trs.c:10:
../Drivers/CMSIS/Include/core_cm4.h:105:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
105 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
| ^~~~~
make: *** [Core/Src/subdir.mk:49: Core/Src/trs.o] Error 1
"make -j32 all" terminated with exit code 2. Build might be incomplete.

15:57:26 Build Failed. 2 errors, 0 warnings. (took 280ms)

#error "Compiler generates FPU instructions for a device without an FPU (check _FPU_PRESENT)"

That #error directive will undoubtedly be within some #if checks.

So go to line 105 in core_cm4.h and see what it's checking - then check how your project has those things configured

Well, here is the content from core_cm4.h, from line 100 until line 110:

#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

I have absolutely no idea how that was changed accidently. I did work in src and inc directories only.

But nevertheless, where and how can I check these options? Soft floating point, ok...but what does VFP_EP mean?

In trs.h, before #include "arm_math.h" insert #include "stm32f3xx.h"

---

> So go to line 105 in core_cm4.h and see what it's checking

It's checking presence of _FPU_PRESENT symbol, exactly as the wording of the error says ;)

JW