Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX deletes Src folder..

Till Rachow
Associate III


When I am generating Code with CubeMX, it will delete my complete Src folder. I always have to recover it. For that reason it will also not generate any new c files once i add a new peripheral.

Tried this on Mac and Windows with latest CubeMx version (4.26.1) and i get the same behaviour in both.

Can anybody help?


Brian Rau
Associate III

Mohamed, any idea WHEN the 4.27.0 release will be? This is holding up software development for many of us!

You understand that's like telling your boss the dog ate your homework, right?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nico 2010
Associate II

0690X000006Bze5QAC.pngHi, I notice that in "Settings" one can select in Application structure "Basic" or "Advanced". The first one erase src, the last one not erase src located in Core folder. Hope help someone. I use CubeMX v4.26.

Associate III

It seems like my problem has been gone with v4.26. The new v4.27 doesn't have this problem at this moment.

Associate II

Just ten minutes ago, CubeMX deleted my entire project without any reason. The version of the CubeMX is 4.26.1. I don't have backup for last couple of days. I made many many changes even today. The project is not even in the Recycle Bin. What kind of team is writing the CubeMX? How this kind of thing can happen? I think it is time to move another brand microcontrollers.

Associate II

Same problem, I have 4.26.1,version 4.27 does not appear in "check for updates".

Associate II

I am still experiencing this issue in CubeMX 5.2.0, this does not seem to be an issue with the .ioc file, since the same file used to work fine before.

Associate II

I have had all the contents of my source folder deleted, and not sent to the windows deleted files bin, on a couple of occasions: the first time I thought it was because I didnt have the 'backup previously generated files ' box ticked; but never the less I would have thought that, at the least, prompting before complete deletion would be courteous. Where is this 'backup directory', where it should have gone on the second occasion?, it is mentioned in the manual, but I cant find it, is it imaginary?. I find this behaviour from an official release ST tool astonishing. Are the developers doing it for LULZ?!. I now make a copy of the source folder before touching cube mx. I see there is a new STM cube release, but I don't want to spend time changing horses mid stream in a project, learning the new tool, and then finding that something else is broken. Code Composer studio or Dave would not do this. Thank goodness eclipse keeps a history where stm cube cant silently erase it. Silently erasing the entire source file directory contents is one of the grossest transgressions I can remember of a development tool . Perhaps I should be grateful it didnt reformat something whilst it was at it.


I can't believe that nearly 2 years after this thread was started this problem still exists! I and running STM32CuebeIDE that has STM32CubeMX I am using a Mac for development.

How I found the issue

  • Create a new project for STM32F103
  • Configure UART using MX Tool
  • Configure FreeRTOS middleware using MX Tool
  • Generate code using MX
  • Write some code
  • Decide to change UART timer source, make the change in MX tool then regenerate code
  • Find that the entire src folder has been deleted!

Am I using this tool as intended? i.e. using the MX tool to make running changes as a project develops. Has anyone dared use this tool for production purposes?

Associate II

I am now using the cube mx ide, I loaded an old reference project to see how I dealt with sdram, decided to rename the opened project and somehow ended up with all my source files deleted!. And - naturally, deleted files do not go to the recycle bin -that would be too easy!. It beggars belief that professional programmers would write code that does this - not just delete and send to recycle bin, or rename as .old - but erase from the file system. Do these guys not use the tools that they create?.