Skip to main content
frackers
Senior
Aug 2, 2020 8:50 AM UTC
Solved

stm32CubeMX corrupts Makefile during re-write

When generating code on an existing Makefile project any existing C_DEFS are corrupted

C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32F301x8 

becomes

-DC_DEFS = USE_HAL_DRIVER \
-DSTM32F301x8 

so the definition of C_DEFS is lost and random errors result from the dangling defines.

This is on version 5.6.1 but is has been an issue for a long time (at least a year).

I've also seen other strange behaviour on Makefile - like "# compile gcc flags" gets repeated every time the code is generated - one makefile now has the string 15 times on one line!!

Another is -isystem for system include file path, CubemX insists on prefixing it with -I so it fails with -Iisystem ....

I'll save all the other bugs I've found for another day! - the above are the most annoying!

This topic has been closed for replies.
frackers
frackersBest answer
Senior
Aug 2, 2020 10:31 PM UTC

On further investigation it appears to be older IOC files that confuse CubeMX. Starting a project from scratch I have no issues but some projects originally generated 2 years ago have all these problems.

2 replies

TDK
Aug 2, 2020 2:15 PM UTC

I don't think STM32CubeMX is meant to generate code over existing project Makefiles. It's meant to only work with its own generated code. The generated makefile has the following header:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

There are places within the IDE to add things like include paths and other definitions.

"If you feel a post has answered your question, please click ""Accept as Solution""."
frackers
frackersAuthorBest answer
Senior
Aug 2, 2020 10:31 PM UTC

On further investigation it appears to be older IOC files that confuse CubeMX. Starting a project from scratch I have no issues but some projects originally generated 2 years ago have all these problems.