Florin-Popescu / avarice-unofficial

AVaRICE with support for newer devices
GNU General Public License v2.0
13 stars 8 forks source link

Compatibility with Arduino Nano Every #2

Closed maxgerhardt closed 3 years ago

maxgerhardt commented 3 years ago

First all, thanks for this fork, seeing UPDI support in avarice looks really promising!

For my issue: I'm unsure how to start avarice for my particular board.

It's a Arduino Nano Every with a ATMega4809 chip. It has a SAMD11 chip on board as a programmer. I can flash the firmware fine using avrdude with

avrdude -v -p atmega4809 -C "C:\Users\Max.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c jtag2updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m -Ulock:w:0xc5:m -b 115200 -V -e -D -P "COM20" -U flash:w:.pio\build\nano_every\firmware.hex:i ... Programmer Type : JTAGMKII_PDI Description : JTAGv2 to UPDI bridge M_MCU hardware version: 1 M_MCU firmware version: 6.00 S_MCU hardware version: 1 S_MCU firmware version: 6.00 Serial number: 00:00:00:00:00:00 Vtarget : 5.0 V .. avrdude done. Thank you.

So some firmware must be flashed on the SAMD11 that implements that JTAG2UPDI protocol The Arduino page says it's the Arduino MuxTO bootloader.

I can compile this program on linux just fine (just execute the last few lines in the build sh script), but when I start it with what I think is right I get

$ sudo ./avarice -j /dev/ttyACM0  -d --part atmega4808 -u  :4242 
AVaRICE version 2.14svn20200906, Feb 12 2021 17:43:24

JTAG config starting.
Attempting synchronisation at bitrate 115200

command[S, 1]: 53 45 20 20
<hangs here>

FYI, when plugging the device, dmesg shows

[ 2430.663748] usb 1-2: new full-speed USB device number 5 using xhci_hcd
[ 2430.934711] usb 1-2: New USB device found, idVendor=2341, idProduct=0058, bcdDevice= 1.00
[ 2430.934713] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2430.934715] usb 1-2: Product: Arduino Nano Every
[ 2430.934716] usb 1-2: Manufacturer: Arduino LLC
[ 2430.934717] usb 1-2: SerialNumber: E611C9CE5151363448202020FF161E41
[ 2430.936620] cdc_acm 1-2:1.0: ttyACM0: USB ACM device

When I try it with the -2 switch since avrdude says its using JTAG MK2..

$ sudo ./avarice -j /dev/ttyACM0  -d --part atmega4808 -u -2  :4242 
AVaRICE version 2.14svn20200906, Feb 12 2021 17:43:24

JTAG config starting.
Attempting synchronisation at bitrate 19200

command[0x01, 1]: 01 
recv: timeout

command[0x01, 2]: 01 
recv: timeout

command[0x01, 3]: 01 
recv: timeout
Attempting synchronisation at bitrate 115200

command[0x01, 1]: 01 
recv: timeout

command[0x01, 2]: 01 
^C

it tries a synchronization until it reaches 9600 baud and then hangs.

Is the Arduino Nano Every supported? How do I start avarice in this particular case?

Florin-Popescu commented 3 years ago

Hi,

I have only added support to the newer AVR families (so the UPDI protocol) via EDBG programmer (which uses the jtag3 class). But it looks to me like JTAG2UPDI is actually based on JTAG MK2, like you said. This programmer uses the class jtag2 in avarice, which would need to be modified to support the UPDI protocol.

So the answer would be that no, sadly it's not supported.

I can't really add the support for it since I don't have a device to test it on. But if you'd like to try to do it, I can assist you. You would need to take the changes I've done for the jtag3 class and port them to jtag2. They are described on the project's README and hopefully the implementation wouldn't be very different for the jtag2.

Florin-Popescu commented 3 years ago

Closing this since it's getting fairly old. Please let me know if you need further assistance.