Make Ozone projects portable

From SEGGER Wiki
Jump to: navigation, search

Whenever Ozone loads an elf file for debugging it will try to find the source files referenced in that elf file automatically. However most compilers will save the paths to these files with an absolute path. If you now want to move the project to another folder or even other computer the source files suddenly can't be referenced anymore as their absolute paths have changed. This article will explain how you can still make your Ozone projects (.jdebug file) portable so the source file references will be found no matter the host system.

How to

Whenever you create a new Ozone project with the project wizard and save the project file Ozone will already try to automatically make the project portable. There is a prerequisite however, the referenced elf file and corresponding source files must be in the same folder as the Ozone or in the same path tree below.

If your project setup does not meet that 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 simply fixed by editing the entries of Project.AddPathSubstitute() and File.Open().

  1. In File.Open() the path to the elf file is set. This function also supports relative paths. So simply edit this line to fit your project setup with a relative path so it stays portable.
  2. Project.AddPathSubstitute() replaces fully or partially the absolute path string of your source files referenced in the elf file. Ozone will try to automatically fill this with the correct parameters, but depending on your project structure it might not fit correctly. You can verify if the path replacement worked in Ozone under View->Source Files. If the file is not found there will be a little warning icon next to it. The currently tried path can be found in the Path row.


The following example project will show a simple setup where the auto-generated paths for portability by Ozone are not sufficient:

  • Unzip the archive and open the Ozone folder.
  • Here you will find the Ozone project file .jdebug.
  • Open it with Ozone.
  • You will now get error messages 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 noticed that there is an absolute path here that fits the original host PC where the project was created with but not yours.
  • Simply edit it as follows: File.Open ("../Output/Debug/Exe/Ozone_Portable_Project_Example.elf");
  • Now save the file and open it in Ozone again. This time loading the elf file will work as the elf file path is now portable.
  • But you will see that file main.c could not be found. This is because the entries for "Project.AddPathSubstitute" are not correct.
  • Simply edit it as follows: Project.AddPathSubstitute ("C:/Users/Nino/Documents/SEGGER Embedded Studio for ARM Projects/Ozone_Portable_Project_Example", "$(ProjectDir)/..");
  • The same for the lower case variant.
  • Now save the project file and open it with Ozone again.
  • You should now see the source files showing up correctly in Ozone.

If everything went correctly your project should be now portable, no matter the host OS or location.