JetBrains CLion

From SEGGER Knowledge Base
Jump to navigation Jump to search

JetBrains's CLion is a J-Link compatible 3rd party IDE that supports most J-Link features. To be used with a J-Link the J-Link software and documentation package and ARM GNU Toolchain need to be installed separately. There are multiple ways configuring J-Link as debug probe, we currently recommend the Debug Server feature.

Requirements

Configuring CLion for J-Link usage

Configure the toolchain

As toolchain we recommend the ARM GNU Toolchain which needs to be installed separately. Once installed the toolchain needs to be configured in CLion's settings.

  1. Open the settings in section Build, Execution, Deployment / Toolchains.
  2. Create a new toolchain using the "System" preset.
  3. Paste the paths to the executables of the ARM GNU Toolchain C Compiler and C++ Compiler in the corresponding fields.
  4. As Debugger the Bundled Debugger or the one from the ARM GNU Toolchain can be used.
    We performed most of our tests with the latter.

CLion ToolchainConfig.png

Configure the Debug Server

The Debug Server implementation offers a preset called SEGGER J-Link which will mostly work out of the box.

  1. Click the "+" symbol and create a new Debug Server using the "SEGGER J-Link" preset
  2. Select the target device out of a list of supported devices.
    CLion DebugServer DeviceSelection.png
    • Option A) Configure a set of Debug Servers each for J-Link with a different target device to choose from.
    • Option B) Configure only one Debug Server for J-Link and edit the target device in that config each time the target is changed.
  3. In the Debug Server's Device Settings select Update executable to device: If updated
    so that the executable is only downloaded to the target when necessary.
    CLion DebugServer UploadExecutable.png

A more structured list of supported devices can also be found on segger.com.

Using a CLion project with J-Link

The following steps assume the configuration steps were already performed.

Select the build system

CLion is mostly built around CMake, which allows for easily configurable cross-platform build-processes.
The IDE holds a few presets, that define a set of build options that can be selected in the settings.

  1. Open the settings in section Build. Execution, Deployment / CMake.
  2. Select the Debug - Debug preset, which relies on the System toolchain configuration.
    CLion CMakePreset.png

Select the Debug Server

  1. Select the Debug Server J-Link config
  2. Change the target-device if necessary

Start debugging

Click the bug symbol or press shift+F9 to start the debugging session.
CLion StartDebugging.png

The screenshot below shows an example of a debugging session.
Note that the peripherals view requires a CMSIS-SVD file for the connected device, which can be obtained from the device's manufacturer. CLion Example DebuggingSession.png