Burning Bootloader on Atmega328 using Uno

Hi,

I have a custom board with an Atmega328 (not the p variant). It's this chip from digikey. I didn't realize I would need to burn a bootloader to use arduino, so OF COURSE I didn't give myself access to the spi port when I designed the board. I have tacked some tiny wires to the individual pins of the chip (installed on the board), and I am attempting to use and arduino Uno as the ISP to burn the bootloader. I used the ArduinoISP sketch to successfully reflash another Uno as well as an Arduino Pro Mini (3.3v 8MHz). I have a 10uF capacitor from the reset line to ground.

The board I built supplies the MCU with 5v and has this 16MHz ceramic resonator attached to pins 7 and 8.

When I use the ArduinoISP sketch to attempt to burn the bootloader, the verbose output looks like this:

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/jordan/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [1c] 
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c

avrdude done.  Thank you.

Although at times, I've seen all kinds of different error messages. If I run this command at the command line,

avrdude -c arduino -p atmega328 -P /dev/ttyACM0 -b 19200 -U flash:w:bootloader_atmega328.h

I get the following output

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

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

avrdude: stk500_disable(): unknown response=0x12

avrdude done.  Thank you.

I've done EVERYTHING possible to verify that my connections are good. I need to know if there is a step I am missing. Do I need to set the fuses to use the internal oscillator? Or maybe to use the external oscillator? I'm at a loss :confused: Any help will be greatly appreciated! Thanks.

Sync error when doing burn bootloader via Arduino as ISP typically indicates that you have not successfully disabled autoreset.

Be aware, that the ATmega328P (the ATmega on the "UNO") has a different device signature than the microcontroller you use (ATmega328).
ATmega328 = 0x1E 0x95 0x14
ATmega328P = 0x1E 0x95 0x0F

So I would expect an error like "Invalid device signature."
But this error may come next :slight_smile:

Take a look at MiniCore which supports ATmega328 (without P).

ISP programmer: Running Arduino as ISP sketch may work well – however, I highly recommend the $3 USBAsp programmers available on ebay. Much less futzing with wires, and hence less opportunity for mistakes.

Wow that's great information, thanks! The sync error probably means my capacitor fell out and wasn't clobbering the reset toggle when the COM port is opened, right?

I have seen the device signature error in the past, but then it was reading my device signature as 0x00FF00 or 0xFFFF00 or 0xFFFFFF. Do you think that could be a result of a baudrate mismatch or something?

I'll get a USBAsp and use MiniCore as soon as I can :smiley:

(deleted)

Device signature of 0xffffff may indicate a wiring problems – probably MISO shorted to Vcc.

Check all the ISP pins with multimeter in continuity mode – check for shorts to ground, vcc, and other ISP pins, and verify that they are connected to the right pins on the target.
Is your reset wires connected properly?

Good luck!

"Using Port : /dev/ttyACM0
Using Programmer : arduino
Overriding Baud Rate : 57600"

Did you up load ArduinoISP and then put your capacitor between reset and ground on the Uno being used as programmer?
Then did you select from tools "Burn Bootlooder? Also did you select Tools/ Programmer/ "Arduino as ISP"?The reason I ask is because I am using Minicore on a atmega328p on a pcb and when I burn the bootloader I get this.

User configuration file is "/home/kprims/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyACM0
Using Programmer : stk500v1 // ************* Notice the difference between yours?
Overriding Baud Rate : 19200
AVR Part : ATmega328P

Okay I'm using MiniCore now, still with the Arduino Uno as the programmer. (USBAsp will arrive Tuesday).
My board doesn't have anything attached to the relevant pins that might be loading them down. I checked for shorts to Vcc, Gnd, and adjacent pins. Here's what I'm seeing from Minicore:

avrdude: Version 6.3, compiled on Dec 16 2016 at 12:32:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/jordan/.arduino15/packages/MiniCore/hardware/avr/1.0.3/avrdude.conf"
         User configuration file is "/home/jordan/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328
         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
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0xff0000
avrdude: Expected signature for ATmega328 is 1E 95 14
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

(deleted)

It worked! I fiddled with my capacitor (I don't think it was making a reliable connection) and used Minicore, and it worked great! I loaded the bootloader and then used my ftdi cable to load the blink example code. Thanks so much, everybody!

jsford94:
I fiddled with my capacitor (I don't think it was making a reliable connection)

So the first guess was close... :slight_smile:

Good to hear that it is working now!