cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX code generation is not idempotent (different output when re-run)

Miles1
Associate III

CubeMX produces different results when re-running code generation without any changes applied.

Steps to reproduce:

  • Create a CubeMX project. I'm using all default settings, except for STM32CubeIDE as Toolchain / IDE.
  • Run code generation
  • Save commit output to git
  • Run code generation again
  • Observe these differences:
git diff --stat         
 test1/.cproject              |  2 +-
 test1/.mxproject             | 16 ++++++++--------
 test1/STM32F413ZHTX_FLASH.ld |  4 ++--

The differences appear to just be due to shuffling things around and adding whitespace, but it would be best if the tool behaved more predictably and wouldn't introduce all this unnecessary noise into project history.

System info:

  • OS : Ubuntu 20.04
  • STM32CubeMX version: 6.0.1
5 REPLIES 5
William1
Associate II

I can corroborate this issue, initial generation and subsequent generations result in different outputs. Similarly, using the tool from command line yields yet another result from the same ioc config file. It makes it very challenging to use this tool with version control and continuous integration.

Uwe Bonnes
Principal III

Can you show us the diffs?

I guess it is some time stamp...

Yes! This is just one of the many issues with the generation toolchain that are making CI really painful.

Here's another showstopper: https://community.st.com/s/question/0D53W00000GWrUmSAL/cubemx-ignores-some-settings-in-ioc-file

Miles1
Associate III

> Can you show us the diffs? I guess it is some time stamp...

Here's the diff: https://gist.github.com/milesfrain/ff294ad52144436c91b8dcf5d28f5a01

As mentioned earlier, it's shuffling content and changing whitespace.

Yeah, I have noticed it also takes any temporary changes and saves if instructed to generate the project.

config load "./project.ioc"
script "./generate-common.cfg"
project toolchain Makefile
project generate
exit

Like the above will load an ioc file and then when it hits "project generate" it actually saves the toolchain selection to the file.

I've also run into this issue while trying to setup CI via make. At this point I'm not really sure using CubeMX codegen is viable in a professional setup and will likely look into writing my own cmake build files instead, although it's definitely not ideal. Best solution I have right now is one that can generate Makefile and Eclipse projects that our devs can use, but the Eclipse projects themselves aren't being committed to version control because they are difficult to merge if multiple devs make changes to them.

CubeMX is a powerful tool with all the configuration it automates, but the toolchain support needs to mature a lot more.