Skip to main content
CHou.1
Associate II
October 7, 2021
Question

Help managing STM32CubeMX auto-generate makefiles

  • October 7, 2021
  • 6 replies
  • 7792 views

Hi all,

We are currently using STM32CubeIDE projects autogenerated from STM32CubeMX as part of our development. The issue with STM32CubeIDE projects is that automating and scripting builds with it is cumbersome even with the CLI interface.

I would like to explore using the auto-generated makefile option but there seems to be no clear documentation on:

  • Adding my own headers/source files to the makefile?
  • What happens if I regenerate the Makefile after adding a new peripheral through CubeMX?
  • If I want to use both generated STM32CubeIDE projects and Makefile, how do I keep them both in sync in terms of my own code (not generated by CubeMX)

As a start I have played around with adding some source files into the generated makefile and re-generating after adding a new peripheral. At the moment the new source/includes required by the newly added peripheral would just be appended after the SRC list in the makefile. This works as a start but I don't think this is maintainable since it's not known which parts of the makefile are free to edit or will be replaced when the project is regenerated.

If anyone could share some tips or experiences from their own workflow that would be greatly appreciated.

This topic has been closed for replies.

6 replies

TDK
October 7, 2021

If you add files to the project, and they're marked as source files, they will get added in the automatically generated makefile. You shouldn't have to or need to edit the makefile directly.

"If you feel a post has answered your question, please click ""Accept as Solution""."
CHou.1
CHou.1Author
Associate II
October 7, 2021

Hi thanks for answering!

By 'project' do you mean the STM32CubeIDE project?

I'm sorry for not being clear enough, I meant that I wanted to use the Makefile generation option directly from STM32CubeMX. In CubeMX I don't see any options for adding source files.

TDK
October 7, 2021
Yes, I mean STM32CubeIDE project.
STM32CubeMX doesn't have the ability to create makefiles as far as I know. It just generates the code structure.
"If you feel a post has answered your question, please click ""Accept as Solution""."