2016-12-26 02:31 PM
Few weeks ago I have started my first CubeMX generated project. Like always, my project is stored in git repository (locally).
Recently, I wanted to extend projects functionality using re-generating option of CubeMX. Before this operation I have carefully commited my work.
After CubeMX regeneration, with options like: 'backup previously generated...' and 'keep user code...' checked in, I got surprise! All my work is overwritten by CubeMX. Whole git repository is without any question deleted! There is no single byte of my work in project.
I'm really disgusted, what a kind of toy with CubeMX.
File rescue tools haven't helped
:(
What have I done wrong?
2016-12-26 03:05 PM
When I used Cube (Hal) there were areas between comments designated as areas for user code.
I think those areas are preserved during a regeneration of the code by MX. If you did not keep your
code within those areas then it will be overwritten.
2016-12-27 12:39 AM
Dear
,For keeping the user code in CubeMx, you should check 'code generator' setting and ensure that you check-in 'Keep user code when re-generating'. Then, you should insert your code in the user code sections parts :
/* USER CODE BEGIN 0 */.../* USER CODE END 0 */�?�?�?
In that way, you will not lose your codein the next generation.
For further information, refer to the user manual
.
Best Regards
Imen
2016-12-27 09:09 AM
I know this all. I have attended a workshop from ST.
But why have my external files in project directory completely disappeared? This is a big bug from CubeMX.
2016-12-27 09:39 AM
Hi
Drozd.Maciej
,I shared your issue to CubeMx team for checking and working on this case.
Best Regards
Imen
2016-12-27 01:19 PM
And more critically how was anything lost from a git repository... not sure that has anything to do with ST's tools.
2017-01-16 02:41 AM
Dear user,
As we can not reproduce your issue with STM32CubeMX 4.18 : user code in MX generated files, user folders, user files and Backup folders in Inc and Src directories are kept after re-generation.
Can you please provide additional information: your project folder contents and the code/files/folder lost after re-generation.
Thank you.
2017-02-01 08:47 AM
I am running CubeMX 4.19.0 and I can reproduce the issue reported by the original poster.
In the auto generated main.c file, add code between the 'user code begin 2' and 'user code end 2' and you will see that regenerating the project from CubeMX will remove the user code. And this is happening even though the 'Keep user code when re-generating' option is ticked.
2017-02-09 02:50 AM
Hello Jean_seb,
Could you please share your ioc file ?
Then we can investiguate it in similar conditioins.
Thnaks in advance.
Kind regards
Sirma
2017-03-29 05:48 PM
DAHMEN.IMEN
Mondoloni.Pascal
Does the .mxproject file need to be committed to source control in order for user sectionsto be preserved properly?
If so, it's not very clear that it was necessary to do so, and the absolute paths in the .mxproject file even discourage us from doing so.