loading

When you are working with Attiny's like the Attiny 85 or the Attiny13, it is bound to happen sooner or later: you brick your Attiny.
I got faced with it while trying to burn a bootlaoder (i.e. setting the correct fuses), that I suddenly got the dreaded 'Yikes! Invalid device signature' error message. As I had just succesfully burned it on IDE1.06 and now was trying on IDE1.6.3, just to see if I installed everything OK, I knew the chip was OK and that my programmer was OK. Also, a new chip did well, so something ominous must have happened to my chip.

Could it be because my computer had some memory problems during the burning???
Well, not much choice but to try and reset my Attiny85.
For that you need a Serial High Voltage Programmer. Plenty of circuits to find, so no way I claim to be original here, but I am writing this ibble to take away any hesitation that people might have by showing how quick and easy it is.

All it takes are 6 resistors, a transistor, a DIL foot, a 9x20 piece of stripboard and a 7-pins male header and of course a 12 Volt supply. And yes, A UNO to stick it in.

As I didnt expect to use the programmer very often, I planned to use a battery, but as I couldnt find my 12 Volt battery, I ended up using a 0.75 USD (so 75 dollarcents) 5 to 12 Volt converter from aliexpress, that i had for another project.

I used the program below. The program starts when you send a random character to teh serial port. As it turns out, it was a fuse problem in my chip as the fuse bits were E4 DF which means it was set for 128 kHz oscillator. Not sure how that could happen as I removed that choice from my menu in the boards.txt file.
Anyway, it reset the fuses to factory setting and after that I could use my Attiny85 again.
Sadly, in order to build this unbricker, I had to use the 1k resistors I wanted to use for the very project I was programming the Attiny for :-) Oh well!!
All in all took me less than an hour to put it together So if you are having problems with your Attiny13/25/45/85 build one of these.
If you want to unbrick the 24/44/84 series, you need a bigger DIL Foot.
If you are trying to unbrick an Attiny15.. then remember that that has PB3 and PB4 switched compared to the 13/25/45/85 series, so you probably need a software or hardware change (Tar and feathers for the Atmel designer who did this)

// AVR High-voltage Serial Fuse Reprogrammer<br>    // Adapted from code and design by Paul Willoughby 03/20/2010
    //   <a href="http://www.rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer/" rel="nofollow"> http://www.rickety.us/2010/03/arduino-avr-high-vo...</a><br>    //
    // Fuse Calc:
    //   <a rel="nofollow">http://www.rickety.us/2010/03/arduino-avr-high-vo....</a>
    #define  RST     13    // Output to level shifter for !RESET from transistor
    #define  SCI     12    // Target Clock Input
    #define  SDO     11    // Target Data Output
    #define  SII     10    // Target Instruction Input
    #define  SDI      9    // Target Data Input
    #define  VCC      8    // Target VCC
    #define  HFUSE  0x747C
    #define  LFUSE  0x646C
    #define  EFUSE  0x666E
    // Define ATTiny series signatures
    #define  ATTINY13   0x9007  // L: 0x6A, H: 0xFF             8 pin
    #define  ATTINY24   0x910B  // L: 0x62, H: 0xDF, E: 0xFF   14 pin
    #define  ATTINY25   0x9108  // L: 0x62, H: 0xDF, E: 0xFF    8 pin
    #define  ATTINY44   0x9207  // L: 0x62, H: 0xDF, E: 0xFFF  14 pin
    #define  ATTINY45   0x9206  // L: 0x62, H: 0xDF, E: 0xFF    8 pin
    #define  ATTINY84   0x930C  // L: 0x62, H: 0xDF, E: 0xFFF  14 pin
    #define  ATTINY85   0x930B  // L: 0x62, H: 0xDF, E: 0xFF    8 pin
    void setup() {
      pinMode(VCC, OUTPUT);
      pinMode(RST, OUTPUT);
      pinMode(SDI, OUTPUT);
      pinMode(SII, OUTPUT);
      pinMode(SCI, OUTPUT);
      pinMode(SDO, OUTPUT);     // Configured as input when in programming mode
      digitalWrite(RST, HIGH);  // Level shifter is inverting, this shuts off 12V
      Serial.begin(19200);
    }
    void loop() {
       if (Serial.available() > 0) {
        Serial.read();
        pinMode(SDO, OUTPUT);     // Set SDO to output
        digitalWrite(SDI, LOW);
        digitalWrite(SII, LOW);
        digitalWrite(SDO, LOW);
        digitalWrite(RST, HIGH);  // 12v Off
        digitalWrite(VCC, HIGH);  // Vcc On
        delayMicroseconds(20);
        digitalWrite(RST, LOW);   // 12v On
        delayMicroseconds(10);
        pinMode(SDO, INPUT);      // Set SDO to input
        delayMicroseconds(300);
        Serial.println("Reading: ");
        unsigned int sig = readSignature();
        Serial.print("Signature is: ");
        Serial.println(sig, HEX);
        readFuses();
        if (sig == ATTINY13) {
          writeFuse(LFUSE, 0x6A);
          writeFuse(HFUSE, 0xFF);
        } else if (sig == ATTINY24 || sig == ATTINY44 || sig == ATTINY84 ||
                   sig == ATTINY25 || sig == ATTINY45 || sig == ATTINY85) {
          writeFuse(LFUSE, 0x62);
          writeFuse(HFUSE, 0xDF);
          writeFuse(EFUSE, 0xFF);
        }
        readFuses();
        digitalWrite(SCI, LOW);
        digitalWrite(VCC, LOW);    // Vcc Off
        digitalWrite(RST, HIGH);   // 12v Off
      }
    }
    byte shiftOut (byte val1, byte val2) {
      int inBits = 0;
      //Wait until SDO goes high
      while (!digitalRead(SDO))
        ;
      unsigned int dout = (unsigned int) val1 << 2;
      unsigned int iout = (unsigned int) val2 << 2;
      for (int ii = 10; ii >= 0; ii--)  {
        digitalWrite(SDI, !!(dout & (1 << ii)));
        digitalWrite(SII, !!(iout & (1 << ii)));
        inBits <<= 1;
        inBits |= digitalRead(SDO);
        digitalWrite(SCI, HIGH);
        digitalWrite(SCI, LOW);
      }
      return inBits >> 2;
    }
    void writeFuse (unsigned int fuse, byte val) {
      shiftOut(0x40, 0x4C);
      shiftOut( val, 0x2C);
      shiftOut(0x00, (byte) (fuse >> 8));
      shiftOut(0x00, (byte) fuse);
    }
    void readFuses () {
      byte val;
            shiftOut(0x04, 0x4C);  // LFuse
            shiftOut(0x00, 0x68);
      val = shiftOut(0x00, 0x6C);
      Serial.print("LFuse: ");
      Serial.print(val, HEX);
            shiftOut(0x04, 0x4C);  // HFuse
            shiftOut(0x00, 0x7A);
      val = shiftOut(0x00, 0x7E);
      Serial.print(", HFuse: ");
      Serial.print(val, HEX);
            shiftOut(0x04, 0x4C);  // EFuse
            shiftOut(0x00, 0x6A);
      val = shiftOut(0x00, 0x6E);
      Serial.print(", EFuse: ");
      Serial.println(val, HEX);
    }
    unsigned int readSignature () {
      unsigned int sig = 0;
      byte val;
      for (int ii = 1; ii < 3; ii++) {
              shiftOut(0x08, 0x4C);
              shiftOut(  ii, 0x0C);
              shiftOut(0x00, 0x68);
        val = shiftOut(0x00, 0x6C);
        sig = (sig << 8) + val;
      }
      return sig;
    }
<p>How to use it? Is it enough to burn it or upload it on arduino? I have not understood the use on arduino because there is no video tutorial that I can see. thank you for your answer</p>
<p>put the attiny in the board an insert in the arduino. </p><p>upload the program to the arduino,</p>
<p>I made this variant. The top side of the ZIF socket acts as a normal programmer, the bottom sie being this HV programmer. The only thing to o is to reprogram the Nano and off you go. The little switch is to enable the &quot;do not reset&quot; capacitor, needed for normal programming.</p>
<p>Looking mighty good. Thanks for sharing. With 'reprogram the nano' I presume you mean either load the ISP or the HV sketch</p>
<p>Hi diy_bloke, could you modify your program so that some status is visible on LED's? For example HV on, or programming done, or busy, ..?</p>
<p>The programming time is rather short so I am not really interested in having LED's indicate statusses, but you ofcourse could always add it yourself and share it here </p>
<p>ok I will as soon as I get to it.</p>
<p>Exactly right. And that is also why I needed that blue switch.</p><p>&quot;On&quot;, as in, capacitor to RST connected: use for sketch uploading to the ATtiny85.</p><p>&quot;Off&quot;, use for uploading ISP or HV sketch to the Nano.</p>
<p>I forgot: I have a few of those 5-&gt;12V converter modules very very handy.</p>
<p>I wonder why SCK, MISO and MOSI from the Arduino Uno are not used?</p><p>Erik$</p>
<p>You mean pins 11, 12 and 13? They are used.<br>Happy Newyear</p>
<p>Hi, thks for your quick reply! I am confused: Arduino Uno SCK is on pin 13 (PB5), MISO is on pin 12 (PB4) and MOSI is on pin 11 (PB3).</p><p>In your drawing ATtiny pin 5 (PB0, MOSI) goes to Arduino D9 (pin 9?), ATtiny pin 6 (PB1, MISO) goes to Arduino D10, ATtiny pin 7 (SCK, PB2) goes to Arduino D11 (MOSI), ATtiny pin 2 (PB3) goes to Arduino D12 (MISO).</p><p>And in the sketch pin 5, 6, 7, 2 and 1 are respectively configured as SDI, SII, SDO, SCI and Reset.</p><p>So my question:</p><p>1. MISO, MOSI and SCK are not on the corresponding pins on the Arduino Uno: what do I miss?</p><p>2. In high voltage programming it seems as if rather SDI, SII, SDO , SCI and Reset are used as variables: what is the difference with MISO and MOSI?</p><p>Thks,</p><p>have a great New Year!</p><p>Erik</p>
<p>OK, now I get your point. Well this is not SPI programming, it is High voltage serial programming, that you still can use if for instance SPI (ICSP) is disabled. One of the pins is SCI (serial clock input), one is SDI (data in to the chip), one is SII (instruction in to the chip), and one is SDO (data out from the chip). <br>So it is totally different from SPI programming</p>
<p>Ah ok!! Now next question.</p><p>I am in process of making a pcb to do both ISP and HV programming for all ATtiny MCU's, based on initial work by Kai Bader: </p><p><a href="https://github.com/kaibader/ISP-HVP-Shield/tree/master/Rev_2.0" rel="nofollow">https://github.com/kaibader/ISP-HVP-Shield/tree/ma...</a></p><p>We agreed I could develop his unfinished project. But I am in need of someone to help me program this project.</p><p>Goal: use HV serial programming on one pcb for ATtiny85/45/25/15/13, ATtiny84/44/24, ATtiny26/261/461/861, ATtiny2313/4313 and ATmega328/168.</p><p>Question: is HV programming for all these MCU's possible, and what changes to my pcb would be needed to get this programmed (see attachment)</p><p>Thks!!</p><p>Erik</p>
<p>Hello ! can you modify it (or the whole code) for Attiny2313 ?<br>I tried my self a bit gone this far :</p><p><strong>#define t2313 0x1e910a // Signature of device (found while burning bootloader to a functional chip)</strong></p><p><strong>#define HFUSE 0xDF <br></strong></p><p><strong>#define LFUSE 0x64<br> #define EFUSE 0xFF</strong></p><p>//calculated from :</p><p>// <a href="http://eleccelerator.com/fusecalc/fusecalc.php?chip=attiny2313a&LOW=64&HIGH=DF&EXTENDED=FF&LOCKBIT=FF" rel="nofollow"> http://eleccelerator.com/fusecalc/fusecalc.php?ch...</a></p><p>...</p><p>...</p><p>...</p><p>else if (<strong>sig == t2313</strong>) {<br> writeFuse(LFUSE, 0x62); // i dont know what 0x62 is. some sort of memory location? because I have defined LFUSE above<br> writeFuse(HFUSE, 0xDF);// same goes for this.<br> writeFuse(EFUSE, 0xFF);// if that is memory location. than I may read its data sheet to search for it.I did read it but just for calculating the fuses. which I later found that these were already written in my board.txt.<br> }</p><p><br>and MY Serial Console is printing this :</p><p><strong>Reading: <br>Signature is: FFFF<br>LFuse: FF, HFuse: FF, EFuse: FF<br>LFuse: FF, HFuse: FF, EFuse: FF</strong></p><p><br></p><p>Thanks Again :) !</p>
<p>0x62 is not 'some sort of memory location' <br>it is the Low Fuse that is in e.g. the attiny85 the standard Low Fuse <br>that the chip comes with from the manufacturer. For the attiny85 this is<br> LF=0x62 HF=0xDF and Efuse =0xFF<br>For the attiny2313 this is 0x64 0xDF 0xFF.<br><br>The memory locations are actually LFUSE, HFUSE and EFUSE.<br>So the command write(LFUSE,0x62) doesnt write the LFUSE value to 0x62, but it writes 0x62 to the LFYSE location.<br>for<br> your chip that is not the default, it should be 0x64. The difference <br>between 0x64 and 0x62 in your chip is the clock source selection (bit 2 <br>instead of bit 1)<br><br>because you defined HFUSE, LFUSE and EFUSE <br>(that is the location of these fuses, not the value) you have started to<br> write values to random places in your chip.<br><br>You could have easily seen this in the program as the definition for all the chips is:<br>#define HFUSE 0x747C </p><p>#define LFUSE 0x646C </p><p>#define EFUSE 0x666E<br>(again, these are the memory locations, NOT the values of these fuses)<br>So why would this suddenly be completely different for the attiny2313.<br>also<br> as you can see in the program, that for e.g. the L,H and Efuse the <br>values are 62, DF and FF and those are completely different from the <br>numbers 646C, &amp;4&amp;C and 666E coz again, one is the location, the <br>other the value that is written in that location.<br><br>If you have a <br>look at the function &quot;writeFuse()&quot; you se it is writeFuse (unsigned int <br>fuse, byte val), so first the address of the fuse and then the value of <br>that fuse.<br><br>Anyway, now we come to the next problem. The Attiny2313 is a 20 pin chip that is programed differently from the 8 and 14 pin chips. The latter are progrmmed with HVSerialprogramming while the Attiny2313 as far as I know is programmed with HVparallelprogramming. Therefore you need more datapins connected to the programmer. You may have a<a href="http://mightyohm.com/blog/products/hv-rescue-shield-2-x/"> look here </a>for that.<br><br><em><strong>Now purely for educational purposes</strong></em><br>If you were to make the code suitable for the attiny2313 (but it<strong><em> wont work</em></strong> as it needs parallel programming, but OK for arguments sake):<br>Remove your definitions:</p><p><strong>#define HFUSE 0xDF </strong></p><p><strong><strong>#define LFUSE 0x64<br> #define EFUSE 0xFF</strong></strong></p><p><br></p><p>then you add a line under the chip definitions like this:<br>#define ATTINY2313 0x1E910A // L: 0x64, H: 0xDF, E: 0xFF 20 pin<br><br>and then you add your code:</p><p>if(sig==ATTINY2313){<br>writeFuse(LFUSE, 0x64);<br> <br>writeFuse(HFUSE, 0xDF);<br> <br>writeFuse(EFUSE, 0xFF);<br>}Just<br> one thing, the attiny2313 is a bit of an odd chip. apparently there <br>have been some problems with it and Atmel actively promotes using the <br>attiny2313A<strong><strong></strong></strong></p>
<p>Yes I have an ATtiny2313A-PU named chip.</p><p>okay I get it now :) ... and thanks for the link. <br>Thank you again !</p>
<p>Good to know, thanks! =D<br>Hope I never have to do this though haha</p>
<p>tnx Raphango</p>
<p>Thanks diy_bloke.</p>
<p>my pleasure</p>
<p>I am stuck! What is a DIL foot? Can't find the expression anywhere.</p>
<p>I apologize, it probably got lost in translation. In proper english it would probably be called DIP-8 IC socket </p><p><a href="http://www.aliexpress.com/item/Free-Shipping-60pcs-DIP8-Socket-Adaptor-Solder-Type-8-pin-IC-Socket/32541669442.html?spm=2114.01010208.3.11.NnEomo&ws_ab_test=searchweb201556_10,searchweb201602_3_10037_10017_507_10033_10032,searchweb201603_2&btsid=89b30a23-1ac9-46de-9506-9a09bf567f98">http://www.aliexpress.com/item/Free-Shipping-60pcs...</a></p>
<p>Here is the picture of my board. It also inspired me to make an ATtiny programmer board (2nd pict) that has the capacitor for the reset to hook it up with a wire on it. The only thing to do was to modify the Arduino ISP to power up pin 9 (LED_HB in the sketch). Using an output pin for Vcc is really neat :-)</p>
<p>As I'm on it: here's the sketch for the layout of the modified board. The red and black wires are for the external power supply.</p>
<p>Really great stuff. Worked like a charm and I can even use it to set my own fuses with little code change. BTW: If you turn the transistor and move it up 3 holes the board is even easier to build.</p>
<p>I am happy it was of use to you. Thanks. good tip.... for others that is as I probably will need only one board :-)<br>But I will check into it and possibly change the design</p>
<p>is it necessary to use 12volt supply?</p><p>Is it safe while working with Arduino?</p><p>Do I need to connect 12volt Supply with this programmer? and then try to unbrick it ?</p><p>Thank you. PLZ reply. I have done making this board with all resistors. just need to ask these questions. thanx</p>
<p>yes the 12 Volt is necessary for High Voltage programming. But please read the instructions very carefully.............................<br>Do not feed the chip directly with 12 Volt. The ONLY pin that gets 12 Volt is pin 1 on yr attiny and then only via a resistor.<br><br>None of the other pins should get 12 Volt<br>and None of the pins of your Arduino should get 12 volts<br>There is ONLY ONE 12 Volt connection on the entire board and that is on R5.<br><br>Your Arduino should just be fed like normal and receive 5 Volt<br>Do not, I repeat DO NOT attach the 12 Volt anywhere else than to the proper side of R5</p>
<p>Can I unbrick other chips of ATtiny with is method ? I mean the chip which has more than 8 pins ?</p>
<p>yes you can, up to a point. I believe at a certain moment you need a parallel High Voltage Programmer, this is a serial High Voltage Programmer. I am not sure at what point you need the parallel programmer, but I believe the 2321,4321, and 24,44,84 series can be done with this method</p>
<p>Done :) <br><br>I MADE IT !!!</p><p>Thank you again :)</p>
<p>good :-)</p>
<p>Cool!</p>
<p>tnx :-)</p>

About This Instructable

3,655views

41favorites

License:

Bio: I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I ... More »
More by diy_bloke:Working With the Funduino W5100 Ethernet Module. Uploading Data to ThingSpeak With MQTT Adding an MCP23017 I/O Extender to Arduino or ESP8266 
Add instructable to: