PlatformIO Community

ATmega32U4 and JTAG

Hi,

I am trying to get JTAG to work with a Leonardo (ATmega32U4), but I am having problem understand what settings I need to set in platformio.ini,
Maybe someone out there knows what to set?

My setup:
Have a SEGGER JTAG+SWD programmer connect to PC with USB.
Device Manager says: Jlink CDC UART Port (COM3) (standard driver, see below)

The Leonardo pins 36-39, Reset, GND are connect to the SEGGER J-Link programmer pins according to the JTAG Interface/Wiring Connections on this page:
https://docs.platformio.org/en/latest/plus/debug-tools/jlink.html
I am powering the Leonardo with USB power as the JTAG adapter only give 3.3v and the board like 5v.

(The programmer works with another board and SWD in platformio.
The board works to update using USB Arduino Leonardo COM18.)

Leonardo JTAG env. settings in platformio.ini:

[env:leonardo]
platform = atmelavr
board = leonardo
framework = arduino

– log

Configuring upload protocol...
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
Looking for upload port...
Auto-detected: COM3
Forcing reset using 1200bps open/close on port COM3
Waiting for the new upload port...
Uploading .pio\build\leonardo\firmware.hex

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = "F"; type = @
    Software Version = !.w; Hardware Version = “.ð
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader
--

Tested changing USB driver using Zadig 2.5.
So, instead of having a COM3, I have a device under USB controller called J-Link driver.

– log

Configuring upload protocol...
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
--

Tested different combination of following settings:
debug_tool = jlink
upload_protocol = jlink-jtag
but get same error.
Don’t know how or what --upload-port I should specify.
So I guess I should stick with Windows default drivers?

Any suggestion what I can try?

Cheers
-Anders

How would you do this any tool at all? At [SOLVED] program Atmega32p using j-link edu - J-Link/Flasher related - SEGGER - Forum I read JLink + AVR target is not supported. Avrdude definitely doesn’t support it, too.

I saw the JTag pins (TDI, TDO, TMS, TCK) on this picture.

and then I read the datasheet from microchip:

(page 371 etc)

So then I thought it would try it out with my programmer and platformio…
I am totally new at this… so I have clearly misunderstood something.

Cheers
-Anders

Debugging via JTAG is possible, just not with the Segger JLink because the software (JLink.exe, avrdude, …) doesn’t have support for it.

Per here and here you can use other JTAG capable debuggers (foremost, an Atmel JTAG ICE and the AVR dragon) with the AVaRICE program to create a GDB server to enable the debugging functionality.

The avarice and PlatformIO has also been successfully demonstrated in other threads, e.g. CLion / Avarice debug not working - #5 by wirepirate