MCUdude / MegaCoreX

An Arduino hardware package for ATmega4809, ATmega4808, ATmega3209, ATmega3208, ATmega1609, ATmega1608, ATmega809 and ATmega808
GNU Lesser General Public License v2.1
247 stars 52 forks source link

Arduino Nano Every sketch upload issue -- no 1200bps reset trick employed #161

Closed mcuee closed 2 years ago

mcuee commented 2 years ago

As of now MegaCoreX does not support the optiboot bootloader for Arduino Nano Every. https://github.com/MCUdude/MegaCoreX#arduino-nano-every

If we look at the Nano Every pin-out from MegaCoreX, it is possible to use the alternative UART fo the bootloader (UART 1/2/3) if we keep UART 0 for the on-board jtag2updi programmer usage.

Reference schematics: https://content.arduino.cc/assets/NANOEveryV3.0_sch.pdf

However, burning the bootloader will fail (choose UART1 default pins) using the default jtag2updi programmer. It seems that MegaCoreX does not apply the 1200bps trick for this board.

"C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude" "-CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf" -v -patmega4809 -cjtag2updi -PCOM12 -e "-Ufuse0:w:0x00:m" "-Ufuse1:w:0x54:m" "-Ufuse2:w:0x01:m" "-Ufuse4:w:0x00:m" "-Ufuse5:w:0b11001001:m" "-Ufuse6:w:0x06:m" "-Ufuse7:w:0x00:m" "-Ufuse8:w:0x02:m" "-Ulock:w:0xC5:m"

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM12
         Using Programmer              : jtag2updi
avrdude: jtagmkII_getsync() attempt 1 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 2 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 3 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 4 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 5 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 6 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 7 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 8 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 9 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 10 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync(): timeout/error communicating with programmer (status -1)
avrdude: opening programmer "jtag2updi" on port "COM12" failed

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1
mcuee commented 2 years ago

Looks like Nano Every sketch upload support is broken since the 1200bps trick is not employed, even using the on-board programmer and not using bootloader.

The following is using the onboard jtag2updi programmer to upload the blink sketch.

Edit: this may work. Please refer to the later comments.

"C:\\Users\\xiaof\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\xiaof\\AppData\\Local\\Temp\\arduino_build_488130/Blink.ino.elf"
Sketch uses 752 bytes (1%) of program storage space. Maximum is 49152 bytes.
Global variables use 4 bytes (0%) of dynamic memory, leaving 6140 bytes for local variables. Maximum is 6144 bytes.
C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude -CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM12 -Uflash:w:C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.with_bootloader.hex:i -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x01:m -Ufuse4:w:0x00:m -Ufuse5:w:0b11001001:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m 

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM12
         Using Programmer              : jtag2updi
avrdude: jtagmkII_getsync() attempt 1 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 2 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 3 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 4 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 5 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 6 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 7 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 8 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync() attempt 9 of 10: sign-on command: status -1
An error occurred while uploading the sketch
avrdude: jtagmkII_getsync() attempt 10 of 10: sign-on command: status -1
avrdude: jtagmkII_getsync(): timeout/error communicating with programmer (status -1)
avrdude: opening programmer "jtag2updi" on port "COM12" failed

avrdude done.  Thank you.
mcuee commented 2 years ago

Arduino megacore works fine when uploading the blink sketch.

C:\\Users\\xiaof\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-size" -A "C:\\Users\\xiaof\\AppData\\Local\\Temp\\arduino_build_488130/Blink.ino.elf"
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 COM12
C:\Users\xiaof\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\xiaof\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM12 -b115200 -e -D -Uflash:w:C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/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\xiaof\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM12
         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: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file "C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex"
avrdude: writing flash (1118 bytes):

Writing | ################################################## | 100% 0.85s

avrdude: 1118 bytes of flash written
avrdude: verifying flash memory against C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex:
avrdude: input file C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex contains 1118 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.22s

avrdude: verifying ...
avrdude: 1118 bytes of flash verified
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2 written
avrdude: verifying fuse2 memory against 0x01:
avrdude: load data fuse2 data from input file 0x01:
avrdude: input file 0x01 contains 1 bytes
avrdude: reading on-chip fuse2 data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of fuse2 verified
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5 written
avrdude: verifying fuse5 memory against 0xC9:
avrdude: load data fuse5 data from input file 0xC9:
avrdude: input file 0xC9 contains 1 bytes
avrdude: reading on-chip fuse5 data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of fuse5 verified
avrdude: reading input file "0x00"
avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8 written
avrdude: verifying fuse8 memory against 0x00:
avrdude: load data fuse8 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse8 data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of fuse8 verified

avrdude done.  Thank you.
mcuee commented 2 years ago

BTW, MegaCoreX has no problem with Nano 4808 as it does not need the 1200bps reset trick.

"C:\\Users\\xiaof\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\xiaof\\AppData\\Local\\Temp\\arduino_build_488130/Blink.ino.elf"
Sketch uses 758 bytes (1%) of program storage space. Maximum is 49152 bytes.
Global variables use 4 bytes (0%) of dynamic memory, leaving 6140 bytes for local variables. Maximum is 6144 bytes.
Forcing reset using 1200bps open/close on port COM13
C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude -CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf -v -patmega4808 -cjtag2updi -PCOM13 -e -Uflash:w:C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex:i -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x01:m -Ufuse4:w:0x00:m -Ufuse5:w:0b11001001:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m 

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   0a:0b:0c:0d:0e:0f
Device ID:                       Thinary mkII
         AVR Part                      : ATmega4808
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    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
           sernum                  0     0     0    0 no         10    0      0     0     0 0x00 0x00
           osccal16                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osccal20                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           tempsense               0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc16err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc20err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           fuse0       wdtcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1       bodcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2       osccfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4       tcd0cfg     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5       syscfg0     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6       syscfg1     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7       append      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8       bootend     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
           userrow     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 HW version: 1
         M_MCU FW version: 6.00
         S_MCU HW version: 1
         S_MCU FW version: 6.00
         Serial number   : 0a:0b:0c:0d:0e:0f
         Vtarget         : 5.0 V

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude: erasing chip
avrdude: reading input file "C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex"
avrdude: writing flash (758 bytes):

Writing | ################################################## | 100% 0.21s

avrdude: 758 bytes of flash written
avrdude: verifying flash memory against C:\Users\xiaof\AppData\Local\Temp\arduino_build_488130/Blink.ino.hex:

Reading | ################################################## | 100% 0.14s

avrdude: 758 bytes of flash verified
avrdude: reading input file "0x00"
avrdude: writing fuse0/wdtcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse0/wdtcfg written
avrdude: verifying fuse0/wdtcfg memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse0/wdtcfg verified
avrdude: reading input file "0x54"
avrdude: writing fuse1/bodcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse1/bodcfg written
avrdude: verifying fuse1/bodcfg memory against 0x54:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse1/bodcfg verified
avrdude: reading input file "0x01"
avrdude: writing fuse2/osccfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2/osccfg written
avrdude: verifying fuse2/osccfg memory against 0x01:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse2/osccfg verified
avrdude: reading input file "0x00"
avrdude: writing fuse4/tcd0cfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse4/tcd0cfg written
avrdude: verifying fuse4/tcd0cfg memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse4/tcd0cfg verified
avrdude: reading input file "0b11001001"
avrdude: writing fuse5/syscfg0 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5/syscfg0 written
avrdude: verifying fuse5/syscfg0 memory against 0b11001001:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse5/syscfg0 verified
avrdude: reading input file "0x06"
avrdude: writing fuse6/syscfg1 (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse6/syscfg1 written
avrdude: verifying fuse6/syscfg1 memory against 0x06:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse6/syscfg1 verified
avrdude: reading input file "0x00"
avrdude: writing fuse7/append (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse7/append written
avrdude: verifying fuse7/append memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse7/append verified
avrdude: reading input file "0x00"
avrdude: writing fuse8/bootend (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8/bootend written
avrdude: verifying fuse8/bootend memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse8/bootend verified
avrdude: reading input file "0xC5"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xC5:

Reading | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock verified

avrdude done.  Thank you.
mcuee commented 2 years ago

MegaCoreX also seems to be able to support UART1 bootloader with Nano 4808 (at least I can upload the hex file but I have not tried to see if the booloader works fine or not by attaching an external USB-TTL converter).

"C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude" "-CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf" -v -patmega4808 -cjtag2updi -PCOM13 -e "-Ufuse0:w:0x00:m" "-Ufuse1:w:0x54:m" "-Ufuse2:w:0x01:m" "-Ufuse4:w:0x00:m" "-Ufuse5:w:0b11001001:m" "-Ufuse6:w:0x06:m" "-Ufuse7:w:0x00:m" "-Ufuse8:w:0x02:m" "-Ulock:w:0xC5:m"

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   0a:0b:0c:0d:0e:0f
Device ID:                       Thinary mkII
         AVR Part                      : ATmega4808
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    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
           sernum                  0     0     0    0 no         10    0      0     0     0 0x00 0x00
           osccal16                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osccal20                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           tempsense               0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc16err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc20err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           fuse0       wdtcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1       bodcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2       osccfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4       tcd0cfg     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5       syscfg0     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6       syscfg1     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7       append      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8       bootend     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
           userrow     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 HW version: 1
         M_MCU FW version: 6.00
         S_MCU HW version: 1
         S_MCU FW version: 6.00
         Serial number   : 0a:0b:0c:0d:0e:0f
         Vtarget         : 5.0 V

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude: erasing chip
avrdude: reading input file "0x00"
avrdude: writing fuse0/wdtcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse0/wdtcfg written
avrdude: verifying fuse0/wdtcfg memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse0/wdtcfg verified
avrdude: reading input file "0x54"
avrdude: writing fuse1/bodcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse1/bodcfg written
avrdude: verifying fuse1/bodcfg memory against 0x54:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse1/bodcfg verified
avrdude: reading input file "0x01"
avrdude: writing fuse2/osccfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2/osccfg written
avrdude: verifying fuse2/osccfg memory against 0x01:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse2/osccfg verified
avrdude: reading input file "0x00"
avrdude: writing fuse4/tcd0cfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse4/tcd0cfg written
avrdude: verifying fuse4/tcd0cfg memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse4/tcd0cfg verified
avrdude: reading input file "0b11001001"
avrdude: writing fuse5/syscfg0 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5/syscfg0 written
avrdude: verifying fuse5/syscfg0 memory against 0b11001001:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse5/syscfg0 verified
avrdude: reading input file "0x06"
avrdude: writing fuse6/syscfg1 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse6/syscfg1 written
avrdude: verifying fuse6/syscfg1 memory against 0x06:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse6/syscfg1 verified
avrdude: reading input file "0x00"
avrdude: writing fuse7/append (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse7/append written
avrdude: verifying fuse7/append memory against 0x00:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse7/append verified
avrdude: reading input file "0x02"
avrdude: writing fuse8/bootend (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8/bootend written
avrdude: verifying fuse8/bootend memory against 0x02:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of fuse8/bootend verified
avrdude: reading input file "0xC5"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xC5:

Reading | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock verified

avrdude done.  Thank you.

"C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude" "-CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf" -v -patmega4808 -cjtag2updi -PCOM13 "-Uflash:w:C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/bootloaders/optiboot/bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.hex:i"

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   0a:0b:0c:0d:0e:0f
Device ID:                       Thinary mkII
         AVR Part                      : ATmega4808
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    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
           sernum                  0     0     0    0 no         10    0      0     0     0 0x00 0x00
           osccal16                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osccal20                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           tempsense               0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc16err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc20err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           fuse0       wdtcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1       bodcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2       osccfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4       tcd0cfg     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5       syscfg0     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6       syscfg1     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7       append      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8       bootend     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
           userrow     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 HW version: 1
         M_MCU FW version: 6.00
         S_MCU HW version: 1
         S_MCU FW version: 6.00
         Serial number   : 0a:0b:0c:0d:0e:0f
         Vtarget         : 5.0 V

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/bootloaders/optiboot/bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.hex"
avrdude: writing flash (512 bytes):

Writing | ################################################## | 100% 0.14s

avrdude: 512 bytes of flash written
avrdude: verifying flash memory against C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/bootloaders/optiboot/bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.hex:

Reading | ################################################## | 100% 0.09s

avrdude: 512 bytes of flash verified

avrdude done.  Thank you.
mcuee commented 2 years ago

Hmm, this is a false alarm. In the above, I run Arduino IDE and then select Examples - Blink.

If I save the file and then double click the sketch file, it seems to be okay.

"C:\\Users\\xiaof\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\xiaof\\AppData\\Local\\Temp\\arduino-sketch-756AE34E26842A986812DA1B2DB862B9/Blink_Every.ino.elf"
Sketch uses 752 bytes (1%) of program storage space. Maximum is 49152 bytes.
Global variables use 4 bytes (0%) of dynamic memory, leaving 6140 bytes for local variables. Maximum is 6144 bytes.
Performing 1200-bps touch reset on serial port COM12
"C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\tools\avrdude\7.0.0-arduino2/bin/avrdude" "-CC:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf" -v -V -patmega4809 -cjtag2updi -PCOM12 -e "-Uflash:w:C:\Users\xiaof\AppData\Local\Temp\arduino-sketch-756AE34E26842A986812DA1B2DB862B9/Blink_Every.ino.hex:i" "-Ufuse0:w:0x00:m" "-Ufuse1:w:0x54:m" "-Ufuse2:w:0x01:m" "-Ufuse4:w:0x00:m" "-Ufuse5:w:0b11001001:m" "-Ufuse6:w:0x06:m" "-Ufuse7:w:0x00:m" "-Ufuse8:w:0x00:m" "-Ulock:w:0xC5:m"

avrdude: Version 7.0
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is "C:\Users\xiaof\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.0/avrdude.conf"

         Using Port                    : COM12
         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
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    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
           sernum                  0     0     0    0 no         10    0      0     0     0 0x00 0x00
           osccal16                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osccal20                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           tempsense               0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc16err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           osc20err                0     0     0    0 no          2    0      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           fuse0       wdtcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1       bodcfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2       osccfg      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4       tcd0cfg     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5       syscfg0     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6       syscfg1     0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7       append      0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8       bootend     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
           userrow     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 HW version: 1
         M_MCU FW version: 1.07
         S_MCU HW version: 1
         S_MCU FW version: 6.07
         Serial number   : 00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file "C:\Users\xiaof\AppData\Local\Temp\arduino-sketch-756AE34E26842A986812DA1B2DB862B9/Blink_Every.ino.hex"
avrdude: writing flash (752 bytes):

Writing | ################################################## | 100% 0.57s

avrdude: 752 bytes of flash written
avrdude: reading input file "0x00"
avrdude: writing fuse0/wdtcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse0/wdtcfg written
avrdude: reading input file "0x54"
avrdude: writing fuse1/bodcfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse1/bodcfg written
avrdude: reading input file "0x01"
avrdude: writing fuse2/osccfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2/osccfg written
avrdude: reading input file "0x00"
avrdude: writing fuse4/tcd0cfg (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse4/tcd0cfg written
avrdude: reading input file "0b11001001"
avrdude: writing fuse5/syscfg0 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5/syscfg0 written
avrdude: reading input file "0x06"
avrdude: writing fuse6/syscfg1 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse6/syscfg1 written
avrdude: reading input file "0x00"
avrdude: writing fuse7/append (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse7/append written
avrdude: reading input file "0x00"
avrdude: writing fuse8/bootend (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8/bootend written
avrdude: reading input file "0xC5"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written

avrdude done.  Thank you.
mcuee commented 2 years ago

But if I select "Burn Bootloader" or "Upload using Programmer" for Nano Every, the issue will happen again.

MCUdude commented 2 years ago

As of now MegaCoreX does not support the optiboot bootloader for Arduino Nano Every.

I've never put in an effort trying to get bootloaders working for the Nano Evey. Using a bootloader on a nano every doesn't make much sense IMO, and the way 1200bps touch is handled by the IDE is very inconvenient.

Ideally, I'd like the Nano Every to not be hardcoded to use the jtag2updi programmer, but a programmer present in programmer.txt can't do 1200bps touch, which means that the "Burn Bootloader" button will never work with a programmer that requires 1200bps touch. It's probably an IDE bug, but it means that a target from boards.txt has to be hardcoded to a programmer in boards.txt in order to perform a 1200bps touch.

https://github.com/MCUdude/MegaCoreX/blob/103adb5a2fc8bc8c221440b1e1dc5596d7b8cf40/megaavr/boards.txt#L44-L50

mcuee commented 2 years ago

but a programmer present in programmer.txt can't do 1200bps touch,

I see. I will close this issue then.