Arduino Nano Every Unable to upload / program any sketch. (Error: RSP_ILLEGAL_MCU_STATE)

Arduino nano every used to work fine before flashing the below sketch containing software reset in loop.

Please find attached code and flashing log.

#include <avr/wdt.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>



void resetViaSWR() {
  _PROTECTED_WRITE(RSTCTRL.SWRR,1);
}
char* resetReason = NULL;

void setup() {
  Serial.begin(115200);
  Serial.println(resetReason);
}

void loop() {
  
  resetViaSWR();
  wdt_reset(); 
}
Arduino: 1.8.15 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

Sketch uses 2663 bytes (5%) of program storage space. Maximum is 49152 bytes.

Global variables use 177 bytes (2%) of dynamic memory, leaving 5967 bytes for local variables. Maximum is 6144 bytes.

Forcing reset using 1200bps open/close on port COM8

C:\Users\Mohammed Zaed\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Mohammed Zaed\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM8 -b115200 -e -D -Uflash:w:C:\Users\MOHAMM~1\AppData\Local\Temp\arduino_build_916747/incubator.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\Mohammed Zaed\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : COM8

         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(): bad response to reset command: RSP_ILLEGAL_MCU_STATE

avrdude: initialization failed, rc=-1

         Double check connections and try again, or use -F to override

         this check.



avrdude: jtagmkII_close(): bad response to sign-off command: RSP_ILLEGAL_MCU_STATE



avrdude done.  Thank you.



An error occurred while uploading the sketch



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

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.