Make Ozone projects portable

From SEGGER Knowledge Base
Jump to navigation Jump to search

Whenever Ozone loads an ELF file for debugging, it will automatically try to find the source files referenced in that ELF file. An issue, however, is that most compilers will save paths to these files as an absolute path. If you want to move the project to another folder or even a different computer, you will find that source files can't be referenced anymore as their absolute paths have changed.

This article explains how to ensure that your Ozone projects (.jdebug files) remain portable, so that source-file references are found regardless of the host system in use.

How to do it

Whenever you use the project wizard to create a new Ozone project and save the project file, Ozone will automatically try to make the project portable right from the start. There is a prerequisite, however: The referenced ELF file and corresponding source files must either be in the same folder as the Ozone project or in the same path tree below.

If your project does not meet this requirement, the default ELF file location will be set with an absolute path, and the default path replacement will not work (out of the box). But this can be fixed easily if you edit the entries Project.AddPathSubstitute() and File.Open(). Proceed as follows:

  1. In File.Open() the path to the ELF file is set. This function also supports relative paths. Simply edit this line to give your project setup a relative path, so that it stays portable.
  2. Project.AddPathSubstitute() either fully or partially replaces the absolute path string of your source files referenced in the ELF file. Ozone will try to automatically fill in the correct parameters; but, depending on your project's structure, it might not fit correctly. You can verify whether or not the path replacement worked in Ozone by clicking View->Source Files. If the file is not found, there will be a small warning icon next to it. The path currently being tried is found in the path row.

Example

The following example project shows a simple setup where auto-generated paths for portability via Ozone are not sufficient:

Ozone_Portable_Project_Example.zip

  • Unzip the archive, and open the Ozone folder.
  • Here, you will find the Ozone project file .jdebug.
  • Open the file with Ozone.
  • You will now receive error messages stating that the ELF file can't be found.
  • To fix this, close Ozone and open the .jdebug file in a text editor.
  • Search for call "File.Open".
  • You will notice that there is an absolute path here that fits the original host PC with which the project was created, but not yours.
  • Edit as follows: File.Open ("../Output/Debug/Exe/Ozone_Portable_Project_Example.elf");
  • Now, save the file and open it in Ozone again. This time, you will be able to successfully load the ELF file, as the ELF file path is now portable.
  • You will see, however, that file main.c could not be found. This is because the entries for "Project.AddPathSubstitute" are not correct.
  • Edit as follows: Project.AddPathSubstitute ("C:/Users/Nino/Documents/SEGGER Embedded Studio for ARM Projects/Ozone_Portable_Project_Example", "$(ProjectDir)/..");
  • Do the same for the lowercase variant.
  • Now, save the project file, and open it with Ozone again.
  • The source files should now be displayed correctly in Ozone.

If everything went well, your project should be now portable, regardless of its location or your host OS.