cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE cloning (copying) a project

chriskuku
Senior II

A usual approach is to branch from a given project by making a copy of it and develop further on the copy, leaving the original intact.

 

How can this be achieved in the STM32CubeIDE project tree?

I tried it by copying the directory in the filsystem, to a different directory, edited every file containing the original project name to the new one. Even edited the .metadata and every occurence of the original name in the new directory tree. It lead to an existing new entry in the tree view Could be that I even did an Import by browsing to that new directory.

But the result was that I was said it not being a CDT project when I wanted to open the properties on the new project icon.

What is a safe way to do achieve this?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

 


@Piranha wrote:

CubeIDE, as every Eclipse based tool ... allows every developers to works as he prefer


That is exactly the thing the Eclipse's workspace and overall design doesn't allow. Read this post for details. If

 

 I must say that - from my own experience - the "copy/paste in the project tree"-method worked for me and is *the* solution. I have no links in my projects. Maybe there are problems when one is using links.

View solution in original post

14 REPLIES 14
Harvey White
Senior III

I'm not sure that CubeIDE etc is set up to gracefully do this.

I've found that simply copying the project leaves a lot of links in that make problems for you later (like links back to previous locations).

What I've done is a brute force approach.

Copy the main.C program to another reference directory.

Copy the .IOC file to another directory.

Hopefully, you've got a standard structure for directories and the like (I do...)

  1. create a project directory.
  2. in that directory, use CUBEMX to create a new project from an existing IOC file
  3. point the initialization software at a previous version of the IOC file.
  4. let it create a new project in the new directory.  The project name should have been embedded in the IOC file and all your chip connections should be identical.
  5. generate code.
  6. your main.c program will lack any modifications you made to it.
  7. copy your older main.c program over the new main.c program, that puts all the mods to main.c back in.
  8. if your main.c had absolute paths, you need to fix them.
  9. move/paste your program addons into whatever directory you used.  I have one or two directories that are added to a project.  With luck, all the links are relative.  If not, you may need to fix them.  You won't if the project is in a subdirectory of the main "project" directory.
  10. if it's higher, you may have to fix things.
  11. as long as all the absolute paths are ok, you're fine.
  12. you may have to go into project properties and fix links and settings.

It's not graceful, but it seems to work.  Eclipse (and CubeMX) don't seem to have a "clone project to another directory" capability.  I'd like to find one.

Hope this helps a bit.

 

Stefano Oliveri
ST Employee

CubeIDE, as every Eclipse based tool has a lot of flexibility that can be powerful or complex, depending on our experience and expertise with the IDE. In my opinion it is a good thing because it allows every developers to works as he prefer (with an initial cost to pay in term of time).

In your case a simple solution is to put all source files inside the project folder, that is the folder containing these elements:

  • .settings folder
  • .cproject file
  • .project file

Img 01Img 01

The above SimplePrj example show this case. I generated it from the IDE using the [File > New > STM32 Project] menu command. Now, If I want to move that project I can copy and paste the project folder. To rename the project there are two options:

  1. Form the IDE, select the project with the cursor and right-click to open the context menu
    1. Select the command [Rename...] from the context menu
  2. manually edit the .cproject and .project file
    1. find and replace the original project name with the new one.

Note

Not always it is convenient to put all files inside the project folder, for example when you want to share some files between multiple projects (like the ST Middleware).

Another thing that can create issue in your scenario is if your project is using linked resources or virtual folder.

img_01.PNG

In the above example (available in ElooMTX-SDK in the stm32-hotspot github) the files highlighted in blue are real files inside the Src folder, but the files with a little arrow icon mark, like the red highlighted, are linked resource, that means the real file can be anywhere in the file system. This can be an issue when you copy and past the project folder. 

Last thing, be careful also at the way you specify the project settings. The recommendation is to use paths relative to the project folder like in the below image.

img_02.PNG

Have a good development time with STM32,

Stefano

Thanks to you both, Harvey and Stefano,

meanwhile I learnt that there exists the most intuitive way to clone a project in the project tree is - and that's was I was initially hoping it would work, but I was unable to detect the right protocol to do it - that you simply select the project with a right mouse click, click copy, then paste (leaving the selection as it is which is a bit confusing since no one wants to paste something into a selected item). You are the asked for the new name (default is the existing name with an incremental number attached). So easy.

 

 


CubeIDE, as every Eclipse based tool ... allows every developers to works as he prefer


That is exactly the thing the Eclipse's workspace and overall design doesn't allow. Read this post for details. If ST would make an IDE based on, for example, Code::Blocks, that could be a decent and worthy IDE. Now CubeIDE is just another bloated under-performing Frankenstein with PITA usability like all Eclipsoids are.

RhSilicon
Lead

This is one of the reasons the Arduino community is so big, just rename a file.

When you do a copy, you must make sure that the files you are editing, if you edit and use linked files, are the ones you think you want, not the ones in the older project.  Eclipse has an awkward way of linking files. 

I have a project with included files common to all such projects.  I have to put in absolute paths or eclipse won't find the files, (nor will it tell me where it THINKS they are).  Yet in other parts of the project, the workspace paths work just fine.

 

I have a very large and versatile swiss army knife.  It has computer tools and just about everything else I might need, including a spatula (and no idea why, makes me wonder about the designers). 

It is not what I'd call a rapid deploy tool.

In that sense, it's a lot like CubeMXIDE and Eclipse itself.

There are times that I suspect that the people who write the tools never use them, otherwise, they'd fix stuff, now....

 

There are times that I suspect that the people who write the tools never use them, otherwise, they'd fix stuff, now....

This! It is the case for these:

  • STM32 HAL API design. It still cannot even receive uninterrupted USART stream without ridiculous workarounds and even then it can do it only in DMA circular mode.
  • Eclipse, especially it's broken Workspace concept.
  • SalesForce, Khoros and other modern forums "community" platforms designed for housewives. Even the naming of things shows clearly that the designers don't know how the things are named, not even talking about understanding how the things should work.

That is apart from some people and whole teams being simply incompetent and incapable of doing better even if they tried...


@Piranha wrote:
  • Eclipse, especially it's broken Workspace concept.

 I already had to reinstall Eclipse once, because I couldn't find a way to solve this.