I have a problem debugging the Arduino mega 2560 with an external ATMEL-ICE debugger. I have previously had success -with the help of maxgerhardt- to setup a custom tool for use with the Arduino Due, for the ATSAM3x8E microcontroller. However, the same setup fails with the Atmega 2560, for which I have simply selected “avr32” as a chip name (see platform.ini below). However, the OCD tool seems to expect SWD communication and not JTAG, and it complains about settings for the transport protocol (see terminal error messages down at the bottom of the page).
Could you please help me to set that up? I have managed to upload the code onto the board using the avr-stub, but the debugging is impossible as it complains about the (auto-detected) COM16 port which the debug software does not seem to understand.
; PlatformIO Project Configuration File (ATMEL - ICE mode) [env:megaatmega2560] platform = atmelavr board = megaatmega2560 framework = arduino debug_tool = custom upload_protocol = atmel-ice debug_init_break = tbreak setup debug_server = /Users/Thinkpad/.platformio/packages/tool-openocd/bin/openocd -d2 -s /Users/Thinkpad/.platformio/packages/tool-openocd/scripts -f interface/cmsis-dap.cfg -c "set CHIPNAME avr32" -c "source [find target/avr32.cfg]"
***Error message from the terminal, ATMEL-ICE debugger connected
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html debug_level: 2 avr32 Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.embedded:startup.tcl:128: Error: session transport is "swd" but your config requires JTAG
; PlatformIO Project Configuration File (avr-stub mode) debug_tool = avr-stub debug_port = COM16 lib_deps = jdolinay/avr-debugger@^1.5 ;use serial1 build_flags = -DAVR8_SWINT_SOURCE=6 -DAVR8_UART_NUMBER=1 -AVR8_BREAKPOINT_MODE=1
***Error message from the terminal, avr-stub mode connected
======================== [SUCCESS] Took 11.18 seconds ========================= Reading symbols from g:\Shared drives\Technical Development\Engineering\Development\ePATH Display\Git Repositories\Z1002 Tester\.pio\build\megaatmega2560\firmware.elf... done. PlatformIO Unified Debugger -> https://bit.ly/pio-debug PlatformIO: debug_tool = avr-stub PlatformIO: Initializing remote target... .pioinit:13: Error in sourced command file: COM16: No such file or directory.