Adafruit is open and shipping! Let's build back better, together!
0

Resetting bad fuse programming on a 128 kHz ATTiny2313
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Resetting bad fuse programming on a 128 kHz ATTiny2313

by bjornwireen on Thu Jan 10, 2008 11:43 am

My equipment is as follows:

Programmer: USBTiny ISP 2
Chip: ATTiny2313
Computer: Mac Cube with OS X.


After uploading code to the t2313 the verification process succeeded. Then I programmed the fuses, but in the end of the verification of the fuses there was an error message telling me that low fuse was 0x46 (internal 128 kHz, 0 ms startup delay) instead of my intended 0x64. I answered yes to doing a rewrite and the rewrite was starting but didn't succeed:

Code: Select all | TOGGLE FULL SIZE
avrdude: initialization failed, rc=-1
...


My hypothesis is that the slow clock speed of the chip prevents me from reprogramming or erasing it. I have tried to erase it through avrdude's interactice prompt mode with the -B 25 switch, but I get the same "initialization failed" error message.

It is said that there is a method getting around this and erase the chip with the use of a 1 MHz oscillator connected to XTAL1 and XTAL2, but my since I am just getting started with programming and hardware designing for the t2313, I would need to find a detailed step-by-step instruction on how to do this.

Does anyone know where? I would be very grateful for any advice.

What could have caused the fuse programming error in the beginning? Is this a common fault?
Last edited by bjornwireen on Thu Jan 10, 2008 4:37 pm, edited 1 time in total.
bjornwireen
 
Posts: 5
Joined: Thu Jan 10, 2008 11:10 am
Location: Stockholm, Sweden

by adafruit on Thu Jan 10, 2008 12:49 pm

use a fuse calculator http://www.ladyada.net/wiki/microcontroller_annoyances
to figure out precisely what you did first

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

Still no success

by bjornwireen on Wed Jan 16, 2008 10:36 am

Thanks for your reply.

In my above post I was probably wrong regarding how the fuses had "changed themself". Today I tried with a new ATtiny chip probably this is what happend last time too:

Code: Select all | TOGGLE FULL SIZE
c213-100-62-176:~/documents/avr/demo/firmware admin$ make fuse
[b]avrdude -c usbtiny -p attiny2313 -U hfuse:w:0x64:m -U lfuse:w:0xD9:m[/b]

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e910a
avrdude: reading input file "0x64"
avrdude: writing hfuse (1 bytes):

Writing |                                                    | 0% 0.00s ***failed; 
Writing | ################################################## | 100% 0.08s

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

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

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x64 != 0x44
avrdude: verification error; content mismatch

avrdude: safemode: hfuse changed! Was 64, and is now 44
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

make: *** [fuse] Error 1
c213-100-62-176:~/documents/avr/demo/firmware admin$ make flash
[b]avrdude -c usbtiny -p attiny2313 -U flash:w:main.hex:i[/b]

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


avrdude done.  Thank you.


This results in the AVR having a start-up time set to 0 ms.

When I try to program the chip again I get the "initialization failed" message above.

What might have caused this error in the first place and how can I get around it?

Thanks in advance!
bjornwireen
 
Posts: 5
Joined: Thu Jan 10, 2008 11:10 am
Location: Stockholm, Sweden

by adafruit on Wed Jan 16, 2008 1:08 pm

er, the fuses you used cause the chip to disable reset (thus be unprogrammable via the usbtiny)

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

by bjornwireen on Wed Jan 16, 2008 3:55 pm

Well, that's a problem. But do you mean the fuse settings I wanted to program
Code: Select all | TOGGLE FULL SIZE
-U hfuse:w:0x64:m -U lfuse:w:0xD9:m

is wrongly chosen and cause it to disable reset, or do you mean that the
Code: Select all | TOGGLE FULL SIZE
avrdude: verification error, first mismatch at byte 0x0000
0x64 != 0x44

bits that's actually programmed (the 0 ms start-up) disables reset?
bjornwireen
 
Posts: 5
Joined: Thu Jan 10, 2008 11:10 am
Location: Stockholm, Sweden

by adafruit on Wed Jan 16, 2008 3:56 pm

i think the fuses are wrong. did you triple check using the fuse calculator i posted?

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

by bjornwireen on Wed Jan 16, 2008 4:12 pm

Then I guess you mean the fuses I tried to program in the first place? That they are wrongly chosen?

I really don't think so ... That would be the most probable explanation but I've been checking with the fuse calculator and it seems right.

What I still don't get is why low bits turned out to be 0x44 although I program it 0x64?

To be sure I'll check out some other peoples makefiles and their fuse settings for the Attiny2313 to see if there could be anything else wrong with the fuse settings in my makefile.
bjornwireen
 
Posts: 5
Joined: Thu Jan 10, 2008 11:10 am
Location: Stockholm, Sweden

by adafruit on Wed Jan 16, 2008 8:14 pm

i think you're confusing hfuse and lfuse.

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

by bjornwireen on Thu Jan 17, 2008 12:27 pm

Ehm -- and I think you're right ;) Thanks for pointing it out to me.
bjornwireen
 
Posts: 5
Joined: Thu Jan 10, 2008 11:10 am
Location: Stockholm, Sweden

Please be positive and constructive with your questions and comments.