Howto upload to Arduino Nano Every via pymcuprog?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

 

I'm started programming the Arduino Nano Every Board and am trying to upload my code.

 

AFAIK there is a so called MuxTO running on the ATSAM on this board which manages UPDI programming via USB/serial.

I suppose that when not running in UPDI-mode (baud != 1200, is that correct?) all USART traffic from the ATmega can be read/written via USB/serial too?

 

So anyway, the tool pymcuprog should work to upload code to the ATmega?

 

I tried something like this:

# pymcuprog -u /dev/ttyACM1 -t uart -d atmega4809 ping
pymcuprog.serialupdi.link - WARNING - Check failed
pymcuprog.serialupdi.link - WARNING - Check failed
Traceback (most recent call last):
  File "/root/.local/bin/pymcuprog", line 8, in <module>
    sys.exit(main())
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/pymcuprog.py", line 249, in main
    return pymcuprog_main.pymcuprog(arguments)
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/pymcuprog_main.py", line 80, in pymcuprog
    status = _start_session(backend, device_selected, args)
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/pymcuprog_main.py", line 548, in _start_session
    backend.start_session(sessionconfig)
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/backend.py", line 363, in start_session
    self.programmer.setup_device(
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/programmer.py", line 78, in setup_device
    self.device_model = get_nvm_access_provider(self.transport,
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/nvm.py", line 42, in get_nvm_access_provider
    accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency, options=options)
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/nvmserialupdi.py", line 51, in __init__
    self.avr = UpdiApplication(port, baud, self.dut)
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/serialupdi/application.py", line 81, in __init__
    datalink.init_datalink()
  File "/root/.local/lib/python3.8/site-packages/pymcuprog/serialupdi/link.py", line 45, in init_datalink
    raise PymcuprogError("UPDI initialisation failed")
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed

 

The commandline arguments are probably correct. The yellow RX-LED on the Arduino also blinks. So maybe the SAM isn't in UPDI mode? Does pymcuprog even supports this way of programming?

 

Thanks for help and have a great day!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The on-board SAMD11 runs something like the jtag2updi protocol; I believe that's substantially different than the "bare UPDI" that pymcuprog uses.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's a list of supported interfaces in the documentation: 

 

on PyPi,  microchiptools wrote:
Supported devices and tools

pymcuprog is primarily intended for use with PKOB nano (nEDBG) debuggers which are found on Curiosity Nano kits and other development boards. This means that it is continuously tested with a selection of AVR devices with UPDI interface as well as a selection of PIC devices. However since the protocol is compatible between all EDBG-based debuggers (pyedbglib) it is possible to use pymcuprog with a wide range of debuggers and devices, although not all device families/interfaces have been implemented.

 

Debuggers / Tools

pymcuprog supports:

  • PKOB nano (nEDBG) - on-board debugger on Curiosity Nano
  • MPLAB PICkit 4 In-Circuit Debugger (when in 'AVR mode')
  • MPLAB Snap In-Circuit Debugger (when in 'AVR mode')
  • Atmel-ICE
  • Power Debugger
  • EDBG - on-board debugger on Xplained Pro/Ultra
  • mEDBG - on-board debugger on Xplained Mini/Nano
  • JTAGICE3 (firmware version 3.0 or newer)

Although not all functionality is provided on all debuggers/boards. See device support section below.

 

https://pypi.org/project/pymcuprog/

 

Also on the Project Homepage: https://github.com/microchip-pic...

 

EDIT

 

The Project Homepage wrote:
pymcuprog is a Python utility for programming various Microchip MCU devices using Microchip CMSIS-DAP based debuggers

 

So, I guess, the big question is: does the  on-board SAMD11 provide a CMSIS-DAP interface?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Jun 10, 2021 - 09:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found this topic usefull:

 

Uploading code to new Arduino NANO-EVERY

 

My current steps to get avrdude running:

1. add jtag2updi programmer to avrdude.conf

programmer
  id    = "jtag2updi";
  desc  = "JTAGv2 to UPDI bridge";
  type  = "jtagmkii_pdi";
  connection_type = serial;
  baudrate = 115200;
;

2. create a python script to enable updi-mode

#!/usr/bin/env python

import serial
import time
import sys

s=serial.Serial(sys.argv[1],1200)
s.setDTR(True)
time.sleep(0.5)
s.setDTR(False)

3. call avrdude

# ./updi_enable.py /dev/ttyACM1 && avrdude -v -p atmega4809 -c jtag2updi -P /dev/ttyACM1 
python-exec: Invalid impl in /etc/python-exec/python-exec.conf: python2.7

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM1
         Using Programmer              : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              1.07
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.07
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
         AVR Part                      : ATmega4809
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    1      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    1      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    1      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    1      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    1      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         64   64      0     0     0 0x00 0x00
           flash          0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGMKII_PDI
         Description     : JTAGv2 to UPDI bridge
         M_MCU hardware version: 1
         M_MCU firmware version: 1.07
         S_MCU hardware version: 1
         S_MCU firmware version: 6.07
         Serial number:          00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): part ATmega4809 has no PDI interface
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

 

I'd call this one closed for me :-)

 

Thanks for your help guys.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
So, I guess, the big question is: does the  on-board SAMD11 provide a CMSIS-DAP interface?

 

Correctly quoted... but the "serial updi" portion of pymcuprog doesn't actually need CMSIS-DAP at all, just a virtual serial port...