Home Getting Started About Download Source Report An Issue

Debugging embedded systems with CLion and Bloom

Because Bloom exposes the connected target via a GDB RSP debug server, any IDE with GDB RSP client capabilities can interface with Bloom to gain access to the target. The CLion IDE is equipped with GDB RSP support.

Once you have installed Bloom and created a project configuration file, you can follow the steps below to setup a debug configuration in CLion.

Installing the GDB client

For debugging AVR microcontrollers, CLion must be configured to use the avr-gdb client. This can be installed via the following command (assuming support for the APT package manager):

$ sudo apt-get install gdb-avr;

Setup a "GDB Remote Debug" configuration in CLion

To configure CLion to interface with Bloom, a "GDB Remote Debug" configuration must be created. To do this, follow the steps below:

1. From CLion, open the "Run/Debug Configurations" window via Tools -> Edit configurations

The Clion Run/Debug Configurations window

2. From the "Run/Debug Configurations" window, create a new "GDB Remote Debug" configuration:

Adding a new GDB Remote Debug configuration in CLion, for Bloom

3. Locate the avr-gdb executable and set the server address & port. If you didn't set the ipAddress or port debug server parameter in your project configuration file, you will need to use the default values (localhost/ and 1442).

You will also need to select the symbol file to pass to avr-gdb. This will be the ELF output from your compiler.

Adding a new GDB Remote Debug configuration in CLion, for Bloom

When compiling your AVR code, be sure to enable the compiler option for including debug information in the compiler output (for avr-gcc/g++, this can be done via the -ggdb compiler flag).

Start Bloom and begin debugging

You should now be ready to begin debugging. Run Bloom from your project directory:

$ cd /path/to/project; $ bloom [ENVIRONMENT];

Replace "[ENVIRONMENT]" with your environment name, or leave blank to have Bloom fallback to the "default" environment.

Bloom will report when it is ready to accept incoming connections:

2021-04-14 23:11:36 BST [DS] [36]: [INFO] Starting DebugServer 2021-04-14 23:11:36 BST [DS] [37]: [INFO] GDB RSP address: 2021-04-14 23:11:36 BST [DS] [38]: [INFO] GDB RSP port: 1442 2021-04-14 23:11:36 BST [DS] [40]: [INFO] DebugServer ready 2021-04-14 23:11:36 BST [DS] [41]: [INFO] Waiting for GDB RSP connection

If Insight is enabled, the Insight window will appear automatically.

Bloom Insight

See Insight documentation for more on how to use the Insight window.

At this point, you can begin a debug session in CLion by clicking Run -> Debug and selecting the newly created debug configuration.