Skip to main content
msch
Associate III
January 31, 2022
Question

How can I duplicate a project in STM32CubeIDE?

  • January 31, 2022
  • 13 replies
  • 15141 views

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?

This topic has been closed for replies.

13 replies

Technical Moderator
January 31, 2022

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

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
msch
mschAuthor
Associate III
January 31, 2022

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
February 1, 2022

And provide the workaround!

mattias norlander
ST Employee
February 1, 2022

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
mschAuthor
Associate III
February 1, 2022

@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.
Super User
February 2, 2022

> 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
mschAuthor
Associate III
February 2, 2022

@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.

Pavel A.
Super User
February 2, 2022

@msch​ It actually *is* this simple. I've used Atollic for few projects, then updated to CubeIDE, and this way still works for me. Of course you need be careful not to have any absolute paths.

The <storageModule moduleId="cdtBuildSystem ... thing in .cproject indeed is not renamed, but does no harm as you've noticed.

The .ioc file needs a manual fix, yes. After a short practice this is not a problem.

I delete the .mxproject files immediately, they do nothing good and are not required to use the MX.

So... would be nice to have but absolutely not a major issue or show stopper.

As for "CDT" projects - i's not clear what you mean by this. Maybe, unmanaged/makefile projects? Both managed and unmanaged types are "CDT".

Internal builder for managed builds does not leave behind a lot of junk generated makefiles. Less confusion for beginners.

-- pa

Pavel A.
Super User
February 3, 2022

And this is very cool, btw. Kudos to Tilen Majerle!

https://github.com/MaJerle/stm32-cube-cmake-vscode

msch
mschAuthor
Associate III
February 7, 2022

Ok. Could you address the second part of my question? If I change the MCU setting in a CDT project, what will happen? Is it just changing some of the flags that are passed to the toolchain? Anything else?

mattias norlander
ST Employee
March 1, 2022

Changing MCU does two things:

  • Change toolchain settings like mcpu, mfpu, mfloat-abi, and the correct selection of C libraries.
  • Feeds the launch configuration with MCU specific information to allow the STM32 Cortex-M C/C++ Application launch type to be usable.
msch
mschAuthor
Associate III
February 7, 2022

Thank you, that's a good explanation.

ATymo.1
Associate II
July 19, 2022

You cannot just copy a project and open it in the same workspace. It seems that this conflict is related to the indexing of projects by name. And two identical names are not allowed.

But you can do it like this.

Method 1.

Import the aligned project into a new workspace

Method 2

1. Copy the project folder to a new location (file manager)

2. Rename the project to Stm32CubeIDE (for example, add its previous version to the name)

3. Import the copied project into Stm32CubeIDE (essentially with the old name)

Method 3.

Manually edit the project files ".project" and ".cproject". These are normal xml files.

In the ".project" file, the project name is contained in the tag

projectDescription->name

There are more tags containing the project name in the ".�?project" file. It is better to carefully drop them all through a file search.