cancel
Showing results for 
Search instead for 
Did you mean: 

How can I duplicate a project in STM32CubeIDE?

msch
Associate III

I have a project in a workspace in STM32CubeIDE, generated with STM32CubeMX. I would like to duplicate the entire project, including the .ioc information, to use as the starting point for a new project. How can I do this? I am amazed that this topic does not seem to be covered in the STM32CubeIDE User Guide.

If I copy and past the project in the STM32CubeIDE Project Explorer window, it does create a new project, but many names are still those of the old project, and various files are still referencing the old project.

This is such a common task to want to accomplish. How can there not be a straightforward way to do it?

25 REPLIES 25
Imen.D
ST Employee

Hello @msch​ and welcome to the Community ��

This is a known limitation with STM32CubeIDE: that the projects cannot be imported with the option Copy into workspace.

For more details about limitations of STM32CubeIDE v1.8.0, please refer to the STM32 MCU wiki at STM32CubeIDE errata 1.8.0.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
msch
Associate III

You say "for details", but in the errata I only see :

68184 Hierarchical projects cannot be imported with the option Copy into workspace.

68440 Hierarchical projects cannot be renamed. also sounds interesting.

Can you provide the documentation for these errata items?

Nikita91
Lead II

And provide the workaround!

mattias norlander
ST Employee

Empty projects and CDT project are easier to duplicate. They do not contain an ioc-file with absolute paths and references to project names in the same way as the more "automatic" STM32Cube projects.

msch
Associate III

@mattias norlander​ Yes, I'm sure that empty projects *are* easier to duplicate. But I'm not particularly interested in duplicating an empty project. If I want a new empty project, I'll just create a new empty project.

Duplicating an existing project as an indepent project with a new name is a *very common workflow*. I do this all the time for testing, and also as a template for a new prjoect. I am astonished that this capability is not available in STM32CubeIDE. Do you consider that lack a bug? Or just an unimportant feature? Does ST plan to provide this in the future?

I have been working around this by copying folders and editing the internal files, but it is cumbersome and error-prone, and I'm never sure if I've gotten everything. It would be greatly beneficial if STM32CubeIDE provided this capability.

Pavel A.
Evangelist III

> I have been working around this by copying folders and editing the internal files

@msch​ Do you mean copying the whole project folder and editing the .project file?

If so, you already know the fastest and most reliable way to clone eclipse projects.

Improving this 5-second procedure is just not worth the time.

If the project contains absolute paths or relative paths that break in the new location - resolving this is hard to automate anyway. 

msch
Associate III

@Pavel A.​ If only it were that simple. I used to do that with Atollic TrueSTUDIO, and it worked ok. If you try that with the STM32CubeIDE on an MX-generated project, you will find that there are dozens of references left pointing to the old project name and the old project files, including the full absolute path to files in the old project. That brings the concern that even if the new project seems to be working ok, at some point doing some operation in the new project might corrupt something in the old project. That is unacceptable. I have figured out the process to clean up almost all of those references, except for one--the project name and id near the end of the .cproject file. That one hasn't seemed to cause any harm so far, and doesn't include the path. Just the same, I'd like to figure out how to get that updated also--from within the IDE.

I think that the safest and simplest way to duplicate an MX project is actually to create a new "STM32 Project from an existing ... .ioc file" with the original .ioc file, and then copy the user source files from the original project. Finally, re-set any customizations in the build settings.

This could be made much much better if Cube used only paths relative to the project folder for all files within the project folder, and used the project folder name for the project name. Then one could literally simply copy the project folder and rename it. A clean and build would recreate al the files with the project name in their filename. This is the way that Altium works, and it's great.

> If I want a new empty project, I'll just create a new empty project.

When I say "Empty project", it does not refer to a project which is empty of resources. It is another project type. But it does not come with an ioc-file and MX integration.

STM32Cube projects are great when you want to move fast and prototype.

But for production projects(production implying more complex projects with a full product life-cycle: from POC > Dev > Production > Forked products > Maintenance...), I would use the CDT project type. CDT projects are more flexible and has no dependencies. It does not matter if we release a new CubeIDE which in terms integrate a new CubeMX version which wants to download new STM32CubwFW. And you can set which MCU you target at build configuration level. And you can duplicate and rename the project!

> Do you consider that lack a bug? Or just an unimportant feature? Does ST plan to provide this in the future?

We have had numerous request for the "renaming capability". The request is actually not an IDE issue. The Eclipse (IDE) framework can support it (as proven by CDT and Empty project types. But the effort to fix this issue is a lot higher on CubeMX side. CubeMX roadmap is full with new feature requests and this defect is not seen as important vs other mass-market features.

So, the question is what can we do short-term? It depends...

...When you duplicate a project for "test" purpose. Do you then need to modify the ioc-file?

@mattias norlander​ Thank you for a good explanation. Points well taken. I'm using an F777 with a lot of pins and a fair number of peripherals. In the early stages it's been quite useful to use MX for changing pin assignments and configuring new peripherals as I add them into the code. But at some point I will need to cut loose from MX for the production code, since as you point out I wouldn't want a FW or MX update to disrupt the code base. And in fact I'll eventually want to completely rewrite generated files like main.c to clean them up for production. I don't feel in a hurry to do that, though--I guess it's a tribute to MX that it works well enough that it's making me lazy!

Right now, I frequently *am* wanting to modify the .ioc in test versions. But as I mentioned in other posts, I have figured out how to make a copy, with some manual cleanup.

But now I have a new question: can you provide a process for migrating an MX based project to a CDT project, retaining the Makefile setup, tool options, include paths, etc.?