2024-09-12 04:05 AM
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
Solved! Go to Solution.
2024-09-14 12:56 PM - edited 2024-09-14 01:00 PM
Let's do a quick experiment.
Run CubeMX v. 6.11.1. Created a new project for the 1st STM32F334 listed in the MCU selector. It was STM32F334C4T6. Did not configure anything, just set the project type as STM32CubeIDE and generated code.
Guess what, the CMSIS device definition file stm32h334x8.h does contain
#define __FPU_PRESENT 1U
Can you try this for your specific STM32F3?
2024-09-16 12:29 AM - edited 2024-09-16 12:30 AM
Ok, I did so as waclawek.jan told me. I defined the fpu_setting in my trs.h file, right before including arm_math.h. It works now again, great.
As I packed the project, I commented this line out, so you should get the same error as I get before if you try to build. If you try it by yourself, just take a look at .../SPV/Core/Inc/trs.h. This is the file where the fault happens.
Here is the console output when I build without arm_math.h:
09:17:26 **** Build of configuration Debug for project SPV ****
make -j32 all
arm-none-eabi-gcc "../Core/Src/main.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/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/main.o"
arm-none-eabi-gcc "../Core/Src/stm32f3xx_it.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/stm32f3xx_it.d" -MT"Core/Src/stm32f3xx_it.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/stm32f3xx_it.o"
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"
arm-none-eabi-gcc -o "SPV.elf" @"objects.list" -larm_cortexM4lf_math -mcpu=cortex-m4 -T"C:\Users\Oli\E-Technik Studium\Master\Abschlußarbeit II\Software\SPV\STM32F334C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="SPV.map" -Wl,--gc-sections -static -L../Drivers/CMSIS/Lib/GCC/ --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
Finished building target: SPV.elf
arm-none-eabi-size SPV.elf
arm-none-eabi-objdump -h -S SPV.elf > "SPV.list"
text data bss dec hex filename
14704 4 2020 16728 4158 SPV.elf
Finished building: default.size.stdout
Finished building: SPV.list
09:17:27 Build Finished. 0 errors, 0 warnings. (took 559ms)
Now the console output after build with arm_math.h, but without #define FPU_PRESENT:
9:19:09 **** 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:13,
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.
09:19:10 Build Failed. 2 errors, 0 warnings. (took 236ms)
The error output tells:
Description Resource Path Location Type
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" core_cm4.h /SPV/Drivers/CMSIS/Include line 105 C/C++ Problem
Now the console output with #define FPU_PRESENT 1U in trs.h:
09:24:07 **** Incremental Build of configuration Debug for project SPV ****
make -j32 all
arm-none-eabi-gcc "../Core/Src/main.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/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/main.o"
arm-none-eabi-gcc "../Core/Src/stm32f3xx_it.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/stm32f3xx_it.d" -MT"Core/Src/stm32f3xx_it.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/stm32f3xx_it.o"
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"
arm-none-eabi-gcc -o "SPV.elf" @"objects.list" -larm_cortexM4lf_math -mcpu=cortex-m4 -T"C:\Users\Oli\E-Technik Studium\Master\Abschlußarbeit II\Software\SPV\STM32F334C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="SPV.map" -Wl,--gc-sections -static -L../Drivers/CMSIS/Lib/GCC/ --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
Finished building target: SPV.elf
arm-none-eabi-size SPV.elf
arm-none-eabi-objdump -h -S SPV.elf > "SPV.list"
text data bss dec hex filename
14704 4 2020 16728 4158 SPV.elf
Finished building: default.size.stdout
Finished building: SPV.list
09:24:08 Build Finished. 0 errors, 0 warnings. (took 496ms)
Edit:
I'm curious what you guys will find. The CubeMX file is also included.
2024-09-16 12:35 AM
@Pavel A. wrote:Guess what, the CMSIS device definition file stm32h334x8.h does contain
Ofcourse, I would expect that the fpu-present-flag is defined somewhere.
This project was set up with CubeMX, so I did already what you told me. The .ioc-file is in the attachement above.
2024-09-17 11:35 PM
Even though if I marked a post as solution, I still would like to know what happened under the hood. Why fires the compiler the error if I include arm_math.h in trs.h, but accept it somewhere else?
Just for a better understanding.
Nevertheless, thank you all for the discussion and your help.
2024-09-18 02:23 AM
> Why fires the compiler the error if I include arm_math.h in trs.h, but accept it somewhere else?
"somewhere else" are presumably files, which do #include stm32f3xx.h directly or (most probably) indirectly, as that's the expected way how you let the compiler know which STM32 are you using, and thus, whether it does have FPU or not.
That's why I recommended to #include stm32f3xx.h into trs.c; and to me, the real mystery is, why would that cause a linker error.
As I've said I don't use CubeIDE so can't try to compile your project.
JW