2022-04-05 07:18 AM
Hi,
I have previously been using the CubeIDE for STM32 developement. Recently I switched to using VScode with makefiles. This has been a very positive upgrade in my opinion, but today I met a problem. I tried to include the CMSIS DSP library to my project. I use the cubeMX software to generate the makefiles for me. In my makefile I defined the following LDFLAGS:
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32H750VBTx_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys -larm_cortexM7lfsp_math
LIBDIR = -Ldsp/lib
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -static
While trying to compile I get the following error:
Drivers/CMSIS/Include/cmsis_gcc.h:1852:57: error: conflicting types for '__QSUB'
1852 | __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
| ^~~~~~
In file included from Src/model.c:22:
Drivers/CMSIS/Include/arm_math.h:5129:12: note: previous implicit declaration of '__QSUB' was here
5129 | *pIb = __QSUB(product2, product1);
| ^~~~~~
I know that the code runs without problem when using CubeIDE. Appreciate any input.
Solved! Go to Solution.
2022-04-05 08:35 AM
Thank you for your input! I found the solution. I needed to make som C defines (like you say):
# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32H750xx \
-DARM_MATH_CM7 \
-D__FPU_PRESENT
the ARM_MATH_CM7 AND __FPU_PRESENT fixed my problems.
2022-04-05 08:31 AM
There may be differences in the CFLAGS like some -D defines etc.. LDFLAGS are for ther linker, not the compiler. You best compare the two log files showing the compiler invocation with your source file(s) and watch out for differences.
The error says that the compiler sees __QSUB in model.c(5129) without having seen a declaration of it. In C, such functions are assumed have an implicit declaration int __QSUB(); The compiler finds later the explicit declaration in cmsis_gcc.h, which is different, and bails out. It could help to include cmsis_gcc.h earlier in your code. But, as you are saying it worked before, compare and adjust the compiler flags.
hth
KnarfB
2022-04-05 08:35 AM
Thank you for your input! I found the solution. I needed to make som C defines (like you say):
# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32H750xx \
-DARM_MATH_CM7 \
-D__FPU_PRESENT
the ARM_MATH_CM7 AND __FPU_PRESENT fixed my problems.