help setting up a new chip in avrdude

This evening i've been trying to get a bootloader on a fresh new mega168, I'm using a USBPROG with avrispmk2 firmware, this seems to be working fine, using avrdude however is where it all seems to go a bit wrong :o

Heres what avrdude throws back with a pre configured arduino mega168

ice@aspire-ubuntu:~$ sudo avrdude -p m168 -c avrispmkII -P usb: -v

avrdude: Version 5.5, compiled on May 11 2008 at 09:48:29
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/ice/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : usb:
         Using Programmer      : avrispmkII
avrdude: usbdev_open(): Found AVRISP mk2 Clone, serno: 0000A00128255
         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     5     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 : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 0
         Firmware Version: 9.09
         Vtarget         : 5.0 V
         SCK period      : 1.00 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 0

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

As you can see it reads just fine, and no doubt I could start wrighting data to it.

With a fresh chip avrdude spits out this

ice@aspire-ubuntu:~$ sudo avrdude -p m168 -c avrispmkII -P usb: -v

avrdude: Version 5.5, compiled on May 11 2008 at 09:48:29
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/ice/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : usb:
         Using Programmer      : avrispmkII
avrdude: usbdev_open(): Found AVRISP mk2 Clone, serno: 0000A00128255
         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     5     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 : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 0
         Firmware Version: 9.09
         Vtarget         : 5.0 V
         SCK period      : 1.00 us

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Now, i've tried;

sudo avrdude -p m168 -c avrispmkII -P usb: -V -e -U lock:w:0x3f:m -U lfuse:w:0xff:m -U hfuse:w:0xdf:m -U efuse:w:0x0:m

Which gives the exact same result :-?

using -F just makes avrdude go into a safemode

I'm sure I'm missing something amazingly simple, I'm finding it hard to find good documentation so a little tuition would be appreciated :sunglasses:

Oh, and as I'm sure you can tell the system is ubuntu, but ultimately I want to get this working in MacOS, but I'm yet to get MacOS to talk to my USBPROG at all ;D

I had similar problems with 644's. Basically it may be that the new chips clock speed doesn't match the programmers. Wrote a bit on it when I was having trouble:

and

Got it going, thanks :smiley:

Ended up adding -B 6

sudo avrdude -c avrispmkII -p m168 -P usb: -B 6 -v -U lock:w:0x3f:m -U lfuse:w:0xff:m -U hfuse:w:0xdf:m -U efuse:w:0x0:m

And off it went :sunglasses: