Launching Ozone from VS Code

From SEGGER Knowledge Base
Jump to navigation Jump to search

This article describes how to launch SEGGER Ozone from within Visual Studio Code (VS Code).

That approach relies on the builtin VS Code tasks feature which can be configured via a JSON file (see https://code.visualstudio.com/docs/debugtest/tasks).

NOTE: Make sure to adapt the arguments below according to your specific project requirements (e.g. -device <your_device>). The supported command-line arguments are explained in detail in the Ozone User Guide & Reference Manual (https://www.segger.com/downloads/jlink/UM08025_Ozone.pdf).

HOW TO

  1. Obtain Ozone: https://www.segger.com/products/development-tools/ozone-j-link-debugger as well as any required license (if applicable).
  2. Install Ozone and make sure the path to ozone is within the $PATH environment variable.
  3. Edit the file .vscode/.tasks.json located in your VS Code workspace (if the file does not yet exist, then you may create it).
  4. Add a task according to this pattern:
    • If NOT using the VS Code CMake extension:
      {
      	"version": "2.0.0",
      	"tasks": [
      		{
      			"label": "Launch Ozone",
      			"type": "shell",
      			"command": "ozone -device STM32F746NG -select USB -if SWD -project dbgWithOzone.jdebug -programfile <path_to_the_application_elf_file>",
      			"problemMatcher": []
      		}
      	]
      }
      
    • If using the VS Code CMake extension:
      {
      	"version": "2.0.0",
      	"tasks": [
      		{
      			"label": "Launch Ozone",
      			"type": "shell",
      			"command": "ozone -device STM32F746NG -select USB -if SWD -project dbgWithOzone.jdebug -programfile ${command:cmake.launchTargetPath}",
      			"problemMatcher": []
      		}
      	]
      }
      
      In the case that the CMake-extension is being used, then ${command:cmake.launchTargetPath} automatically resolves to the build-target of the CMake project currently selected in VS Code.
  5. Launch the task by using the Command Palette (Ctrl+Shift+P), filtering on 'task' and selecting Tasks: Run Task and then choosing Launch Ozone from the drop-down list that gets shown.