[RESOLVED]: avrdude w/ Arduino Nano Every: Can't upload any code to Arduino IDE

[RESOLVED: See comment #13]

I'm trying to run the example blink code. I've tried Arduino IDE 1.8.5, 1.8.9, & 1.8.10 and
Arduino megaAVR Boards v1.8.4 & 1.8.5 and seen mostly the same errors and nothing has worked yet.

OS: Windows 10 64-bi

Arduino: 1.8.9 (Windows 10), Board: "Arduino Nano Every, ATMEGA328"

Sketch uses 1118 bytes (2%) of program storage space. Maximum is 49152 bytes.
Global variables use 22 bytes (0%) of dynamic memory, leaving 6122 bytes for local variables. Maximum is 6144 bytes.
Forcing reset using 1200bps open/close on port COM10
C:\Users\Michael\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Michael\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM10 -b115200 -e -D -Uflash:w:C:\Users\Michael\AppData\Local\Temp\arduino_build_784176/Blink.ino.hex:i -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m {upload.extra_files} 

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

         System wide configuration file is "C:\Users\Michael\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
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    0      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    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      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(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_reset(): timeout/error communicating with programmer (status -1)
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)
avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)

avrdude done.  Thank you.

the selected serial port 
 does not exist or your board is not connected

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

avrdude gives such useful error messages here doesn't it? I count 4 separate error messages, all of which, taken literally, are mutually exclusive with the other errors.

No, I don't know what this sequence of errors means either (though the flash/boot section error/warning is spurious - it always shows up with jtag2updi programmer type, even when everything works).

I count 4 separate error messages

Theoretically, that makes sense, since the "upload" command involves multiple individual steps:

Prolog:

C:\Users\Michael\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Michael\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM10 -b115200

Chip erase:

-e -D

Upload sketch itself:

-Uflash:w:C:\Users\Michael\AppData\Local\Temp\arduino_build_784176/Blink.ino.hex:i

Program fuses:

-Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m

Bugs:

{upload.extra_files}

Have you made sure that your "board" package for megaAVR is up-to-date? (Tools/Board/BoardsManager//Update) - it looks like this package has been subject to quite a bit of "churn", and since it's handled separately, it would stay the same for different installed versions of the IDE. Current version seems to be 1.8.5 (although, avrdude of that seems to match what you're using. Maybe an older version would work better?) (avrdude support for atmega4809 seems to be pretty ... primitive.)

Well, how could one logically get:

timeout communicating with programmer (which should indicate that it opened the serial port and attempted to talk to the programmer, but the programmer didn't answer)

AND

initialization failed (this generally indicates that the programmer has responded that it attempted to program the target chip, but wasn't able to communicate with it)

AND

The selected serial port does not exist (how could it have attempted to communicate with the programmer and timed out, if the port doesn't exist?)

Should I just experiment with different versions each of these: Arduino IDE, the Arduino megaAVR Boards, and having the Registers Emulation set to None or ATMEGA328 ?

I can log all of the error codes. I really need to use this for a project due on Tuesday if at all possible or I'll need to order another Arduino board/use a TI launchpad that I already have but this fits my form factor the best.

Frankly, I'm suspicious that the board may be hosed.

Register emulation setting won't change anything (this effects compilation, not upload - also, avoid using the register emulation unless you have a gun to your head; the implementation is godawful under the hood - if you're doing direct port writes, look up the real m4809 registers in the datasheet). Arduino IDE version also shouldn't matter either.

Do you suggest I order another one to see if this one is just bad or to get a different board?

how could one logically get ... timeout, initialization failed ..., serial port does not exist ...

Well, as far as I can tell, avrdude, and/or the jtag2updi firmware, and/or the comm protocols involved, and/or some combination thereof, doesn't do a very good job of resetting to a known state after errors (or even after successful use.) In the process of the optiboot-x development, using avrdude with Microchip development boards, I "frequently" encountered situations where avrdude (and/or the Official tools) would fail to talk to the board (and the official EDBG or mEDBG chips) until it was actually power-cycled. :frowning:
So it wouldn't surprise me if a failure of some kind on the first piece of the upload would set things up for a different error on the second part up the upload.

(unfortunately, I don't think this helps the OP find a solution...)

You know, I think I have encountered that sort of thing too - though never with such spectacularly colorful errors. For that matter, I've also had a jtag2updi programmer fail (unable to revive via ISCP). It is still early days for megaavr and arduino.

I mean it does suggest powercycling the board...

May I ask, why the nano every?

Unless you need it's new features, you're probably better with a plain old nano 3.0 (not nano 33, another new board where as far as I can tell compatibility is even worse). The m4809 (in every) is a megaavr, rather than a classic avr like the m328p ( used in nano, pro mini, and ever popular uno, plus dozens of niche arduino compatible third party boards) - there are a lot of libraries floating around the internet that doesn't support them yet. I mean, they're pretty awesome parts, no joke, but it sounds like you're not super experienced with Arduino yet, and so the board about which there are a million guides and tutorials and examples is probably the wisest choice.

so a basic question: did you power-cycle it?
if I have this error I must disconnect the USB cable and connect it back

Something else you might try would be to press the reset switch on the nano every twice to put it into bootload mode, if you have a sketch running it could be interfering with the serial communications.

david_2018:
Something else you might try would be to press the reset switch on the nano every twice to put it into bootload mode, if you have a sketch running it could be interfering with the serial communications.

wrong advice. the double reset works with some bootloaders on MCU with native USB. this is not the case here. the USB is handled by the on board programmer

Juraj:
wrong advice. the double reset works with some bootloaders on MCU with native USB. this is not the case here. the USB is handled by the on board programmer

If I recall, I have done that with a nano every when I had a sketch outputting a lot of serial data at a high baud rate, not sure if it was just coincidence that I got it to program afterwards.

RESOLVED:

Well, I got a new Nano Every & regular Nano and they both worked so I guess that board was just bad. Thanks for the help though!

I got a Nano every just because I could and so far the only problem I found are the pin names printed only on the bottom, I treated it like I would do to a nano (except choosing the different board type) and so far it works...
I don't have any kind of beanchmarks to run so I can't say it's better or worst, but I still don't like the idea of having the usb interface on the main MCU.

ocsav:
I still don't like the idea of having the usb interface on the main MCU.

It's not. Nano Every uses a '4809 with a separate chip running (iirc) the mEDBG firmware to interface between USB and the UPDI interface.

The atmega4809 does not have native USB.

Sorry people, totally my mistake, don't know what I was thinking about.