2023-07-22 09:57 PM
I am using STM32CubeIDE 1.13.0 with the latest firmware packs targeting a STM32H563 and need to include the CMSIS-DSP library.
All of the forum posts/youtube videos/howto's etc say to copy a precompiled library file from the firmware repository to your project and then reference it. The problem is that the current firmware repositories no longer contain pre-compiled libraries, only source code. So can someone provide an updated set of instructions describing how to use the DSP code.
Cheers
Simon
Solved! Go to Solution.
2024-02-07 06:01 PM
I've gone through this process a few times before and it's always a huge hassle. Here's how I got it done today:
cmake_minimum_required(VERSION 3.16)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/toolchain.cmake)
set(HOME $ENV{HOME})
set(CMSISDSP ${CMAKE_CURRENT_SOURCE_DIR}/CMSIS-DSP)
set(CMSISCORE ${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_6/CMSIS/Core)
add_compile_options(
-mcpu=cortex-m4
-std=gnu11
-ffunction-sections
-fdata-sections
#--specs=nano.specs
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mthumb
-Wsign-compare
-Wdouble-promotion
-Ofast -ffast-math
-DNDEBUG
-Wall -Wextra -Werror
-fshort-enums
#-fshort-wchar
)
add_link_options(
-mfloat-abi=hard
-mcpu=cortex-m4
-Wl,--gc-sections
-static
-mfpu=fpv4-sp-d16
-mthumb
)
## Define the project
project (cmsis-dsp)
add_subdirectory(${CMSISDSP}/Source bin_dsp)
(You will probably have to adjust some options for your particular STM32 chip. Look in your project's Properties / C/C++ Build Settings / MCU GCC Compiler / All options and MCU G++ Linker / All options to see what STM32CubeIDE is using.)
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_SIZE_UTIL arm-none-eabi-size)
set(CMAKE_C_GDB arm-none-eabi-gdb-py)
set(CMAKE_AR arm-none-eabi-gcc-ar)
set(CMAKE_RANLIB arm-none-eabi-gcc-ranlib)
set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs" CACHE INTERNAL "")
# This should be safe to set for a bare-metal cross-compiler
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
This should produce a libCMSISDSP.a file in CMSIS-DSP/build/bin_dsp.
Now, in STM32CubeIDE, you can
2024-08-22 12:19 AM
Thanks a lot CKugl.1 . Your answer made my day :)
I provide below my feedback on this matter, in case it can help any one out there in a similar situation:
I come from the STM32F4 family and have been using CMSIS-DSP precompiled libraries for STM32F4 family for a while now.
Recently I upgraded to the new STM32H5 family, for which no precompiled CMSIS-DSP libraries are availalble. After some (or rather a lot of) search online and following the official instructions of CMSIS-DSP github I managed to add the source files to the project and compile the libraries from source within STM32CubeIDE. I followed my own steps, but they were rather similar to the ones detailed in this ST post by the ST team .
However, after testing the libraries for a while I observed a really strange behaviour in some of the functions of the library, mostly some functions related to FFT transformations, when compiling the project with the Optimization option for speed , as this was the recommended option instructed in CMSIS-DSP github:
-Ofast
Indeed, with this option I had a gain in computation speed of approximately 60%, but the results of FFT operations , multiplications of complex vectors, etc. were just not right!!
I was then trying to find a way to precompile the CMSIS-DSP libraries externally and ended up in your reply CKugl.1 .
For me this is definately the way to go and should be the recommended method for integrating this libraries into the STM32 MCUs. Now I can have the CMSIS-DSP libraries compiled for speed optimization externally and leave the project with Optimization option "None". So now the code is working accurate as a clock and I am also saving processing time. So thanks a lot for this!
Cheers,
Diego