Debugging an Arduino in Clion with Platformio Pluggin?

I’m trying to debug my project to get more detail on what is happening with my dynamically stored memory in my project. I’ve setup Clion (latest version) with platformio IO. I installed the core using python and pip install. I can build and upload to the board successfully but when I insert a breakpoint on a line and attempt to run the debugger, I get the error:

Debugger process ended with exit code 1

I have the Arduino framework installed I believe (I have the Arduino IDE, as well as the platformIO installed on VScode && Clion). Do I need additional drivers or any other framework in order to get the debugger working properly? If so, how do I go about installing that?

  • full platformio.ini?
  • judging from the environment name UNO it seems to me that you want to debug an Arduino Uno. Note that
    • PIO only has simavr, an AVR simulator, built in as a debugger on simulated hardware. it can still fully debug a program, though. It should have launched there, but somehow hasn’t – I’ll investigate.
    • if simulation is not wanted, the Uno needs additional hardware to be debuggable, e.g. via the debugWire protocol with an AVARICE debug probe or similiar. Not debugable (with line-by-line stepping etc.) with just the Uno and its built-in serial port itself
    • PIO does not yet have integrated support for debugging realHW regarding AVRs (unlike Atmel Studio)

Here is my platformio.ini.

Note: I happened to figure out the issue with my code without a debugger, however I think it would have certainly been helpful to have that tool at my disposal.

simavr would be fine I would guess, so long as it allows me to step through the program and check variable values and whatever else in memory.

The issue I was having was related to the limited SRAM of the Arduino Uno. I was trying to return a very large String at one time without checking for available memory or periodically flushing the serial buffer .

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = 
	mike-matera/ArduinoSTL@^1.1.0
	https://github.com/mpflaga/Arduino-MemoryFree.git

@maxgerhardt

Hey Max, any update as to why the debugger isn’t launching? I would appreciate any further help with this. Thanks! :slight_smile:

Same problem here. What is going on with it?!

Please post a new topic with the exact platformio.ini, code and hardware (microcontroller + debugger) setup that you are working with.