cancel
Showing results for 
Search instead for 
Did you mean: 

Help managing STM32CubeMX auto-generate makefiles

CHou.1
Associate II

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.

6 REPLIES 6
TDK
Guru

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
Associate II

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.

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".

STM32CubeMX can generate a makefile but indeed no option to add source files (and includes and everything else).

Makefiles (*.mk) generated by CubeIDE with "external builder" options are artifact of Eclipse CDT "managed builder".

They can be tweaked, see the Eclipse CDT documentation.

IMHO for complex projects these *.mk files are not any better than a manually written makefile and should be avoided

(for example by using "internal builder).

Eclipse CDT has command line options for headless build, just use that.

I see, but doesn't using the headless build option still required you to basically install the whole eclipse executable? I'm concerned about the overhead required with this method since it would make it slow if we were to say do this in a docker instance.

> doesn't using the headless build option still required you to basically install the whole eclipse executable?

This is the simplest. Just install it in container (copy-install often works) and be done with it.