Burnt wrong bootloader on ATtiny85 - how to correct?

I have an Arduino Uno R3 board and successfully used it to program my first ATtiny85. I followed the MIT Media Lab instructions and, in burning the Bootloader, selected "ATtiny85 (with internal 8MHz clock)" in Tools>Board.

Moving on to my second ATtiny85 I got careless and, in burning the Bootloader, I accidentally selected "ATtiny85 (with external 20MHz clock)" - the next one down in the Tools>Board list. When I subsequently tried to re-burn the Bootloader having now selected "ATtiny85 (with internal 8MHz clock)" I get the following error message:

"Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check."

Is there an easy way to put this right? I am very much of a beginner.

What does "use -F" mean and would that solve the problem?

Do you have a crystal + capacitors? Or a resonator?

simondumbo:
What does "use -F" mean and would that solve the problem?

Doesn't matter. No.

No, yes, and no.

I can go and buy a crystal (I've never worked with them though). Could you briefly explain what crystal to buy, how to connect it up, and the procedure?

Many thanks for your speedy reply.

simondumbo:
I have an Arduino Uno R3 board and successfully used it to program my first ATtiny85. I followed the MIT Media Lab instructions and, in burning the Bootloader, selected "ATtiny85 (with internal 8MHz clock)" in Tools>Board.

Moving on to my second ATtiny85 I got careless and, in burning the Bootloader, I accidentally selected "ATtiny85 (with external 20MHz clock)" - the next one down in the Tools>Board list. When I subsequently tried to re-burn the Bootloader having now selected "ATtiny85 (with internal 8MHz clock)" I get the following error message:

I find it helps if I remove the boards I don't own from boards.txt. Make the menu smaller, and avoids accidents.

simondumbo:
Is there an easy way to put this right? I am very much of a beginner.

What does "use -F" mean and would that solve the problem?

I've heard you can connect any clock source to the clock pin to make it run while you fix the fuses. Doesn't have to be 20mHz.

Oscilloscopes and signal generators have square wave outputs...or maybe you can use the PWM signal from another Arduino...

I have just found an old printed circuit board with what appears to be a crystal on it (oblong silver can, with two pins, and "XT1" marked on the pc-board next to it). The only marking on the can is 12000.SN so I have no idea if it will be of any use.

fungus:
I've heard you can connect any clock source to the clock pin to make it run while you fix the fuses. Doesn't have to be 20mHz.

Oscilloscopes and signal generators have square wave outputs...or maybe you can use the PWM signal from another Arduino...

Thanks. I mentioned in my other post that I did, I think, find a crystal. Do I simply connect its two terminals across pins 4 (GND) and 7 (SCK) of the ATtiny and see if I can then re-burn the (correct) bootloader?

simondumbo:
Thanks. I mentioned in my other post that I did, I think, find a crystal. Do I simply connect its two terminals across pins 4 (GND) and 7 (SCK) of the ATtiny and see if I can then re-burn the (correct) bootloader?

It's pin 2 on a Tiny85...

Give it a try, you can't do any harm. All you need is some pulses on that pin while you set the fuses.

simondumbo:
I can go and buy a crystal (I've never worked with them though).

(Probably) no need. What are you using for a programmer? Do you have an Uno (or equivalent)?

fungus:

simondumbo:
Thanks. I mentioned in my other post that I did, I think, find a crystal. Do I simply connect its two terminals across pins 4 (GND) and 7 (SCK) of the ATtiny and see if I can then re-burn the (correct) bootloader?

It's pin 2 on a Tiny85...

Give it a try, you can't do any harm. All you need is some pulses on that pin while you set the fuses.

Success!!

This is what I've done:

  1. Your comment about the pin told me I needed to do some homework. So I looked up the data sheet for the ATtiny85. (As they say, if all else fails read the instructions.) In paragraph 6.2.6 it shows you how to connect up a crystal.

  2. I carefully unsoldered the crystal from the old PC-board I happened to have lying around, as well as two surface-mount components next to it, which I assumed to be the required capacitors.

  3. Apart from the usual connections between the Arduino board and the ATtiny85 required to burn the Bootloader, I connected the crystal between pin 2 (XTAL1) and pin 3 (XTAL2) of the ATtiny, the one capitor between pin 4 (GND) and pin 2 and the other capacitor between pin 4 and pin 3.

  4. I then re-burnt the Bootloader, this time having selected the correct board, and it worked first time.

Unfortunately I have no idea what the values of the crystal and capacitors are.

(Probably) no need. What are you using for a programmer? Do you have an Uno (or equivalent)?

As mentioned in my other post the problem has been solved. For what it's worth, I used the ArduinoISP sketch and an Arduino Uno R3 board. Thanks again.

simondumbo:
Success!!

Yay!

simondumbo:
Unfortunately I have no idea what the values of the crystal and capacitors are.

Who cares, it oscillated!

Now you need to delete the "bad" entry from your boards.txt file so it can't happen again... :slight_smile:

Burnt wrong bootloader on ATtiny85 - how to correct?

Would burning the right bootloader correct it?

dhenry:

Burnt wrong bootloader on ATtiny85 - how to correct?

Would burning the right bootloader correct it?

You had me worried there for a moment, because I hadn't actually tried loading a sketch to the ATtiny.

But I have now done so and it does work. So, as far as I am concerned, it did correct what the previous (wrong) bootloader did.

For future reference, it's fairly easy to get a board running the ArduinoISP sketch to output an appropriate clock signal. LadaAda published a modified ArduinoISP sketch, I published a version, Nick Gammon published relevant code, and you can probably find a snippet in the forum.

Armed with a modified ArduinoISP sketch, you simply connect the clock output (an Arduino pin) to the XTAL1 pin on the target and re-burn the bootloader.

Good job extracting the crystal!

Why are you burning a bootloader on an ATtiny? The normal approach is just to upload programs to it via ICSP.

dc42:
Why are you burning a bootloader on an ATtiny? The normal approach is just to upload programs to it via ICSP.

Using the burn the boot loader option in the arduino IDE sets the fuses which determine the micro controller clock source. Factory settings run it at 1MHz so to run at the faster internal clock of 8 needs this step. By selecting an external clock source like the OP did in error the uC becomes unresponsive unless an external clock source is provided.

Same thing happens with the ATMega328 when setting up a standalone board - once the Arduino UNO boot loader is in place the fuses for an external clock are set and you can't get a reaction from the uC without an external clock signal of some type.

Difference here is there's no boot loader as such, so that process only sets the required fuses.

Geoff

Edit: fixed poor punctuation and spelling.

strykeroz:
there's no boot loader as such, so that process only sets the required fuses.

Yes, it seems to be an on-going source of confusion for the attiny series, that "burning a bootloader"under the Arduino tools menu is really only setting the fuses. No bootloader as such is written, and subsequently trying to program the device via tx/rx will simply not work.