PlatformIO doesn’t officially support debugging real 8-bit AVR hardware, but:
- Atmega32 debugging with avarice and avr-gdb is a thread about using a ATATMEL-ICE with the avarice software as a GDBserver. The debug probe originally costs ~100€, clones can be built cheaper. Avarice can also work with the cheaper AVRDragon, ~50€.
- VSCode PIO debugger for AVR is thread about integrating the dwire-debug program into PIO, which also opens up a GDB server. Uses the debugWIRE debugging technology via the (bi-directional) reset line, only needs a serial adapter and a diode as hardware.
Once you have a working debug probe connected to the target and a program which can open a GDB server, PlatformIO can connect to using it’s normal avr-gdb
gdbclient and you can debug as normal. Also see options in docs.