cancel
Showing results for 
Search instead for 
Did you mean: 

Using DSP libraries (e.g. arm_math.h) in STM32CubeIDE, STM32F4

Legacy member
Not applicable

Hi I need some help,

I am having the same problem using CubeIDE v1.0. I have copied the arm_math.h, const_structs.h and arm_common_tables.h into Drivers/CMSIS/DSP/Include.

I was not able to find arm_math.h until I went to Project > Properties > C/C++ General > Paths and Symbols > Includes and added in Drivers/CMSIS/DSP/Include. That fixed the problem of not finding arm_math.h

After which I get a whole bunch of errors:

 __uint32_t

../Drivers/CMSIS/DSP/Include/arm_math.h:6612:3: error: unknown type name 'uint32_t'; did you mean '__uint32_t'?

 uint32_t blockSize);

...

...

../Drivers/CMSIS/DSP/Include/arm_math.h:6873:16: error: unknown type name '__STATIC_INLINE'

 CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(

    ^~~~~~~~~~~~~~~

../Drivers/CMSIS/DSP/Include/arm_math.h:6873:38: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'arm_bilinear_interp_q15'

 CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(

          ^~~~~~~~~~~~~~~~~~~~~~~

../Drivers/CMSIS/DSP/Include/arm_math.h:6951:16: error: unknown type name '__STATIC_INLINE'

 CMSIS_INLINE __STATIC_INLINE q7_t arm_bilinear_interp_q7(

    ^~~~~~~~~~~~~~~

Thanks!

34 REPLIES 34
Legacy member
Not applicable

I got rid of the (check __FPU_PRESENT) error in my comments above. Did you try it?

"This seems to go away if I include main.h which includes "stm32f4xx_hal.h" before I include "arm_math.h""

in main.c right?

#include "main.h"
#include "arm_math.h"

And I get:

In file included from C:/Users/alire/OneDrive/Desktop/New folder/1/Drivers/CMSIS/DSP/Include/arm_math.h:319:0,
                 from ../Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_q15.c:29:
../Drivers/CMSIS/Include/core_cm7.h:105:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
       #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
        ^~~~~
In file included from C:/Users/alire/OneDrive/Desktop/New folder/1/Drivers/CMSIS/DSP/Include/arm_math.h:319:0,
                 from ../Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.c:29:
../Drivers/CMSIS/Include/core_cm7.h:105:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
       #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
        ^~~~~
In file included from C:/Users/alire/OneDrive/Desktop/New folder/1/Drivers/CMSIS/DSP/Include/arm_math.h:319:0,
                 from ../Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_f32.c:29:
../Drivers/CMSIS/Include/core_cm7.h:105:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
       #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
        ^~~~~
make: *** [Drivers/CMSIS/DSP/Source/TransformFunctions/subdir.mk:118: Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_q15.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Drivers/CMSIS/DSP/Source/TransformFunctions/subdir.mk:112: Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.o] Error 1
make: *** [Drivers/CMSIS/DSP/Source/TransformFunctions/subdir.mk:116: Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_f32.o] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.

Legacy member
Not applicable

Hmm... I am not sure then. I only did those 2 things. I did not include the DSP/Source folder for my project. Only the Include.

I just tried adding DSP/Source to my project and I got a whole bunch of errors. I managed to get rid of it, by putting

#include "main.h" inside arm_math.h

#ifndef _ARM_MATH_H
#define _ARM_MATH_H
 
#include "main.h"

I managed to compile fine after that.

I was thinking that you have done it in main.c

I just did what you explained above and now mine is working too.

I noticed the issue is that arm_math.h gets included before everything else. I changed the order of the directories but still did not solve the issue.

But anyway man, thank you so much for your help. :) Without you this would be impossible.

Legacy member
Not applicable

Yea I did it in main.c. I didn't include DSP/Source in my project. I only include DSP/Include. Supposedly we don't need to include source, unless we are rebuilding the libraries.

DSP arm_math.h need __FPU_PRESENT to be defined, hence this can be resolved by including "main.h" before including "arm_math.h"

As __FPU_PRESENT is defined in "stm32f407xx.h" > "stm32f407xx.h" > "stm32f4xx_hal_def.h >"stm32f4xx_hal_cortex.h" > "stm32f4xx_hal_conf.h > "stm32f4xx_hal.h"

Its just I noticed you included DSP/Source, which I only managed to resolve the errors from that if I include "main.h" inside "arm_math.h" otherwise, you will need to include "main,h" in every source file that includes "arm_math.h"

Glad to help. =)

I did not include the sources also. But still i got the error.

including the main.h in ARM_MATH.h solved the issue for me but I will try to see if there is a better workaround without touching the library files. Although this is already great! I have spend more than 24 hours on this.

Thanks again!

Legacy member
Not applicable

Your log looks like the DSP/Source is included in your project somehow, as the errors came up when you tried to build them.

Maybe it was added as a source folder accidentally?

Glad I could help. :)

Legacy member
Not applicable

Your log looks like the DSP/Source is included in your project somehow, as the errors came up when you tried to build them.

Maybe it was added as a source folder accidentally?

Glad I could help. =)

Man you were absolutely right. I was very sleepy (24 hours without sleep) at the time of writing. I had the DSP files located under the project's CMSIS folder and as you may know the project directory is searched for sources by default. (Okay, to be honest I feel stupid :D ). Anyway thank you for all your time and effort. I am going to write a step by step guide for future readers to save them some time and also cover the issue I was facing so they do not fall for this trap like I did.

Thank you again, you saved the day for me and for many other people.:smiling_face_with_heart_eyes: :folded_hands:

Alireza Safdari
Associate III

I think I celebrated too early! :D

When I remove the accidentally added files in the source, I get undefined error reference for functions in arm_math.h

C:/Users/alire/OneDrive/Desktop/Testing Fir FIlter/Stage1/Debug/../Src/main.c:234: undefined reference to `arm_fir_init_f32'
C:/Users/alire/OneDrive/Desktop/Testing Fir FIlter/Stage1/Debug/../Src/main.c:238: undefined reference to `arm_fir_f32'

I think I am doing something stupid again :D but cannot figure it out. On the bright side when I include the source things get compiled and run correctly.