0

Issues burning to the Arduino
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Issues burning to the Arduino

by xsmurf on Thu Jan 31, 2008 1:19 pm

Hi there, after mistakenly frying two m168 (I had -F in a Makefile that was uploading directly rather than using the bootloader) I was left with no more Arduino. Now I'm trying to burn the bootloader on a new mega168 but I get the dreadful "avrdude: initialization failed, rc=-1". I really tried all power options (self power, target powered, separate power), but to no avail. Yet the same mega168 on a breadboard powered by the USBTiny works just fine. Sadly, I don't have any 16Mhz crystals so I can't burn the bootloader (fuses get burnt first and after that the m168 expects to use the external clock and I'm left unable to upload the bootloader's flash). Now I ran out of ideas :( What's next? Any ideas?

Thanks, Murf.

EDIT: PS. I have a v1 (but have a few 74ah125 at hand). I bought the tiny2313 afterwards, so it may be a v2
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by xsmurf on Thu Jan 31, 2008 4:45 pm

Ok so I found some 12Mhz xtals I had laying around. From what I can see the fuses would be the same. Now this is what I got... another dead bug :(

Code: Select all | TOGGLE FULL SIZE
$ avrdude -c usbtiny -p m168

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

chimera:Bootloader mlalonde$ avrdude -c usbtiny -p m168

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

$ make TARGET=diecimila isp
avrdude -c usbtiny -p m168 -P usb -b 115200 -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdd:m -U lfuse:w:0xff:m

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x00"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x00:
avrdude: load data efuse data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xdd"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xdd:
avrdude: load data hfuse data from input file 0xdd:
avrdude: input file 0xdd contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:

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

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

avrdude -c usbtiny -p m168 -P usb -b 115200 -U flash:w:ATmegaBOOT_168_diecimila.hex -U lock:w:0x0f:m

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


avrdude done.  Thank you.

make: *** [isp] Error 1
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by adafruit on Thu Jan 31, 2008 5:22 pm

do you have a crystal or oscillator connected to the atmega168?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by mtbf0 on Thu Jan 31, 2008 9:43 pm

even if you get the bootloader loaded it is built to run at 16Mz, not 12. you will get no joy from this set up.

reset the fuses to use the internal oscillator, then burn the lilypad bootloader and select the lilypad as your target. you'll be able to happily plug along at 8MHz and you'll have an extra two digital i/o.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by xsmurf on Fri Feb 01, 2008 2:49 am

Limor: as I said I have a 12Mhz hooked up

mtbf0: I know, my issue is only burning the bootloader. It won't burn when on the Arduino board.
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

Re: Issues burning to the Arduino

by mtbf0 on Fri Feb 01, 2008 8:31 am

xsmurf wrote: Sadly, I don't have any 16Mhz crystals so I can't burn the bootloader (fuses get burnt first and after that the m168 expects to use the external clock and I'm left unable to upload the bootloader's flash)


why not burn the bootloader first? then burn the fuses. of course, now that you've burnt the fuses, you'll need a stable clock.

xsmurf wrote:Ok so I found some 12Mhz xtals I had laying around.


if that's a crystal and not a resonator you'll need a very small value capacitor from each leg of the crystal to ground. between 12 and 22pf. probably 12pf.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Re: Issues burning to the Arduino

by xsmurf on Fri Feb 01, 2008 2:00 pm

mtbf0 wrote:why not burn the bootloader first? then burn the fuses. of course, now that you've burnt the fuses, you'll need a stable clock.


Are you sure this is something that can be done? thought the bootloader had to be written after and before the lock fuses. I'd rather not fry another mega168...

if that's a crystal and not a resonator you'll need a very small value capacitor from each leg of the crystal to ground. between 12 and 22pf. probably 12pf.

I am aware of that

Anyhow, this is really off topic... Why can't I burn when the mega's are on the Arduino board?
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by adafruit on Fri Feb 01, 2008 2:04 pm

xsmurf wrote:Limor: as I said I have a 12Mhz hooked up

mtbf0: I know, my issue is only burning the bootloader. It won't burn when on the Arduino board.


oh i thought you meant for the usbtiny.
have you tried burning the bootloader -before- the fuses?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by xsmurf on Fri Feb 01, 2008 2:23 pm

Well it won't burn with the USBTiny ;)

You sure I can do that? Do I need to burn the lock bit fuse first? I would really like not to fry another mega168 :(
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by adafruit on Fri Feb 01, 2008 2:25 pm

welcome to electrical engineering! :)

its pretty much impossible for me to debug your setup so i can only offer suggestions!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by xsmurf on Sat Feb 02, 2008 4:02 pm

Might be hard, but I'd still like the suggestions. Looking back at it I've lost two mega128 board, at least 3 attiny2313 and 3 mega168 due to this issue... Let's just say that the difference in price with a real STK/ICE is getting slimmer...
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by xsmurf on Sat Feb 02, 2008 4:07 pm

xsmurf wrote:[If I burn the bootloader before the fuse] do I need to burn the lock bit fuse first?


Also, I tried the 1Mhz trick with no success...

using :
Code: Select all | TOGGLE FULL SIZE
void loop(void)
{
  PORTB |= PB0;
  delayMicroseconds(1);
  PORTB &= ~PB0;
  delayMicroseconds(1);
}
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by xsmurf on Sat Feb 02, 2008 4:20 pm

xsmurf wrote:Also, I tried the 1Mhz trick with no success...

using :
Code: Select all | TOGGLE FULL SIZE
void loop(void)
{
  PORTB |= PB0;
  delayMicroseconds(1);
  PORTB &= ~PB0;
  delayMicroseconds(1);
}


Ah! did I say that?

Code: Select all | TOGGLE FULL SIZE
$ avrdude -c usbtiny -p m168

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406
avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.
avrdude: safemode: To protect your AVR the programming will be aborted

avrdude done.  Thank you.
xsmurf
 
Posts: 28
Joined: Mon Aug 27, 2007 3:04 pm

by adafruit on Sat Feb 02, 2008 8:25 pm

id say dont screw around with fuses or lockbits becase its very easy to brick a chip. just get a new chip such as the attiny2313 which as an 8mhz internal oscillator and just burn code. if you cant do that then theres a problem but if you're saying "i can burn fuses great but then everything falls apart right afterwards' it says to me that the programmer is fine but the fuses are wrong.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.