Skip to main content
May 28, 2019
Question

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

  • May 28, 2019
  • 14 replies
  • 17987 views

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!

This topic has been closed for replies.

14 replies

May 28, 2019

It seems that I need to define #ARM_MATH_CM4 in Project > Properties > C/C++ General > Paths and Symbols > Symbols. That will get rid of the errors above, but I will get a new error.

../Drivers/CMSIS/Include/core_cm4.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)"

May 28, 2019

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

Can someone confirm that this is the right way to include the DSP libaries?

May 28, 2019

For some reason in main.h, stm32f4xx_hal.h is included twice. Feels like a auto-generated bug?

SShap
Visitor II
June 10, 2019

#include "arm_math.h" STM32CubeIDE

I'm use CMSIS 5.4.0 My Directory C:\CMSIS_5-5.4.0\CMSIS\DSP\Include

poroject ->properties->C/C++ General->path and Symbols->Includes-> Add library directory

June 11, 2019

yep I did that if you refer to my original post at the top. but I still faced some errors which I addressed in my following replies. Do you encounter them as well?

hmm, I guess my formatting for my original question may not be that clear. I have updated it to make it clearer.

Thanks for replying!

Alireza Safdari
Associate
July 21, 2019

Did you get it working? I have the same problem.

July 22, 2019

yea, look at my comments above. still have stm32f4xx_hal.h included twice though.

Alireza Safdari
Associate
July 22, 2019

I did what you explained and I keep getting this error:

I am using Nucleo-F767ZI

I have added ARM_MATH_CM7 with no value under the symbols

arm-none-eabi-gcc "../Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DSTM32F767xx -DDEBUG -DARM_MATH_CM7 -c -I../Inc -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I"C:/Users/alire/OneDrive/Desktop/New folder/1/Drivers/CMSIS/DSP/Include" -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.d" -MT"Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.o"
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)"
 ^~~~~
make: *** [Drivers/CMSIS/DSP/Source/TransformFunctions/subdir.mk:112: Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j4 all" terminated with exit code 2. Build might be incomplete.
 
09:56:57 Build Failed. 3 errors, 0 warnings. (took 24s.614ms)

July 22, 2019

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. =)

Alireza Safdari
Associate
July 22, 2019

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!

July 22, 2019

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. :)

Alireza Safdari
Associate
July 22, 2019

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
July 22, 2019

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.

July 23, 2019

Are these the only functions you use? Maybe we do need to include the source. I haven't tried out these functions. Yea. At least you have something that works. :)

Georgy Moshkin
Senior
August 1, 2019

Just installed STM32CubeIDE v1.0.2. Why arm_common_tables.h, arm_const_structs.h and arm_math.h are not copied to project directory automatically?

Never experienced this problem before, but some people had: https://community.st.com/s/question/0D50X0000Amkvg6SQA/how-to-get-stm32cubemx-to-include-dsp-header-files

Check my STM32 Bootloader - flash your STM32 with AES-encrypted binaries right from web browser!
August 6, 2019

I wonder why as well..... they just aren't.

mfars
Visitor II
September 13, 2019

i want to use dsp lib. i include "arm_math.h" , i m using cortex m0 and first of main.c i define ARM_MATH_CM0 then i compile with no errors. but after that i want to use FFt function // arm_rfft_init_q15(&Real_FFT_Instance, 128, 0, 1) ; // errors happening.

undefined reference to " arm_rfft_init_q15" .

pls help us how to use dsp lib.

Tesla DeLorean
Guru
September 13, 2019

Errors at the linker or compiler level?

Perhaps review the availability of functions for the CM0, and if you need to pull library code into the project to get closure for the linker.

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