A brief desciption of my situation:
I want to debug a Atmel ATmega 328P using an AVR Dragon. The hardware is working: I can successfully initiate a debugging session in Atmel Studio. I can also start a debug session using avarice (on linux), gdb and step through the code.
The debugger of PlatformIO (VSCode) is also working (albeing it not as stable as the previous two), but not on CLion. When the debug session is starting, the debugger is stuck on ‘Loading’ in the Thread-1 pane and ‘Collecting data’ on the Variables pane. After a few seconds, it crashes (or at least, the debug session stops, avarice keeps running in the background). A debug log:
Preparing firmware for debugging...
Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (custom) On-board (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr 5.1.0
- toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Checking size .pio/build/uno/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 11.4% (used 234 bytes from 2048 bytes)
Flash: [= ] 8.2% (used 2632 bytes from 32256 bytes)
========================= [SUCCESS] Took 0.27 seconds =========================
Reading symbols from /home/WirePirate/CLionProjects/untitled/.pio/build/uno/firmware.elf...done.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target...
0x00000000 in __vectors ()
PlatformIO: Initialization completed
warning: Can not parse XML memory map; XML support was disabled at compile time
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
And my platformio.ini:
[env:uno]
platform = atmelavr
board = uno
upload_protocol = dragon_isp
framework = arduino
upload_flags = "-e"
board_upload.require_upload_port = false
debug_server =
avarice
--dragon
--debugwire
:4242
debug_tool = custom
debug_port = :4242
debug_init_cmds =
target remote $DEBUG_PORT
debug_load_cmds =
file "$PROG_PATH"
file /home/WirePirate/CLionProjects/untitled/.pio/build/uno/firmware.elf
load
This is the same config used to run the debug session in VSCode. If anyone has a hint, I’m eager to hear it. Since it is even working in VSCode, this is propably a PlatformIO bug.