cancel
Showing results for 
Search instead for 
Did you mean: 

cubemx re-generating

Maciej Drozd
Associate II
Posted on December 26, 2016 at 23:31

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?

15 REPLIES 15
joemccarr
Senior
Posted on December 27, 2016 at 00:05

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. 

Imen.D
ST Employee
Posted on December 27, 2016 at 09:39

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

http://www.st.com/content/ccc/resource/technical/document/user_manual/10/c5/1a/43/3a/70/43/7d/DM001047pdf/files/DM001047pdf/jcr:content/translations/en.DM001047pdf

.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on December 27, 2016 at 17:09

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.

Imen.D
ST Employee
Posted on December 27, 2016 at 18:39

Hi

Drozd.Maciej

‌,

I shared your issue to CubeMx team for checking and working on this case.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on December 27, 2016 at 21:19

And more critically how was anything lost from a git repository... not sure that has anything to do with ST's tools.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm32cube-t
Senior III
Posted on January 16, 2017 at 11:41

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.

Posted on February 01, 2017 at 16:47

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.

Posted on February 09, 2017 at 10:50

Hello Jean_seb,

Could you please share your ioc file ?

Then we can investiguate it in similar conditioins.

Thnaks in advance.

Kind regards

Sirma

Posted on March 30, 2017 at 00:48

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.