Sunday, November 16, 2014

Recovering a "bricked" ATtiny85 from bad clock fuse settings

In my endeavor to add some board selections in the "boards.txt" that offer BOD protection, I managed to burn fuses on an ATtiny85 to run it at 128kHz, aka the watchdog oscillator. Bad idea. At this point the ATtiny became unresponsive and the IDE displayed the error below. Arrggh, just bought these. BTW, I'm using an Arduino Nano v3.0 as an ISP for the ATtiny85.


Error after trying to burn the 128kHz boot loader …
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override         this check.
Here's how I un-bricked them ...
  1. Checked wiring, checked again.
  2. Downloaded an enhanced ArduinoISP sketch from https://github.com/adafruit/ArduinoISP which essentially allows you to fix bad fuse settings.
  3. I renamed it to ArduinoISP2 so I could differentiate it from the original. 
  4. Before you load this on your programmer (nano in my case), you'll want to un-comment out the line "#define LOW_SPEED" which enables all the wonderful un-bricking goodness packed inside. I also had a 10uF cap on the nano's RST pin and GND (for uploading sketches to the ATtiny85) so I pulled this cap out before uploading.
  5. Now you can upload the ArduinoISP2 sketch.
  6. After the upload, I inserted my 10uF cap back on the nano's RST pin.
  7. Next, I selected a known good board selection for the ATtiny85 at 1 MHz and burned the boot loader set the fuses. You may encounter the following error:

         avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x00
         avrdude: stk500_cmd(): programmer is out of sync

    Just keep going, the rest is easy.
  8. Now i went to the original ArduinoISP sketch and uploaded that to the nano, so out with the cap again, upload, cap back in.
  9. Now repeated step 7 with the difference being that the ISP is going regular speed. I got the usual error message ...

         avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
    which just fine with me.
  10. I tested it out with the Blink sketch (led = 4) to verify everything was peachy. Blink blink blink.
Edit - 20150829 - changed "burned the boot loader" to "set the fuses".
Edit - 20150923 - this only worked with Arduino 1.0x.

4 comments:

  1. No, it means that I apparently did not burn a bootloader at the time the fuses were set. I was messing around with fuse settings and the method of setting fuses through the Arduino IDE is to select "Burn Bootloader". There are different ways to brick a chip and to be honest my chips may not have been truly bricked at the time of writing. MIT's High-Low Tech tutorial for the ATTiny is a better resource than this lousy blog.

    ReplyDelete
  2. Thanks Man! You saved me 15€ :D

    ReplyDelete
  3. I tried it but at step 7 it stopped with the error
    avrdude: Device signature = 0x000000
    and the following stuff. I dont know why i cant programm/use my 2 completly new ATTINY85's

    ReplyDelete