Open maxgerhardt opened 2 years ago
I have to agree with Max (again!).
I am encountering this in the wild right now. Using STM32 but not the framework.
but it's unintuitive
Very. I'm looking into why the linker wouldn't work as expected, but if Max hadn't made the post he did, and the user who first had the issue hadn't been clear enough for me to find it in search results I would be near-defeated. I'm a veteran programmer, but new PIO user. Making a script to add flags would be so far down the list of things I tried on my own that I would have gone back to STM32CubeIDE.
When using a minimal
platformio.ini
ofwith
src/main.c
ofLinking will fail.
This is because the STM32Cube builder script does not add the
-larm_cortex...
switch to actually link in the library.Adding in
fixes that,
but it's unintuitive and undocumented.
Further, above I explicitly linked in
arm_cortexM4l_math
(softfloat) instead ofarm_cortexM4lf_math
(hardfloat). This is because the STM32Cube builder script does not add any-mfpu
or-mfloat-abi
flags by default (source in the compilation process, so everything is compiled as default softfloat, which leads to a ton of linker errors if a user attempts to link with the hardfloat libraryOne has to explicitly add an extra script to add in
-mfloat-abi=hard -mfpu=fpv4-sp-d16
in theCCFLAGS
andLINKFLAGS
to make this work (see https://community.platformio.org/t/error-object-uses-vfp-register-arguments-firmware-elf-does-not/25263).The STM32Cube builder script should provide easier coniguration of the selected CMSIS-DSP library to be linked in, as well as being able to add hardfloat flags for those targets that support it (Cortex-M4, Cortex-M7, Cortex-M33 etc). These options should further be documented.
Note: STM32Duino does this regarding floating point flags and this regarding the library selection.