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