Operating System: Windows (MinGW or MinGW-w64) / Linux / macOS
Required Tools: Debug probe with software, cross-compiler toolchain
Build Targets: CMake / Makefile / Custom build targets
To debug on the chip, you need to create a special run/debug configuration. In CLion, you can quickly create the following GDB server configurations using the "New Embedded Configuration" wizard:
-
Segger J-Link GDB Server
-
Qemu as GDB Server
-
PyOCD
-
st-util (Open-source GDB server for ST-LINK debug probe)
-
ST-LINK_gdbserver (part of STM32CubeIDE)
-
PEmicro (OpenSDA)
You can also create a run/debug configuration for any debug probe software that complies with the GDB server protocol. To do this, add a new “Embedded GDB Server” configuration from the “Run/Debug Configurations” dialog.
👇 Click to Claim 👇
👉 C Language Knowledge Resource Collection
Before You Start
-
Configure the cross-compilation toolchain.
On Windows, switch to the System toolchain (recommended). Alternatively, you can use the MinGW / MinGW-w64 environment.
-
Ensure that the selected GDB server is installed on your computer. You do not need to start it manually: the configuration will automatically run the GDB server when you start the debugging session.
Create Embedded GDB Server Configuration
-
Select “Run | New Embedded Configuration” from the main menu.
-
In the opened wizard, set the following:
-
Always: Every time a debugging session is started.
-
If updated: Only when the binary file changes.
-
None: Skip downloading.
-
GDB Server Type: Select the type of GDB server. CLion will automatically predefine the parameters required for this server.
-
Location: Specify the full path to the binary file to be used as the GDB server.
For the STM32CubeIDE ST-LINK GDB server, specify the path to the STM32CubeIDE binary file.
For PE-Micro, specify the path to the platform-specific binary file.
-
Debugger: Choose the GDB debugger that will run on the CLion side and connect to the remote GDB server. Use the bundled GDB or your custom GDB binary.
-
Target and Executable Binary: Select the target to build and the executable binary to be downloaded to the device.
-
Download Executable File: Specify when to download the executable binary to the target device:
-
TCP/IP Port: Specify the port of the GDB server explicitly, or leave it blank to use a random port.
Click “Next.” On the next wizard page, you can adjust the settings for the selected GDB server type. For example, for the Segger JLink server, you can choose the transport interface type, initial speed, and device:
Click “Create.” A new run/debug configuration will be created with the necessary parameters set for the specified server. Check the next program to learn how to adjust it.
Popular Recommendations
-
Essential skills for working in a state-owned enterprise…
-
Far from it, you need to calculate your fortune before joining…
-
Humiliated by the interviewer…