platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
139 stars 105 forks source link

avr-debugger support #205

Closed msquirogac closed 3 years ago

msquirogac commented 4 years ago

Support for the avr-debugger debug tool, requires this library.

There are three modes of operation:

To change between modes the user only has to add the following line to the platformio.ini file.

build_flags =
    -DAVR8_BREAKPOINT_MODE=2

Then, a complete platformio.ini file would look like this:

[env:328p16m]
board = 328p16m
debug_tool = avr_debugger
debug_port = /dev/ttyUSB0
build_flags =
    -DAVR8_BREAKPOINT_MODE=2
valeros commented 4 years ago

Hi @msquirogac ! Many thanks for the PR, looks great. Could you please take a look at the comments I left in the code? Thanks!

msquirogac commented 4 years ago

Any comment?

valeros commented 4 years ago

Hi @msquirogac ! Sorry for the late reply. I finally found some time to try this stub on real hardware. I was able to debug a simple blink application on Uno board with RAM breakpoints. The workflow is a bit clumsy, but it works. The main issue I encountered is that the avr-debugger library is not ready to be used out of the box. It compiles all available source files (in arduino, avr8-stub, bootloader folders) which leads to linker issues. Probably we need to provide a PR with fixes to the library manifest before merging this PR.