Stm32cube framework - fail to build CMSIS DSP sources (dev branch)

I tryed to use rfft functions from CMSIS DSP (comes with stm32cobe framework). But got linker errors like undefined reference to 'arm_rfft_init_q31'.

Also tried -l arm_cortexM0l_math, but not succeeded too. - that’s a concrete file, calling rfft.

Could you help me how to build CMSIS DSP from embedded sources? (i’d prefer to not link pre-build library, because wish to reduce tables size)

The builder script for STM32Cube is not capable of building some of its additional packages (like DSP, CMSIS-RTOS2, etc.). Others like the USB library, or BSP packages, it can. This is also noted in Expand stm32cube builder script to build CMSIS-RTOS2 component · Issue #481 · platformio/platform-ststm32 · GitHub.

I found the GitHub - arduino-libraries/Arduino_CMSIS-DSP: ARM CMSIS DSP repackaged as an Arduino library library which is an Arduino library for the CMSIS-DSP functionality, or rather, a script to generate such a library. I’ve used that library (output in lib/) to compile CMSIS-DSP from the very-latest source for an Arduino project (GitHub - maxgerhardt/portenta-m7-arduino-dsp-example).

Especially if you want to modify certain things about the library like table sizes it would make sense to explicitly exclude the STM32Cube version from being in the include path and add the CMSIS-DSP library as a folder to the project. Try using build_unflags for that with something like build_unflags = -I$PROJECT_PACKAGES_DIR/framework-stm32cubef4/Drivers/CMSIS/DSP/Include (completely untestedd) in conjuction with putting the CMSIS-DSP sources from either the original STM32Cube package version or a newer version as referenced above in a new folder in lib/. (You might have to remove the file from my version to get it to be accepted for framework = stm32cube).

In any case, the STM32Cube builder script can be improved here to at least have the option of buildding its included Drivers/CMSIS/DSP package. I’ll see to it to open an issue about that.

1 Like

Issues Precompiled DSP library path wrong for some STM32Cube packages · Issue #569 · platformio/platform-ststm32 · GitHub and Make CMSIS-DSP inclusion configurable in STM32Cube · Issue #570 · platformio/platform-ststm32 · GitHub are open in regards for this.

1 Like

@maxgerhardt Thanks for detailed explanation, i will use it as plan B.

I’d like to avoid copying of external sources to project’s repo (not nice practice). So, 2 more questions:

  1. Is it possible to just add $PROJECT_PACKAGES_DIR/framework-stm32cubeg0/CMSIS/DSP/Source/**/* as my project sources? It’s not critical to build those as standalone lib.
  2. Is it possible to use lib_deps = and organize paths to dsp headers/sources manually (via python script will be ok too)?

Possible via lib_deps with a file:// URI. Untested.

The shell script of the Arduino_CMSIS_DSP library I referenced already does that to generate an Arduino-compatible library layout, which is thus also PlatformIO compatible.

1 Like

Tried. Seems doesn’t work. Probably, not expands variable (i also tried to cut path to be sure not mistyped nested folders).

Library Manager: Installing file://$PROJECT_PACKAGES_DIR/framework-stm32cubeg0/CMSIS/DSP/Source/
FileNotFoundError: [Errno 2] No such file or directory: '$PROJECT_PACKAGES_DIR/framework-stm32cubeg0/CMSIS/DSP/Source/':
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/builder/", line 180:
  File "/home/vitaly/.platformio/packages/tool-scons/scons-local-4.2.0/SCons/Script/", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/vitaly/.platformio/packages/tool-scons/scons-local-4.2.0/SCons/Script/", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/vitaly/.platformio/platforms/ststm32/builder/", line 121:
    target_elf = env.BuildProgram()
  File "/home/vitaly/.platformio/packages/tool-scons/scons-local-4.2.0/SCons/", line 748:
    return self.method(*nargs, **kwargs)
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/", line 62:
  File "/home/vitaly/.platformio/packages/tool-scons/scons-local-4.2.0/SCons/", line 748:
    return self.method(*nargs, **kwargs)
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/", line 141:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "/home/vitaly/.platformio/packages/tool-scons/scons-local-4.2.0/SCons/", line 748:
    return self.method(*nargs, **kwargs)
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/", line 1104:
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/", line 940:
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/", line 48:
    pkg = self._install(
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/", line 91:
    return super(LibraryPackageManager, self)._install(
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/", line 97:
    pkg = self.install_from_url(spec.url, spec, silent=silent)
  File "/home/vitaly/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/", line 135:
    shutil.copytree(_url, tmp_dir, symlinks=True)
  File "/usr/lib/python3.8/", line 555:
    with os.scandir(src) as itr:

Is that fixable?

I understand. My question is “Is it possible to hack paths without copying cmsis dsp sources into project repo?”. I will copy, if all alternatives fail, but wish to avoid that (if possible).

One can add a little piece of Python script to add the files to the build system so that they are compiled. Using the same env.BuildSources() or env.BuildLibrary() function as the builder script uses.

I used that in e.g. GitHub - maxgerhardt/pio-baremetal-atmel-cmsis.

This would require no duplication of files.

However, since you say you want to modify the header or source files, that is then not possible unless you modify framework-internal files. So having the library in the lib/ folder in the version you want should be the best solution.

I said a bit different thing. Need to restrict built-in tables. That’s done via -D option, without sources change CMSIS_5/CMSIS/DSP at develop · ARM-software/CMSIS_5 · GitHub

I temporary copied files to my project to check build. Seems i have to replace cmsis dsp with something different. After all optimizations, table sizes for arm_rfft_q31(…) is still huge.

The STM32Cube builder script has been updated in the latest platform-ststm32 release to allow excluding the builtin DSP library, as well as fixing the path to the precompiled DSP library if the user wants its inclusion (Precompiled DSP library path wrong for some STM32Cube packages · Issue #569 · platformio/platform-ststm32 · GitHub, Make CMSIS-DSP inclusion configurable in STM32Cube · Issue #570 · platformio/platform-ststm32 · GitHub).

These options are now documented in STM32Cube — PlatformIO latest documentation.

1 Like