AnsweredAssumed Answered

BUG: CubeMX SW4STM32 Project generation and STM32 MAT Target

Question asked by Binder.Kristian.001 on Apr 15, 2017
Latest reply on Feb 21, 2018 by STM32Cube-T

Hi there,

when generating code  from Simulink using the STM32 MAT Target, the project build in SW4STM32 will not succeed, because CubeMX doesn't include the <modelName>/Src  directory into the eclipse project's code search paths. This has to be done manually each time the code generation is re-run. The <modelName>/Inc directory is included correctly. I am not sure if this is a bug in CubeMX or in the STM32 MAT Target, but it is definitively annoying and I would appreciate to see it fixed soon.


Another bug appearing to me in this context is the inclusion of the C math library. In Eclipse project settings, the C math library can be included by activating a checkbox in C/C++ Build > Settings > MCU GCC Linker > Libraries. This is set by default in the CubeMx generated projects. But results in linker failure. Unchecking the checkbox and adding the library "m" to the Libraries list in the same configuration page helps.

The difference in the linker call seems to be the order of inclusion:

with checkbox Use C math library (-lm) checked:

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T"../STM32F405RGTx_FLASH.ld" -Wl, -Wl,--gc-sections -lm -o "Application.elf" @"objects.list"

=> Linker fails to build binary


without checkbox checked, but m included in libraries list:

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T"../STM32F405RGTx_FLASH.ld" -Wl, -Wl,--gc-sections -o "Application.elf" @"objects.list"  -lm

=> Linker succeeds to build binary


I hope that my descriptions are clear enough. If not, feel free to ask for more information. Or maybe there is a simple solution for this? Some configuration option I missed so far?

Thank you!


Btw: How many of you are actually using the STM32 MAT Target library for Code Generation in Simulink? I can't find much references on the web. Most private users seem to use the Waijung Blockset? Are there any good professional solutions besides the STM32 MAT Target library?