Debugging AVR chips with debug adapters (using JTAG/PDI/UPDI/debugWire) with open-source tools is basically an unstable nightmare and not included in PlatformIO, for reasons explained in PIO Unified Debugger for AVR ¡ Issue #95 ¡ platformio/platform-atmelavr ¡ GitHub.
PlatformIO does have simulator tools included (simavr) and avr-stub, but these donât seem to be applying to your chip.
The only tool that seems to be able to do PDI (which you seem to use?) with an Atmel-ICE is AVaRICE . You would have to compile it for your operating system from source (e.g. with MinGW64 / MSys2 under Windows). Once you have that program, you can check the options to see
> avarice --help
AVaRICE version 2.14svn20200906, Oct 16 2021 10:40:06
Usage: avarice [OPTION]... [[HOST_NAME]:PORT]
Options:
-h, --help Print this message.
-1, --mkI Connect to JTAG ICE mkI (default)
-2, --mkII Connect to JTAG ICE mkII
-3, --jtag3 Connect to JTAGICE3 (Firmware 2.x)
-4, --edbg Atmel-ICE, or JTAGICE3 (firmware 3.x), or EDBG Integrated Debugger
-B, --jtag-bitrate <rate> Set the bitrate that the JTAG box communicates
with the avr target device. This must be less
than 1/4 of the frequency of the target. Valid
values are 1000/500/250/125 kHz (mkI),
or 22 through 6400 kHz (mkII).
(default: 250 kHz)
-C, --capture Capture running program.
Note: debugging must have been enabled prior
to starting the program. (e.g., by running
avarice earlier)
-c, --daisy-chain <ub,ua,bb,ba> Daisy chain settings:
<units before, units after,
bits before, bits after>
-D, --detach Detach once synced with JTAG ICE
-d, --debug Enable printing of debug information.
-e, --erase Erase target.
-E, --event <eventlist> List of events that do not interrupt.
JTAG ICE mkII and AVR Dragon only.
Default is "none,run,target_power_on,target_sleep,target_wakeup"
-g, --dragon Connect to an AVR Dragon rather than a JTAG ICE.
This implies --mkII, but might be required in
addition to --debugwire when debugWire is to
be used.
-I, --ignore-intr Automatically step over interrupts.
Note: EXPERIMENTAL. Can not currently handle
devices fused for compatibility.
-j, --jtag <devname> Port attached to JTAG box (default: /dev/avrjtag).
-k, --known-devices Print a list of known devices.
-L, --write-lockbits <ll> Write lock bits.
-l, --read-lockbits Read lock bits.
-P, --part <name> Target device name (e.g. atmega16)
-r, --read-fuses Read fuses bytes.
-R, --reset-srst External reset through nSRST signal.
-V, --version Print version information.
-w, --debugwire For the JTAG ICE mkII, connect to the target
using debugWire protocol rather than JTAG.
-W, --write-fuses <eehhll> Write fuses bytes.
-x, --xmega AVR part is an ATxmega device, using JTAG.
-X, --pdi AVR part is an ATxmega device, using PDI.
HOST_NAME defaults to 0.0.0.0 (listen on any interface).
":PORT" is required to put avarice into gdb server mode.
Example usage:
avarice --jtag /dev/ttyS0 :4242
avarice --dragon :4242
The first test would be whether avarice can connect to the chip through the Atmel-ICE at all. Youâd probably have to use a command like
avarice --jtag3 --pdi :4444
If, and only if, that seems to indicated success, you can integrate in PlatformIO through the platformio.ini
similiar as shown in here.