cancel
Showing results for 
Search instead for 
Did you mean: 

stm32CubeMX corrupts Makefile during re-write

frackers
Senior

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!

1 ACCEPTED SOLUTION

Accepted Solutions
frackers
Senior

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.

View solution in original post

2 REPLIES 2
TDK
Guru

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
Senior

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.