You don’t need to do that at all. As documented, unless you set board_build.stm32cube.custom_dsp_library = yes in the platformio.ini, then the STM32Cube builder script will automatically find the path to CMSIS-DSP as it’s inside framework-stm32cubef1 and add it to the 1. includepath and 2. library include path.
However, it doesn’t yet link the library or define the right ARM_MATH_CMxxx macro.
Still, without copying any file, we can write
[env:bluepill_f103c8_128k]
platform = ststm32
board = bluepill_f103c8_128k
framework = stm32cube
build_flags =
-DARM_MATH_CM3
-larm_cortexM3l_math
And that will use the libarm_cortexM3l_math.a from framework-stm32cubef1. (Note: When specfying to link a library with -l <library name>, that library name should be without the lib prefix. PlatformIO fixes up this common mistake silently though.)
So, this will compile without any problems
#include "stm32f1xx.h"
#include "arm_math.h"
int16_t data_set[] = {1234, 5678, 9876, 4321, 3456, 7890, 6543, 2109, 8765, 1234, 5678, 9012, 2345, 6789, 4321, 8765, 1098, 3456, 7890, 6543};
int16_t array_size = 19;
int main() {
int16_t _max_cmsis = 0;
uint32_t _max_cmsis_index = -1;
int16_t _min_cmsis = 0;
uint32_t _min_cmsis_index = -1;
arm_max_q15(data_set, array_size, &_max_cmsis, &_max_cmsis_index);
arm_min_q15(data_set, array_size, &_min_cmsis, &_min_cmsis_index);
return 0;
}
Conversely, if you do have a custom-compiled CMSIS-DSP library, that is both header and library file, then you can add it like
[env:bluepill_f103c8_128k]
platform = ststm32
board = bluepill_f103c8_128k
framework = stm32cube
; DISABLE INTERNAL CMSIS-DSP LIBRARY
board_build.stm32cube.custom_dsp_library = yes
build_flags =
-D ARM_MATH_CM3 ; Required for CMSIS-DSP library(arm_math.h)
; assumes -I lib/cmsis is automatically present thanks to library structure
-L lib/cmsis ; add the directory where libarm_cortexM3l_math.a is located
-l arm_cortexM3l_math ; instruct the linker to link this library