Can't upgrade Arduino Nano to Optiboot bootloader

I'm following this video to upgrade to the Optiboot bootloader some Arduino Nano clones that I bought from Amazon.

The process basically needs this wiring:

Then the Arduino IDE is used to flash the ArduinoISP program in normal mode into the board to the left side, and then the programmer mode is switched to Arduino as ISP to burn the bootloader.

This doesn't seem to work, and I'm getting this error every time:

"/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-1410 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

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 "/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/Users/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-1410
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 145478971
         Firmware Version: -417919568.32766
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

Using the connections from other schematic with the program ArduinoISP I found here doesn't seem to work either, this is the output with the error I'm getting:

"/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-1410 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

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 "/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/Users/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-1410
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 140141883
         Firmware Version: -412582480.32766
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

Both boards work perfectly fine in formal mode, for instance if I flash the Blink program from the examples on the Arduino IDE, it seems to work fine.

Have you tried putting a capacitor between reset and ground on the Nano being used as the programmer? Usually something around 10uF electrolytic, but the value is not critical.

First, congratulations on that Fritzing diagram. It's particularly clear and obvious, compared to some efforts we've seen.

However, if it's CORRECT, the "to be programmed" ICSP header is "upside down" compared to the diagram of the ICSP header (ie pin 1 is at the bottom), and all of your connections are "backward." (ie the yellow wire that is supposed to connect to pin 5 "reset" is connected to pin 2 +5V instead.)

I've connected ICSP connectors backward like this several (many?) times - it's seems that it's usually not fatal to the target board.

(It may be easier to wire the data pins instead of the ICSP connector. Pin13 to 13, 12 to 12, 11 to 11, GND to GND, 5V to 5V, and pin 10 to RESET.)

Thanks @david_2018 and @westfw , it looks like the problem was the bauderate. The Arduino IDE tries to burn the bootloader at 19200 baud, that was the problem. When I tried using 57600 baud from the command line the whole process finished without any issues. Like so:

"./bin/avrdude" "-C./etc/avrdude.conf" -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-1410 -b57600 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

Just looked at about half of the video you linked in the original post. Did you edit the boards.txt file like the video said? If so, that is completely wrong, there is no need whatsoever to edit that file. The "Burn Bootloader" option in the IDE is made to work with the ArduinoISP example sketch, and the baud rate will be correct - the baud rate that the bootloader itself uses is irrelevant.

When updating the bootloader on a Nano, it is common to set the IDE board selection to UNO. The UNO bootloader is exactly the same as the "new" Nano bootloader, but the Nano allocates 2048 bytes of flash memory for the bootloader, while the UNO only allocate 512 bytes, leaving more memory for your code. The extra memory was needed for the "old" Nano bootloader, and was left that way with the change to the "new" bootloader, even though the bootloader itself does not need it.

Yes , I changed the boards.txt file as the video says. I have a sketch that uses 96% of program storage space on the UNO. I knew the Nano also has the same storage space, but needed to be upgraded to the Optiboot bootloader. I'll check if I can use the UNO settings instead to burn the new bootloader into the Nano. Thanks for the info.

Using the Uno settings does not eliminate the need to flash the bootloader to the Nano.
Just instead of editing the Nano settings in the boards file, you can use the Uno settings.

If you burn the bootloader with the IDE board selection set to UNO, from then on you need to use that setting for compiling/uploading sketches to the board.

I don't think so
If in your IDE are separate settings for "Nano" and "Nano -Old bootloader" - then you should be able to use Nano settings for updated bootloader

Unfortunately, both setting on the Nano allocate 2K bytes of flash memory for the bootloader, even though the "new" bootloader only needs 512 (it is the exact same bootloader used for the UNO). Selecting UNO is the easy way to get the fuse settings correct for an allocation of 512 bytes of flash memory for the bootloader. Editing boards.txt is problematic because any update of the boards package will require re-editing the file.

Thanks, everybody. The suggestion of @b707 did the trick. I was able to burn the new bootloader into the Nano using the UNO settings without the need to modify the boards.txt file. After that I just use the Nano as a UNO board and was able to flash the sketch that was surpassing the default Nano storage capacity.

Thank you, but to be honest, is was not my suggestion. It came from @david_2018 in post#5

Thanks @b707, I marked David's comment with the suggestion to use the UNO settings on the Nano as the solution. Thanks a lot @david_2018.

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