cancel
Showing results for 
Search instead for 
Did you mean: 

Option/feature suggestion - Discussion CubeMX

Tobe
Senior III

I had changed a library file, and i wondered, why after a MX config generation it did not work anymore.

CubeMX replaced all the files!!! Lucky i had some backup. Why would you replace library files, that were already copied? Please see my picture for a future upgrade:

7 REPLIES 7
Oskar_H
Senior

Maybe you have done a FW upgrade in the meantime ?

Of course not.

 

Bob S
Principal

Rule #1 - NEVER trust CubeMX (or ANY code generator) to not screw up your code.  The stakes are just too high no matter how good the code generator is (please no CubeMX flames here).

Yeah - CubeMX re-generates all files in the Drivers tree.  The best way to handle this is use version control (git, svn, etc.).  Make sure your version control repo is "clean" (i.e. all changes checked in) before you allow CubeMX to re-gen code.

I've got a large handful of changes to the various HAL files and non-HAL CubeMX generated files.  These changes are not between the "USER" comment sections, so CubeMX over-writes them.  After ever re-gen, I have to restore those changes from the GIT repo.  But that is a simple 1-step process (after committing the changes I wanted from the re-gen).

AScha.3
Chief III

apart from "is Cube - the good - the bad - or the ugly " you should keep to the rules of a tool - or not use it.

so at first : the "generate code" will change/remove everything, except your code between

>>

/* USER CODE BEGIN xxxx */

// this will stay - nothing else !

/* USER CODE END xxxx */

<<

every other modification will be away. ( or you have to restore again .)

 

second: there is a setting you should use (that worked for me for years...)

AScha3_0-1702066684157.png

(even: activate "backup ..generated files" - sound good. but dont work.. (in my test) . so dont use it)

 

third: as Bob said: Rule #1 - NEVER trust CubeMX (or ANY code generator) .

backup/copy everything, you want to see again. just in case...

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

 Please see my picture for a future upgrade

Yes, adding option "Do not touch (delete, rewrite) library files" can be helpful for re-generation,  if the user has changed any library files and wants to keep them. 

The other option "only once" IMHO won't be helpful. Less value vs. effort to implement.

Note that if user choses the option to "add files as references", and changes the library or middlewares files in the "repository", these changes will stay after re-generation. Cube won't re-download and compare the libraries.

 

"The other option "only once" IMHO won't be helpful. Less value vs. effort to implement."

I think other people would not care about your opinion when it comes to create some nice system. Give people choices! The implementation wouldnt be much effort...

Pavel A.
Evangelist III

Give people choices! The implementation wouldnt be much effort...

CubeIDE is not opensource software. We need to find good arguments to convince ST folks to allocate time and resources to change anything.