cancel
Showing results for 
Search instead for 
Did you mean: 

How to use CMSIS-DSP now that there are no precompiled libs in the firmware packs

theRat
Associate

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

10 REPLIES 10
CKugl.1
Senior II

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:

  1. mkdir CMSIS-DSP
  2. cd CMSIS-DSP
  3. git clone git@github.com:ARM-software/CMSIS-DSP.git
  4. git clone git@github.com:ARM-software/CMSIS_6.git
  5. Create a CMakeLists.txt like the following:

 

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

  • Create a toolchain.cmake file like the following:

 

# 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)

 

  • mkdir build
  • cd build
  • cmake ..
  • make -j4

This should produce a libCMSISDSP.a file in CMSIS-DSP/build/bin_dsp.

Now, in STM32CubeIDE, you can

  1. Go to your project's Properties / C/C++ Build Settings / MCU G++ Linker / Libraries
  2. Under Libraries (-l), add CMSISDSP
  3. Under Library Search Path (-L), add the full path to the directory containing libCMSISDSP.a
  4. Go to your project's Properties / C/C++ Build Settings / MCU GCC Compiler / Include paths and add the full path to CMSIS-DSP/CMSIS-DSP/Include/