Skip to main content
Maciej Drozd
Associate
December 26, 2016
Question

cubemx re-generating

  • December 26, 2016
  • 15 replies
  • 3372 views
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?

    This topic has been closed for replies.

    15 replies

    joemccarr
    Associate III
    December 26, 2016
    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. 

    ST Technical Moderator
    December 27, 2016
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Maciej Drozd
    Associate
    December 27, 2016
    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.

    Tesla DeLorean
    Guru
    December 27, 2016
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ST Technical Moderator
    December 27, 2016
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Bryce Schober
    Associate II
    March 30, 2017
    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.

    stm32cube-t
    ST Employee
    January 16, 2017
    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.

    js2
    Associate II
    February 1, 2017
    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.

    Sirma Siang
    ST Employee
    February 9, 2017
    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