Arduino-based AVR High Voltage Programmer

Arduino-based AVR High Voltage Programmer

Update 01/02/09: A PCB version of this circuit is in the design stages – some preliminary information is here.

Update 03/11/09: Kits based on this design are now for sale!

Update 12/14/10: The original AVR HV Rescue Shield kit has been replaced by the new and improved HV Rescue Shield 2.  Visit the HV Rescue Shield 2 product page for information about the new kit!

As I mentioned earlier this week, I recently “lost” an ATmega168 due to flashing the configuration fuses to disable the RESET pin, without realizing that this makes the device impossible to reflash with SPI.  This is particularly frustrating because the device is still 100% functional, just completely deaf to ordinary serial programmers.  The only way to recover the device is using what Atmel calls “High Voltage Parallel Programming Mode” which very few programmers support, most importantly, not the USBtinyISP I otherwise love.

Fortunately, my trusty Arduino came to the rescue – I created an Arduino-based AVR programmer that uses the high voltage programming mode and can fix pesky fuses like RSTDISBL.

The Arduino has just enough IO to implement the entire HV protocol plus a “go” button.  So far I have only implemented setting LFUSE and HFUSE in software, but there is no reason why the code couldn’t be extended to support chip erase and programming the entire flash as well.

Overview:

The fuse programming process is simple:

  • Upload the HVFuse sketch to the Arduino, available for download here: HVFuse.pde
  • Install the shield and apply +12VDC to the terminals on the left
  • Wait for the red LED to turn on (if it isn’t already)
  • Install the ATmega to be repaired
  • Push the button
  • As soon as the LED turns back on, the AVR is fixed and ready to be put back into service!

Schematic:

Here is an Eagle schematic of the HV Programming shield (click to enlarge):

Update 12/17/08:  An observant reader pointed out that there were three errors in the way GND/AGND, AREF and VCC/AVCC were connected on the target AVR in the original schematic.  The errors have been fixed and the updated schematic is below.  Apologies for any confusion this caused.

hvfuse_fixed.sch

Parts list:

  • An Arduino NG, Diecimila, or compatible
  • A piece of perfboard cut to size
  • Header pins for the Arduino interface (note I had to drill some of the holes to get the headers to fit the nonstandard pin spacing for digital lines 8-13.
  • An LED which indicates when it is ok to insert/remove the AVR
  • A 2N3903 or similar NPN transistor (2N2222, etc.)
  • (20) 1k resistors – these protect the Arduino from short circuits in case something goes wrong
  • A pushbutton switch – this is the ‘go’ button
  • A 28 pin socket for the target AVR

Kits!

A kit version of this project is available.  Visit the HV Rescue Shield 2 product page for more information.

136 thoughts on “Arduino-based AVR High Voltage Programmer”

    1. What version of the hardware are you using? I suspect that you are trying to use the HV Rescue Shield sketch with the original version of the programmer shown on this page. That won’t work. You need to build the newer version of the board or buy a kit to use the newer, interactive Arduino sketch!

  1. Great! but still not work forme.
    I need additional code for Efuse , Lockbit.
    Please give me an exsample.(I’m a newbie in AVR)

    1. The AVR HV Rescue Shield is supported by a sketch that can set EFUSE, but not the lock bits. While the newer sketch doesn’t support the original version of the HV programmer shown above, it shouldn’t be too hard to port it to work with the older hardware. I believe the only differences are a couple pin assignments and the polarity of the HV enable signal. I’m not sure what it would take to set the lock bits (or if HV parallel mode even supports setting them).

  2. Ken – Thanks!

    For people who don’t want to solder the surface mount components, the full kit version comes with them pre-soldered to the PCB, so all that is left is through hole soldering!

    The parts in the kit are shown here. The PCB is shown as it ships, with the DC-DC converter and surrounding components already soldered. I have these in stock now.

    https://mightyohm.com/blog/products/avr-hv-rescue-shield/

  3. Thank the Lord for GREAt favors – Hey Jeff, you could have used 0402 chips also, there HAS to be a limit somewhere. I think I can work with 0804 chips ok – just prefer the 1206 chips.

    I got the board yesterday – looks great. You did a GREAT job of layout. Thanks.

    I hope to get it fab’d up in a few days…. I’m in the middle of another project just now.

    Ken H.

  4. Good deal Jeff = thanks for the GREAT work. The order has been placed this morning, looking forward to it…. now, just why didn’t you use 1206 SMD parts rather than those “tinny tiny” 0804 parts? {grinning}

    Ken H.

  5. He Jeff, thx, for the artschool in Rotterdam Holland (WDKA.nl) I thought I could save a bit of money buying ATMega’s instead of Lilypads and Arduino’s. I ran in the same fuses trouble I found in your blog (having more experience in Iphone programming :-). Just in this holiday week I decided I could try building your shield. I had to be careful (so being not at all artistic) and indeed I succeeded in…yes! making a tiny shortcut in between two near pins, of course the 5.5V and the GND of the ARDUINO. Invisible to the naked eye, there was a microscopic soldering error on my board between the not even connected pins!
    USB protection saved me twice, but then amazingly my shield (a master copy of your shield) worked! I could recuperate the ATMEGA 168. (And the 9 others I had apparently meshed up!)
    You will be remembered in the blog i write for the school

    Your picture of the shield helped a lot making the right placements, (and my backside is as ‘artistic’ as yours, i only saw it after finishing…)

  6. Thanks for the update Jeff – I’ll be looking forward to the PCB/Kit… depending on how you offer it. “IF” you wish someone to “beta test” a PCB or kit, just let me know, you have may email address? I’ll be happy to purchase a PCB or kit to help out – I expect I’ve got most all the parts in my spare parts bin.

    73 de Ken H>

  7. Thanks Ken!

    I just got word from BatchPCB that the prototype boards are on their way. Once I verify that the step up converter is working and modify the code the kits should follow pretty quickly…

  8. Thanks for the response Jeff – I did not realize how different the ATtiny45 and the t2313 or m168 chips were. I do understand, and I am STILL looking forward to your PCB board… kit or finished product? Will just the bare PCB be available? and perhaps MOST important – WHEN!!!! {grinning}

    Keep up the GREAT work Jeff. It’s sites like your’s that allow me to learn more as I struggle along. My old mind just isn’t as agile as it was 40 yrs ago.

    Ken H>

  9. Roberto – Read the rest of the comments! At least two people have made this circuit without an Arduino. The most recent was Brandt, he posted his results at:

    http://pomprock.netdojo.com/blog/2009/01/avr-high-voltage-programmer.html

    Ken – I just got some samples of the ATtiny45 to play with, but they use a different programming mechanism and would require extending the code to support high voltage serial programming. It’s on my list of things to look at but I wasn’t planning on including it on the Arduino shield.

  10. Hey Jeff, I see the new PCB will do both the m168 and t2313 – is there any chance of getting code to do the ATtiny45 chip also? That would cover all 3 chips I currently use….. well, planning to use anyway.

    I WILL be watching your site for that HV programmer.

    73 de Ken H>

  11. Hi Jeff, please. I don´t use Arduino. I want know if you have some schematic to do a simple interface without arduino that can reset fuses for atmega128 and another models.. I make write wrong some fuses and need unlock them. With google I found your project. Please, some info are very appreciated ! Nice work ! 😉

  12. Brandt,

    Way to go, and nice breadboard skills! I’m really glad you got the programmer working eventually, sorry for the mistake in the schematics, but it’s all fixed now.

    I’m making a fancy PCB version of the circuit so if you ever do get an Arduino you can try it out without having to build your own from scratch.

    Jeff

    1. Hi Brandt,

      Please repost the link where the HVP is made without the Arduino but on the breadboard. The current link does not work. Thanks!

  13. Thanks for your help with the AVR HV programmer to reinstall the default fuse bits on my ATmega48.
    I was using an PIC16F876 and recode your AURDIN code to a CC5X compiler (BD-knudsen c-compiler) And IT! work
    I can send you source code and HEX file for this PIC16F876 if some out there want to use that.

  14. Hi! I’ve just succeeded in rescuing ten atmega8 (they had SPIEN=1 and RSTDSBL=0) using this method ! It really works, but I had to rewrite the software for avr libc (as I don’t use Arduino).

    Here’s my code with gEDA schematics :
    http://grapsus.net/up/misc/hw/hvprog.tar.gz

    Thank you for publishing your code, it would have been much harder to understand the parallel programming protocol without it.

    1. Nice! Definitely I am going to try this out tonight! I have too many locked ATMEGA8 that i need to revive!

  15. Westfw – The .sch file is kind of a mess, in that I grabbed components with decent looking symbols without regard for the PCB footprints, but if you want it anyway I can send it to you.

    I have plans to make a PCB with an integrated step up converter, just haven’t gotten to it yet.

  16. Are you publishing the machine-readable version of the (corrected) .SCH file? There are some thoughts floating around about having some PCBs made…

  17. YESSSSSSS It worked!!

    I fixed my circuit according to the new schematic, I also used an LM317T w/ trimpot instead of an LM7812A to get my 12volts. So I don’t know if the exact 12v matters. But I don’t care to test cause it worked!!

    Thanks Jeff!!!

  18. Brandt – I think so but I haven’t done it before so I’m not 100% sure.

    Very important update!

    Another reader found an error in the original schematic that might be causing your problems. I had screwed up the GND/AGND, AVREF and VCC/AVCC pins in the schematic. I fixed the schematic, if you look now you should see:

    On the target AVR:
    Pins 8 (GND) and 22 (AGND) are tied together and to GND on the Arduino.
    Pin 21 (AVREF) is not connected to anything.
    Pins 7 (VCC) and 20 (AVCC) are tied together and to pin 08 on the Arduino.

    Sorry for the screwup and I hope this hasn’t been causing people headaches. I’m actually really surprised that noone pointed this out to me before now, given that several people have built this circuit and reported good results!

  19. That site is great, but It doesn’t talking about programming the fuses on your atmega168 to act like an Arduino. When you burn the bootloader does it setup the fuses for you?

  20. I just thought of something…I’m not using an arduino, i’m using an atmega168 on a breadboard. What fuses should I set on the atmega168 to make it equivalent? Do the arduino’s run at 16mhz? Would that matter?

Leave a Reply