2019-12-03 08:10 PM
So I've developed several 'MCU ARM GCC' static libraries for use in a range of STM32 devices.
They contain standard definitions and utility functions needed by many different projects.
When instantiating a standard, non-STM32 specific, 'MCU ARM GCC' static library, you are not promoted to select an MCU (nothing wrong here) however as you need to know the target for compilation, you need to somehow get this information to the compiler.
When instantiating a STM32 specific project, CubeMX allows you to select a target, which is then locked in to the project and not able to be changed. It is independent of the build settings.
Is there a way to tie the target to a build configuration?
This would allow me to have a single 'STM32Cube project file' with different build configurations for different targets. Ideally, this would not involve re-writing, hacking, or invoking external makefiles, scripts, or something else. Cube should manage all of this for me just as long as I can set the target, and then set all the regular specifics (soft FPs, instruction sets, etc...).
2019-12-08 01:13 PM
Try cross gcc.
Create a new C empty static library cross gcc project and manually fill in the cross compiler toolchain like
Properties > C/C++ Build > Settings > Tool Settings > Cross Settings > Prefix: arm-none-eabi-
Properties > C/C++ Build > Settings > Tool Settings > Cross Settings > Path: C:\ST\STM32CubeIDE_1.0.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-arm-embedded.7-2018-q2-update.win32_1.0.0.201904081647\tools\bin
(your path may vary)
and the absolute path of make here:
Properties > C/C++ Build > Builder Settings > Build Command
Don't specify a target (chip) for a library, but specify compiler options. You can specify different compiler options for different types of chips like:
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
You can create many configurations and set individual compiler options for each one, thereby addressing different types of chips.
hth
KnarfB
PS: I would use a Makefile :)