2023-12-07 01:37 PM
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:
2023-12-08 12:04 AM
Maybe you have done a FW upgrade in the meantime ?
2023-12-08 02:27 AM
Of course not.
2023-12-08 11:31 AM
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).
2023-12-08 12:24 PM - edited 2023-12-08 12:30 PM
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...)
(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...
2023-12-08 01:50 PM - edited 2023-12-08 01:55 PM
> 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.
2023-12-09 12:50 AM - edited 2023-12-09 12:52 AM
"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...
2023-12-09 06:30 AM
> 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.