Error Installing Bootloader on ATMEGA168

Hi everyone,

Long time reader, first time poster! I made a custom board based on Sparkfun’s Arduino ProMini 3.3V. I used an ATMEGA168-20MU (MLF Package). I am attempting to use my arduino as an ISP to program the bootloader onto the chip, but I keep getting error messages. I have tried every suggestion I could find on Google (I have the latest drivers/IDE/right COM port/etc) but nothing has worked. I would appreciate any help you guys could offer!

Thanks! :slight_smile:

Hardware Note

I have attached a screenshot of how my processor is wired up in the schematic (Could someone please look at the DTR line for me and make sure that is correct?)

Error Message With Verbose Output

Arduino: 1.6.5 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega168 (3.3V, 8 MHz)"

E:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CE:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega168 -cstk500v1 -PCOM6 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x00:m -Uhfuse:w:0xdd:m -Ulfuse:w:0xc6:m 



avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58

        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

        Copyright (c) 2007-2009 Joerg Wunsch



        System wide configuration file is "E:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"



        Using Port                    : COM6

        Using Programmer              : stk500v1

        Overriding Baud Rate          : 19200

        AVR Part                      : ATmega168

        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        512    4      0  3600  3600 0xff 0xff

          flash         65     6   128    0 yes     16384  128    128  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



Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000 (retrying)



Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000 (retrying)



Error while burning bootloader.

Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000

avrdude: Yikes!  Invalid device signature.

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

        this check.





avrdude done.  Thank you.

Attachments do not work for many people, so here are your diagrams:

534d3b7ab869bb20a0e48f50b5a3f1379e214d3c.png

d80fc060c2b317351f560dfcf628699d4e836a11.png

Schematic looks okay.

Got a pic of the board layout in case you did anything wrong there?

That error is almost always bad connections, or device set to use crystal/resonator, but without a working crystal or resonator connected.

Check all of the ISP programming lines - from the ISP programmer to the pin on the device - with a multimeter set for continuity, and also check for shorts to adjacent pins, ground, or Vcc on all of the pins involved.

Hi,

your question remembers me to my troubles I described in this post . Maybe my solution could be as good for you?

If you want to try, pease let me know, if it worked for you too.

Greetings
Herbert

DrAzzy:
Schematic looks okay.

Got a pic of the board layout in case you did anything wrong there?

That error is almost always bad connections, or device set to use crystal/resonator, but without a working crystal or resonator connected.

Check all of the ISP programming lines - from the ISP programmer to the pin on the device - with a multimeter set for continuity, and also check for shorts to adjacent pins, ground, or Vcc on all of the pins involved.

Hi DrAzzy,

I uploaded the images of the full schematic and board to the first post. Let me know what you think. Thanks!

You say you're programming with ISP - but unless I'm missing something, I don't see the ISP pins brought out to accessible headers anywhere... I see the header for serial programming, but I'm not sure how you're making the connections for ISP programming, since it looks like MISO/MOSI/SCK only go to the SD card slot...

I didn't bring them out. I have jumpers on the SD pins right now. It was a space saving measure for the initial board design that has now backfired :sweat_smile:

The ISP is reading the chip somehow. Here is the new error message I received after strengthing the connection points:

Arduino: 1.6.5 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega168 (3.3V, 8 MHz)"

E:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CE:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega168 -cstk500v1 -PCOM6 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x00:m -Uhfuse:w:0xdd:m -Ulfuse:w:0xc6:m 



avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2009 Joerg Wunsch



         System wide configuration file is "E:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM6

         Using Programmer              : stk500v1

         Overriding Baud Rate          : 19200

         AVR Part                      : ATmega168

         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        512    4      0  3600  3600 0xff 0xff

           flash         65     6   128    0 yes     16384  128    128  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



Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000 (retrying)



Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000 (retrying)



Error while burning bootloader.

Reading | ################################################## | 100% 0.05s



avrdude: Device signature = 0x000000

avrdude: Yikes!  Invalid device signature.

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

         this check.

Are you sure the chip is mounted correctly? There have been some instances where the "pin 1" marking and the package text imprint were not congruent. (That was actually on a Due chip, but it's something to keep an eye on.)

westfw:
Are you sure the chip is mounted correctly? There have been some instances where the “pin 1” marking and the package text imprint were not congruent. (That was actually on a Due chip, but it’s something to keep an eye on.)

Here is the pinout of the ATMEGA168 32 pin (MLF package) from the Atmel Website. Unless the physical chip was manufactured differently than their website suggests, it appears that it is correctly mounted to my board.

Mega168_32MLF.png

herbert-pesendorfer:
Hi,

your question remembers me to my troubles I described in this post . Maybe my solution could be as good for you?

If you want to try, pease let me know, if it worked for you too.

Greetings
Herbert

Hi Herbert,

Thank you for your suggestion! I uploaded optiboot to my Arduino Uno and it was able to compile and upload successfully. However, the Uno was unable to program my new chip. I received the following error message from the serial log:

Target power on! ...No RESET pullup detected! - no target?

Target power OFF!

Type 'G' or hit RESET for next chip

Any thoughts?

Hi SirLearnALot,

it seems to me, that you haven't wired correctly. I think you are missing the connection VCC->10k->RST (chip which will be programmed).

Please have a look at my wiring diagram

Greetings
Herbert

Hey everyone,

I still haven't been able to get the ATMEGA168-20MU programmed. Could this be an issue with the boards.text file?

Could this be an issue with the boards.text file?

No. Your avrdude command looks OK, and boards.txt isn't used past that.
Also, optiloader doesn't use boards.txt at all.

Target power on! ...No RESET pullup detected! - no target?

And the way that optiloader works, is that it starts with the pin going to RESET as an input, and reads the digital value there. It should be "high"; if not, then something is wrong with the circuit and wiring.
How are you connecting to RESET, anyway? You mentioned that since you hadn't added an ISP connector, you were bringing in the programming signals via the SD footprint, but that doesn't include RESET. And looking at your board, RESET doesn't look easy to get to. You're not trying to program it with the programmer RESET connector to the other side of the "auto-reset capacitor", are you? That won't work for ISP programming!

westfw:
You're not trying to program it with the programmer RESET connector to the other side of the "auto-reset capacitor", are you? That won't work for ISP programming!

I am doing just that, oh no! Would placing a jumper on an exposed section of R1's pad allow me to program the bootloader? See image below for clarification. Thank you!

Yes, the programmer must access Reset directly for ICSP programming. It will hold it low, not just give it a pulse.

I believe that I finally burned the bootloader! (Should I celebrate?)

OptiLoader Bootstrap programmer.
2011 by Bill Westfield (WestfW)

Target power on! ...
Starting Program Mode [OK]

Reading signature:9406
Searching for image...
  Found "optiboot_atmega168.hex" for atmega168
  Start address at 3E00
  Total bytes read: 502

Setting fuses for programming
  Lock: 3F FFE000  Low: C6 FFA000  High: DD FFA800  Ext: 4 FFA400

Programming bootloader: 512 bytes at 0x1F00
  Commit Page: 1F00:1F00
  Commit Page: 1F40:1F40
  Commit Page: 1F80:1F80
  Commit Page: 1FC0:1FC0

Restoring normal fuses
  Lock: 2F FFE000

Target power OFF!

Type 'G' or hit RESET for next chip

However, I have a new issue: I attempted to upload the blink sketch to my board and received the following:

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "E:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xc6

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Thank you all for your help so far, you have been wonderful!

I attempted to upload the blink sketch to my board and received the following:

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "E:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200

You haven't updated your boards.txt file with an entry for "m168 running optiboot." Optiboot runs at 115200bps, and you're still running at 19200bps (the older bootloader speed.)

westfw:
You haven't updated your boards.txt file with an entry for "m168 running optiboot." Optiboot runs at 115200bps, and you're still running at 19200bps (the older bootloader speed.)

How would I go about doing this? What parameters should I enter and where? Thanks!

Easiest: run at least version 1.6.5, point the Preferences dialog at this URL: https://github.com/Optiboot/optiboot/releases/download/v6.2/package_optiboot_optiboot-additional_index.json
Use the “board manager” to install the “optiboot 6.2” that will show up.
Then set the “Board type” to “optiboot on 32pin CPUs”, and the “CPU” to ATmega168.

Hi West,

Thanks for the suggestion, but I'm still getting an error message. Is it because I installed the wrong bootloader previously? Or could it be because I have an external 8MHz clock?

Arduino: 1.6.5 (Windows 7), Board: "Optiboot on 32-pin cpus, 8MHz (int), ATmega168"

E:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CE:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega168 -cstk500v1 -PCOM6 -b19200 -e -Ulock:w:0x2F:m -Uefuse:w:0xFC:m -Uhfuse:w:0xDD:m -Ulfuse:w:0xE2:m 



avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2009 Joerg Wunsch



         System wide configuration file is "E:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM6

         Using Programmer              : stk500v1

         Overriding Baud Rate          : 19200

         AVR Part                      : ATmega168

         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        512    4      0  3600  3600 0xff 0xff

           flash         65     6   128    0 yes     16384  128    128  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.05s



avrdude: Device signature = 0x1e940c

avrdude: Expected signature for ATmega168 is 1E 94 06

         Double check chip, or use -F to override this check.



avrdude done.  Thank you.

I keep getting the same error message but the "Device signature = *********" line is always different