Copy my CodeWarrior Project

I have a project working, and then I want to do a copy. Unfortunately, this is not as simple as it should be :-(. In order to copy a project with all the settings, some knowledge about the internals of the project structure is required, which is the topic of this post.

In “Copy my Project” I was using a ColdFire V2 project which is not an easy case, as is using a Target Task to flash the microcontroller. Fortunately, all other targets in CodeWarrior for MCU are *not* using target tasks :-). With little help and preparation, a copy a project is not that difficult to do.  I’m showing how to do this with the FRDM-KL25Z project I have created in this post.

Clone with Copy-Paste

Eclipse projects can be easily copied with a copy-paste operation. That works pretty well, except for the CodeWarrior debugger settings. They are not updated/copied all the way through, at least not up to CodeWarrior for MCU10.3 beta.

There are a few things tied to the project name, and at least in 10.3 beta some are ‘hard coded’. So changing the ‘base’ project a bit will help me to copy it later. So I explain first what the (file) dependencies are, followed by some project adjustments which make the copy easier later one. And finally I’ll show how to do this with an actual project :-).

Project Name Dependencies

There are a few files in the project which are sharing the project name. Namely the output files (Linker ELF file and related output files) and the debugger/launch configuration files:

Files with Project Name Dependency

Files with Project Name Dependency

The *.pemicro file is a text file which keeps the last P&E connection settings. As long as I go with the defaults, I can ignore that file for now.

There is one more file in the Debugger folder: the *.launch file which is filtered by default. To show it inside the project structure, I use the Filters… menu:

Project Filters Menu

Project Filters Menu

That way I can disable the filter for Launch Configurations in the project view:

Disabled Filter for Launch Configurations

Disabled Filter for Launch Configurations

Now that file shows up (I need to press F5 or do a ‘Refresh’ on the project):

Launch Configuration File Visible in Project

Launch Configuration File Visible in Project

💡 I can export any Eclipse Launch Configuration to a file using the menu File > Export > Run/Debug > Launch Configurations.

While I have now the launch configuration visible, two other things are missing: the RSE (Remote System Explorer) target and connection settings (see “Flashing with a Button (and a Magic Wand)”). To enable the settings file, I need to remove the filter for ‘Referenced Remote System Settings’:

Disabled Filter for Referenced Remote System Settings

Disabled Filter for Referenced Remote System Settings

Now the ReferencedRSESystems.xml file shows up (a F5/Refresh might be needed):

➡ In earlier CodeWarrior/Eclipse versions this file is named as ‘rseHostSettingsCache.xml’

ReferencedRSESystems.xml

ReferencedRSESystems.xml

❗ Important Note: This .xml file is a ‘cache’ file, and has the debugger target and connection settings used by that project. It is updated automatically in the background by Eclipse. To make sure that the cache is flushed, I close the project to make sure the latest information is stored in it. Modifications in this file should only be done with having the project closed in Eclipse.

Now I have at least all the dependencies with the project name shown in my project structure.

💡 As the .lauch and ReferencedRSESystems.xml files are needed debugger files for my projects, I always store them in my version control system (e.g. SVN). If I don’t have them in my version control system, then I do *not* have any debugging settings for my project.

😥 The fact that there is no way in the Eclipse RSE system to store the connection and target settings in a file inside the project and loaded automatically is a major problem in my view. Having the RSE cache file is better than nothing, but really painful. I hope that in future Eclipse versions this will be improved. So for now it means dealing with this ReferencedRSESystems.xml file.

Building: Using ${ProjectName} for Artifact

The project created used by the standard CodeWarrior projects (at least in MCU10.3beta) has the output (artifact) name defined like this in the project properties:

Build Artifact Name

Build Artifact Name

I can give my output/artifact file any name, but it makes sense to have it named after the project name. But with above, I have to change that name after I have copied it. A better way is to use the variable ${ProjName}:

Using ProjectName Variable for Artifact Name

Using ${ProjectName} Variable for Artifact Name

Debugging: Using Variables to Name the Application

In a similar way, the Application name is used in the debug/launch configuration:

Application Name in Debug Configuration

Application Name in Debug Configuration

Instead of using the hard-coded naming, I can use ${ConfigName}/${BuildArtifactFileName}:

Variables for Application Name

Variables for Application Name

Copy/Clone of a Project – Step by Step

To copy or clone a project is simple:

a) select the project, then use copy in the context menu (or CTRL+C):

Copy of a Project

Copy of a Project

b) and paste (or CTRL+V) it in the workspace. It will ask me to specify the new project name:

Name for new project

Name for new project

This creates a new project for me.

The good thing: the content of the .launch file and the *.pemicro file are OK and updated as needed. The not so good thing: the files names are still the same:

Copied Project

Copied Project

The file name of the launch file (and consequently the one of the *.pemicro) does not really matter. The Eclipse IDE will load any *.launch file inside the project and add it to the launch configurations. But to be consistent, I rename the *.launch and *.pemicro files to match my project name:

Renamed launch and pemicro files to match project settings

Renamed launch and pemicro files to match project settings

What is now an issue is that my copied project still references the connection and target settings of the base/source project. This is obvious when inspect my Debug launch configuration:

Connection Setting in Copied Project

Connection Setting in Copied Project

This means, my copied project will all use the same (shared) connection settings of the base project:

Shared Connection and Target Settings

Shared Connection and Target Settings

That might not be a problem at all. If I copy a project, then I might want to use the same shared settings. However, in my opinion I would like to have the copy a full (deep) copy. I want to have the connection settings copied too:

Copy of Connection and Target Settings

Copy of Connection and Target Settings

It is possible to copy the Connection and Target settings with the Remote Systems View. That view is accessible with the menu Window > Show View > Remote Systems:

Connection and Target Settings in the Remote Systems View

Connection and Target Settings in the Remote Systems View

To copy the Connection and Target Settings, I can select both entries and use the ‘Copy…’ context menu:

Copy of Target and Connection inside Remote Systems View

Copy of Target and Connection inside Remote Systems View

It will ask me which profile to use (on my machine) which I simply can confirm:

active profile

active profile

Then it allows me to give the Connection Settings a new name:

Copy of Connection

Copy of Connection

And the same for the Target Settings:

Copy of Target

Copy of Target

Now I have both the Target and the Connection Settings duplicated:

Remote Systems with copied Target and Connection Settings

Remote Systems with copied Target and Connection Settings

Now I can use the context menu on the Connection and apply it to my project debugger launch configuration:

Apply Connection to Project

Apply Connection to Project

Unfortunately such a ‘apply’ menu does not exist for the connection. So I need to make the linkage from the Target to the new Connection from within the Connection properties. For this I select the Connection and use the Properties menu and then assign the new Target:

Assigning new Target Settings

Assigning new Target Settings

Now I have my copy of the Target and Connection Settings for my new project. An alternative way to accomplish this would be to change the ReferencedRSESystems.xml directly:

  1. Close the project so the cache is updated in the file
  2. Open the file and edit the XML file. In our example to replace ‘Freedom_LED’ with ‘Copy of Freedom_LED’. Save the file.
  3. Re-Open the project in Eclipse again.

💡 Modifying that XML file could be part of a script for automatic copy of a project.

Summary

In summary, here is how copy or clone a project:

First, I make sure my base/source project is set up like this so do not need to update the artifact or application file name for the debugger:

  1. Use ${ProjectName} for the Artifact name in the project build settings.
  2. Use ${ConfigName}/{BuildArtifactFileName} for the Application name to debug.
  3. Disable the project filters for the *.launch and the RSE *.xml cache file.

To copy the project and as well the Connection and Target settings:

  1. Select the project, copy (CTRL-C) and paste it (CTRL-V) and give it a new name.
  2. Rename the .launch and .pemicro files
  3. In the Remote Systems view copy and rename the Connection and Target Settings
  4. Apply the Connection setting to the new project
  5. Go into the Connection properties and assign the new Target Settings

➡ If I have copied the project with existing make files and object files, it is a good idea to do a Project > Clean, see this post.

Happy Cloning 🙂

9 thoughts on “Copy my CodeWarrior Project

  1. Hello,
    I have to copy a project into same work space with different name.
    I followed the steps mentioned by you.
    I got the problem (at step 2) in debug configuration setting, When I copied ” ${ConfigName}/{BuildArtifactFileName} ” this into application field i got the error as ” The application file specified in the launch configuration does not exist ”
    And if I go on following further steps at the end I do not see Run/Debug (open SDA connection) download option.
    Could you please state what may have gone wrong?

    Like

    • Hi Amreen,
      looks like I missed a ‘$’ in the text (the screenshot is showing the correct string). It should be
      ${ConfigName}/${BuildArtifactFileName}
      I have updated the post. Thanks for finding this bug!

      Like

      • Hello Erich Styger,
        I have followed above steps to copy example code of ADC demo in CW 10.3
        The new name of Project is “CopyOf_adc_demo”.
        My .map and .elf file are with the previous name of project.
        I think it should be with new name of project.
        Could you please guide me?

        Like

        • Hi Amreen,
          the elf output file is configured in the Build artifact settings (see section Building: Using ${ProjectName} for Artifact). Try to specify your name there directly without the usage of variables (e.g. just say CopyOf_adc_demo). If you have not cleaned up your project, the the previous .elf/.map file still might exist on your harddisk.

          Like

  2. Hi Erich,

    Thank you for your tutorial. I’m using KL05Z board, Codewarrior 10.6
    I copy the sample project “Led_Blink” , also copy a file from another project to current project.
    For example : The error is “common.h: no such file or directory”.

    I solved the problem by two way:

    1>. Create the new file that compiler don’t “see”, Copy the content of the old file and paste to the new one.
    2>. property on the file that compiler can’t detect =>Resource=> edit Location ( by copying it from original location to Project Header file of project copied.

    My question is , why this happened ? _the original project get these file from other folder, not Project Header file , and It works fine. But when I copy it and then the compiler can’t detect these file and forces me to take them into Project Header file.

    I think you used to face with this issue,

    Please share with me your experience ,

    thank a lot,
    Minh.

    Like

    • Hi Minh,
      it all depends how common.h is references from your original project. Probably it is project relative (take the current project as base, go up one folder, go into xxx folder, and here is the common.h). If you now copy your project to a different place, then of course that relative reference does not work any more. So you need to design your project and project file references in such a way that it fits your needs.

      Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.