Cannot burn bootloader using Arduino Duemilanove as ISP

I'm trying to use my Arduino Duemilanove board to burn a bootloader to an ATMega328P device.

My computer is running Linux (Ubuntu 18.04), and I'm using the most recent IDE 1.8.13 downloaded from the arduino.cc site.

I've hooked up the ATMega I'm trying to burn with the bootloader on a breadboard using an external 16MHz crystal, per this article: Using an Arduino as an AVR ISP | ArduinoDev.com (the circuit diagram is at the bottom of the page).

I am following this guide: https://www.arduino.cc/en/pmwiki.php?n=Tutorial/ArduinoISP and I have:

  • Opened the ArduinoISP example sketch, #define'd USE_OLD_STYLE_WIRING (as I'm using pins 11, 12, and 13 for MOSI, MISO and SCK respectively)
  • Compiled the sketch and uploaded to the Duemilanove
  • Tools->Boards: 'Arduino Duemilanove or Diecilma'
  • Tools->Processor: 'ATMega328P'
  • Tools->Programmer: 'Arduino as ISP'
  • Tools->Burn bootloader

Sadly the bootloader burn fails, with this verbose output from the burning process:

/home/tom/bin/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/tom/bin/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "/home/tom/bin/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/tom/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         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: 4238814
         Firmware Version: 18613904.0
         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.

Error while burning bootloader.

I'm not expert enough in arvdude to be able to debug this further. Any suggestions?

I've not had any luck with the ArduinoISP sketch :frowning:

However, based on general searching around on the web I came across Nick Gammon's ATMega bootloader page here: Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer

I uploaded this sketch to my Duemilanove board (with the existing wiring to the ATMega328P part on the breadboard) and the sketch was able to locate and burn a bootloader to the ATMega.

There was a minor stumbling block left: I wasn't able to upload to the new ATMega when wiring via. the Due board as per: Arduino - ArduinoToBreadboard

This turns out to be because Nick's bootloader is for an Uno. If I set my board type to Uno I can successfully upload code to the ATMega.

It would be nice to be able to get to the bottom of why the Arduino ISP sketch didn't work for me, but for posterity in case anyone finds this post in the future this procedure worked for me:

And we're off to the races! :smiley: