2026-05-03 4:00 AM
Hi,
using STM32CubeIDE 2.1.1 and STM32CubeMX 6.17, I'm a little confused on how to import an existing ioc-file created by CubeMX into an existing project in CubeIDE. And to later modify it.
Confusion is drawn from this tutorial: https://community.st.com/t5/stm32-mcus/stm32cubeide-2-0-0-workflow-tutorial/ta-p/864831
At the end, it is somehow saying to use the import function of CubeIDE for an ioc-File which is located (physically) on a different location than the project itself (ioc-file in §2.3 tutorial c:/users/ST/Documents while project is in workspace 2.0.0, from which I assume it is stored in a different folder).
Then, later on in §2.5, MCU gets some modification (added I2C in the example) and code is newly generated (in c:/users/ST/Documents and CubeIDE requires a refresh (F5) to capture the updated MCU configuration) (see also equivalent video tutorial at around 4:05min)
So good, so confusing. Why?
1) CubeIDE shows the ioc-file in the project tree, and is physically stored in the folder as the project (see attached screenshot)ioc-File in product tree and storage location
Note that workspace is "Cpp_KeithBentely" (I'm investigating usage of C++).
So why is the ioc-File not directly saved in the location of the project? And the need to refresh is somehow indicating that there is a link between the ioc-File generated by CubeMX and the ioc-File used by CubeIDE. As, hopefully made clear enough, there are two ioc-files ... Shouldn't be one sufficient?
So, why not simply doing something like, where the new ioc-file is directly stored inside the workspace's folder on the harddisk. Note that project location is actually the workspace!
What I simply fear is something might be broken by doing so. Bascially because I haven't understood this eclipse-world just to a minor fraction in best case.
End of Question 1.
Question 2:
In the tutorials of CubeIDE 2.x it is said that CubeMX shall be launched separately to modify the MCU's configuration. Hm, I still can double click on the ioc-File in CubeIDE and CubeMX opens. Is this, even possible, forbidden to do?
You see, I haven't understood the new philosophy. I hope you can help in put some light into the dark.
Solved! Go to Solution.
2026-05-05 2:26 PM - edited 2026-05-05 2:28 PM
> I have no experience about workflow in CubeIDE 1.x because I just recently started with STM32
This is only to the better IMHO, you just skipped developing wrong habits :)
Then, here's a very simple explanation - assuming the "old" project is not based on .ioc and Cube-generated files (but may use the "HAL" and "middleware" libraries of older versions).
1. Start clean with CubeMX, create a new project for your board (or find a closest ST example that has an .ioc ). This will, of course, contain nothing of your custom code.
2. Compare it with the "old" project. Are the structures of two projects totally different or have something in common ?(besides the startup .s file and system_stm32xx.c) Does merging them look viable?
3. Now you have a principal choice: merge the old one to the new one and maintain your project further with CubeMX and .ioc, or stay with the original code and transplant just the pieces and changes from the cube-generated project (which you'll have to keep aside).
In the former case, of course, mind the "user areas" and move as much of your code out of the cube generated files to your own. Even then, be prepared to "surprises" when CubeMX code generation suddenly acts up and breaks things. This happens sometimes, even to the modern AI things. Use version control.
Hope this looks much less confusing now.
2026-05-03 9:51 AM
> Note that project location is actually the workspace!
Not sure about CubeIDE 2.x behavior, but generally Eclipse CDT does not like when a project root directory is same as the workspace directory. This isn't forbidden explicitly but known as a sure recipe for problems.
2026-05-03 11:06 AM
Not sure about CubeIDE 2.x behavior, but generally Eclipse CDT does not like when a project root directory is same as the workspace directory.
Probably some misleading wordings in the GUI of STM32CubeMX - I had similar thoughts as you, but at the end, in conjunction with "Project Name" a sub-folder is created (named what has been entered in the field "Project Name") under the folder "Project Location", which actually STM32CubeIDE will identify as workspace later on.
So, with "Project Name" = "Cpp_KeithBentley" and "Project Location" = "51_Cpp_Test" I get the folders as shown below, and its equvialent in CubeIDE
File Locations
View in CubeIDE
So root directories are actually not the same. The project is one level below.
Despite, what came into my mind is that there seems to be a link between the original ioc-file and the imported one. I.e. the imported ioc-file at one physical location is still linked to its origin at another physical location. So when taken from another project it will updated also when its original has been updated. Kind of bad if not desired. A solution could be if it is possible to break that link - any chance to do this?
2026-05-03 1:11 PM - edited 2026-05-03 1:12 PM
Well, then to the point of importing .ioc file into existing CubeIDE project.
Was the project initially created by some version of standalone CubeMX or integrated in CubeIDE 1.x?
Not all CubeIDE projects are (or must be) associated with .ioc files. They are just sort of Eclipse CDT projects. Many older examples are not based on CubeMX at all.
AFAIK if a project has not been created with CubeMX, there is no any "automatic" workflow for adopting CubeMX generated code into it. The merge can be done manually, it's boring but not a rocket science.
The change from CubeIDE 1.x with integrated CubeMX is that standalone CubeMX (the only option for CubeIDE 2.x) no longer insist that .ioc file must be in certain location or has the same name as the Eclipse project. It just generates the new code where ever the .ioc file happens to be. If you just put a .ioc file in existing project, generation with standalone CubeMX can corrupt the existing project. Take caution, make backups, merge new and existing code carefully.
2026-05-05 12:54 PM
Hi Pavel,
first of all, I have no experience about workflow in CubeIDE 1.x because I just recently started with STM32, and so with CubeIDE 2.x from the very beginning. So any reference to workflow in CubeIDE 1.x will run, at least for my brain, nowhere ;)
" If you just put a .ioc file in existing project, generation with standalone CubeMX can corrupt the existing project."
Any specific procedure to do this in mind? What I tried is the following:
Just short feedback, I'm not totally sure if I have written my steps correctly - I have some time constraints and so can not investigate further every in a timely manner. At the end, to let you know what I'm investigating.
As of know, I tried simply opening CubeMX by double click in CubeIDE, or letting CubeMX generating code into existing project. Don't know that is the better approach; the later one appear the more attractive one as it comes closer to the the idea of importing ioc-Files. The idea of copy and paste is that steps to merge CubeMX' generated code with own one seems not to be required is, as written above, everything is only (and only!) inside the dedicated "user-areas" sourround by the comments "/* User Begin */" and "/* User End*/"
And, oh, if that sound all a little confused - this reflects my understanding as of today. As said, I will further play around, but it will take some time to do so.
2026-05-05 2:26 PM - edited 2026-05-05 2:28 PM
> I have no experience about workflow in CubeIDE 1.x because I just recently started with STM32
This is only to the better IMHO, you just skipped developing wrong habits :)
Then, here's a very simple explanation - assuming the "old" project is not based on .ioc and Cube-generated files (but may use the "HAL" and "middleware" libraries of older versions).
1. Start clean with CubeMX, create a new project for your board (or find a closest ST example that has an .ioc ). This will, of course, contain nothing of your custom code.
2. Compare it with the "old" project. Are the structures of two projects totally different or have something in common ?(besides the startup .s file and system_stm32xx.c) Does merging them look viable?
3. Now you have a principal choice: merge the old one to the new one and maintain your project further with CubeMX and .ioc, or stay with the original code and transplant just the pieces and changes from the cube-generated project (which you'll have to keep aside).
In the former case, of course, mind the "user areas" and move as much of your code out of the cube generated files to your own. Even then, be prepared to "surprises" when CubeMX code generation suddenly acts up and breaks things. This happens sometimes, even to the modern AI things. Use version control.
Hope this looks much less confusing now.
2026-05-07 2:34 PM
Hi,
still not on the road of success.
First have a look on my sketch below, in which I tried to draw what I like to do.
So, far I have seperated folders on harddisk to seperate projects created by CubeMX and CubeIDE. On the bottom the desired "what I want to do" is outlined. It is developping an application with several version (initial, a feature added, code clean up)
So far, the intial phase is doing fine. Project created in CubeMX in folder MX, generated code (in CubeMX), then close CubeMX, open CubeIDE and import project into CubeIDE. Link to ioc-File in Folder MX is maintained, i.e. when I modify something here, it will be updated in CubeIDE automatically, fine!
But then, Project B is created (i.e. the next version) by copy and paste (because I like to maintain all my user code). Then, ioc-File is not anymore referenced to the one in folder MX but in folder IDE (well, a copy created in IDE, so appears logical)
Unfortunately (see black arrow with ???) the import function is not available anymore, see below (Please note that I trying to import from folder MX (here: MX_Repository). It is not selectable (box can not be ticked, button select all is not doing anything)
Well, what does work is when I generated code directly from CubeMX into the workspace of CubeIDE - to the price that all user code gets deleted :( (there is a corresponding warning up front, so not a surprise at the end)
Now one my say: I try manual version control through creating various projects. Hm, yes, this is somehow the intention.
So it sounds like manual merging, but, huh, that doesn't sound very smart. Except there is a list of files/folder I can just overwrite as long as the MCU (/board) remains the same? Ehm, really?
No, I don't get it. With CubeMX as stand-alone application, projects in CubeMX have their own lifecycle, which can be, in general, different to the projects in CubeIDE. Still not where I like to be ...
2026-05-14 3:27 AM
Hi,
I stopped further investigations on it with following conclusions:
Take this as a solution, however, marked Pavel's comment as solution because he made me thinking into the right direction (despite the not totally satisfying result, which is caused by CubeIDE/MX working principles)
Final remark: I'll investigate version control, but this is another topic.