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.
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
2. From the "Run/Debug Configurations" window, create a new "GDB Remote Debug" configuration:
3. Locate the avr-gdb executable and set the server address & port. If you didn't set the
port debug server parameter in your
project configuration file, you will need to use the default values (localhost/127.0.0.1 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.
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] : [INFO] Starting DebugServer 2021-04-14 23:11:36 BST [DS] : [INFO] GDB RSP address: 127.0.0.1 2021-04-14 23:11:36 BST [DS] : [INFO] GDB RSP port: 1442 2021-04-14 23:11:36 BST [DS] : [INFO] DebugServer ready 2021-04-14 23:11:36 BST [DS] : [INFO] Waiting for GDB RSP connection
If Insight is enabled, the Insight window will appear automatically.
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.