HV Rescue Simple

24,383

19

41

Introduction: HV Rescue Simple

About: These Arduinos are driving me up the wall.

High voltage programming of ATmega328P and other Atmel chips on a breadboard

This procedure shows how to set up an Arduino as a high voltage programmer using a very small number of components: transistor, small inexpensive 12V battery, a paper clip, three resistors, LED, and assorted wire and breadboard. It works with just about any Arduino you may have handy, including Uno or older, Leonardo, Micro, Pro Mini, Nano, Mega2560, etc. The sketch has an easy-to-use menu with simple commands you send to it via Serial Monitor to read or set fuses on the target chip.

If you set this up and become comfortable with using the programmer, you can exploit features of the ATmega328P that you may have not used before, because prior to today most people think they've hopelessly bricked their processors once they set wrong fuse bits. Well, the fuse bits aren't wrong, they are available for use. For example, you can disable the reset pin and start using the reset pin as a general-purpose digital pin. You can disable ISP programming, if you have the need for that. You can set the 128K internal oscillator and experiment with the processor. You can now easily restore factory fuse settings or Uno fuse settings, or whatever fuse settings you want, whenever you have experimented with fuse settings that make your processor unrecoverable via the usual ICSP programming.

I recommend uploading the sketch to the Arduino before connecting the Arduino to the breadboard. The sketch was originally started by Jeff Keyzer for version 2 of his HV Rescue Shield (mightyohm.com/hvrescue2), and I have done extensive reorganization and alterations and simplification, to include giving it a user-friendly menu, changing some of the wiring, making it compatible with various Arduinos, and simplifying the reset circuit for breadboard use.

I recommend becoming familiar with the datasheet for your target processor before using high voltage programming.

Step 1: Wiring a Pro Mini As HV Programmer

The pictures show the progress I made as I wired the breadboard, and finally it was completed and my FTDI-like adapter connected with the sketch running.

In order to stay organized and make sure the wiring has the best chance of being done right, print out labels that show what each pin is used for on the target chip and on the Arduino. Print them out on regular paper, cut the labels out, and run them through a Xyron Create-a-Sticker machine (which you may find in your better half's scrapbooking tools), or put double-sided tape on them. Then use them and start laying out the breadboard components and wire according to the schematic. Notice the sketch uses digital pins 1-13, and all of the analog pins A0-A5. Digital pin 0, which is the RX pin, is not used.

I have found the small Arduinos such as Pro Mini or Nano result in the neatest breadboard wiring. If you use a Pro Mini or Nano it is also easy to use a multimeter to check continuity of all the connections, to make sure you haven't missed any connections. Note that on Pro Mini the RX pin is marked RXI and TX pin is marked TXO. The TXO pin is pin 1 and RXI pin is pin 0 regardless of how confusing the labeling on the Pro Mini looks. Connect the TX pin to the DATA1 line of the target chip, and do not connect the RX pin to any pin of the target chip.

Use pieces of a paperclip for a battery holder and bend them to get a little spring tension. You can use a 27A or A23 or other similar 12V battery. I have also borrowed a sealed lead acid 12V battery from a UPS. EBay has listings for extremely inexpensive step up converters that are breadboard friendly and can provide 12V. I am contemplating ordering a MT3608 DC-DC Step Up, which costs between $1 and $3 USD postage included. Those modules have the interesting requirement of keeping peak current "no more than TV University." You do not require much 12V current for this, it is just a signal to indicate to the target processor it should enter parallel programming mode, it is not burning anything with high current. If you leave your 12V battery connected to the circuit for a long time, it will drain. So, it would be a good idea to insert it right before programming, and remove it when done.

Notes about the labels I suggest using for keeping your work organized:

Vsup represents the pin 12 of the Arduino supplying operating voltage to the target chip, and that should be connected to the pins labeled V on the target. 12VG represents the pin A0 of the Arduino which controls the 12V switch or gate, and that should be connected to the resistor leading to the base of the transistor.

Step 2: Using Different Arduinos As HV Programmers

Here are photos of completed wiring for Uno, Leonardo, and Mega2560 setting the fuses on ATmega328P.

Step 3: Using the Sketch

To use the sketch:

  • Attach the Arduino to the computer with the USB cable.
  • Insert the 12V battery.
  • Open the Serial Monitor and set for 115200 baud.
  • The menu should appear and show you the proposed new fuses.
  • Type r and click send to read the existing fuses on the target.
  • If you like the proposed fuses, type w and click send to write them to the target.
  • To set custom fuses, type l, h, or x followed by a number to set the low, high, or extended fuse value, and click send. Repeat for any of the fuses you want to change. Then type w and click send to write them to the target.
  • Remove and insert the next processor you want to work with, or remove the 12V battery and disconnect the Arduino from the computer.

If the fuse readings show 02, 00, or FF for all fuse values it is likely the target chip is not inserted properly, wiring is wrong, battery polarity is reversed, or the battery is not producing something near 12V. Check everything with a multimeter, make corrections, and try again.

Step 4: Other Targets and Miscellaneous Notes

The schematic and sketch also handle setting fuses on ATtiny2313, ATtiny85, ATmega168P, and other targets. I have also used this to set the fuses on an assembled Digispark tiny85 board. Read the sketch and schematic, and especially study the data sheet for your target chip, to figure out the wiring.

If your target is a chip soldered on a board, such as Uno SMD or Nano or something like that, you should temporarily remove the DTR-to-Reset 0.1uF capacitor, the pull-up resistor for the reset pin, and the diode connected to the reset pin (if your board has one). You can put them back when you are done using the HV Rescue procedure.

Some of the pin connections serve dual purposes when programming ATtiny2313. To clarify what you see in the schematic, the BS1 pin of the Arduino (analog pin A2), goes to PD4 physical pin 8 on the ATtiny2313 and you leave the Arduino PAGEL pin of the Arduino (digital pin 5) unconnected. The PAGEL signals are sent through the BS1 pin by the sketch. The same thing is true of XA1 pin. The XA1 pin of the Arduino (analog pin A4), goes to PD6 physical pin 11 on the ATtiny2313 and you leave the Arduino BS2 pin of the Arduino (digital pin 9) unconnected. The BS2 signals are sent through the XA1 pin by the sketch.

How does the transistor switch on and off 12V to the reset pin of the target chip? Explanation: 12V is applied to the target chip reset pin through a resistor. So, you could say normally 12V is just applied to the reset pin. The transistor is switched on when it receives a 5V high signal from one of the Arduino pins, through the resistor to the base pin of the transistor. When the transistor is switched on, it conducts between the collector and emitter pins. This shorts to ground the 12V which was going to the reset pin, making it effectively 0V at the reset pin. When the Arduino sends 0V low signal to the base of the transistor, it switches off the transistor, and it no longer conducts, essentially taking it out of the circuit. 12V is once again applied to the target chip reset pin.

This is called inverting, because a low signal is applied to make an output go high, and a high signal is applied to make the output go low.

The resistor attached to the base of the transistor is a current limiting resistor. The resistor attached to the 12V battery does double duty: it is a current limiting resistor when the transistor is switched on and shorting the 12V to ground, and it is a pull-up resistor for the reset pin when the transistor is switched off.

The programming happens very quickly, but if you insert a delay(5000); in the sketch before the two lines "digitalWrite(RST, HIGH); // exit programming mode", it would allow you enough time to observe with a multimeter the voltage at the reset pin of the target chip, and see that it goes to 12V during reading or writing of the fuses.

Step 5: Links

7 People Made This Project!

Recommendations

  • Chocolate Challenge

    Chocolate Challenge
  • Cardboard Speed Challenge

    Cardboard Speed Challenge
  • Tinkercad to Fusion 360 Challenge

    Tinkercad to Fusion 360 Challenge

41 Comments

0
MakerSpec
MakerSpec

2 years ago

I've spent the last two days trying to get this to work with absolutely no luck. I started with a pro mini and 328P-mu on a QFN-DIP adapter connected with jumper wires, but kept getting changing fuse values and random garbage text over seriall. Probed all the connections from MCU pin to MCU pin to ensure there were no broken traces or wonky connections, made an excel spreadsheet of the connections to ensure I didn't mix something up, switched the 328P-MU several times, eventually even trying a brand new one to see if maybe the ones I'm trying to fix are just too far gone, even went as far as replacing the jumper wires with soldered wires, and still all I get is random, changing fuse values on every read. I've checked to ensure I'm getting 12v, checked the wiring and connections repeatedly, and I've changed out the Pro Mini for a 328P Nano and then a 168P Nano to rule out any issue with my USB-UART module and still, exactly the same result.

I'm not really sure why it'd make a difference seeing as the pin functions and mapping is the same across the MU, AU and PU packages, but for whatever reason this doesn't seem to like SMD packages.

0
dmjlambert
dmjlambert

Reply 2 years ago

I'm sorry you're having trouble with it. I built this on a breadboard a few weeks ago because I had some fuse settings to do, and I had 3 or 4 days worth of trouble getting it going. I double and triple and quadruple checked wiring and just walked away to cool off for a couple days. The problem ended up being I got the wiring wrong around the transistor and LED. I was also using a Pro Mini and got my wiring on A4 and A5 backwards and that slowed me down more. Eventually I got it right. I would consider this to be a fairly advanced and difficult project to breadboard, and it may not truly be worth doing from a money standpoint because new MCUs are pretty cheap. It depends on how much you are paying yourself by the hour. :-) But it can be interesting. I guess I got the name of the project wrong, should be HV Rescue Hard As Hell....

0
mistrije
mistrije

Reply 5 months ago

"I guess I got the name of the project wrong, should be HV Rescue Hard As Hell...."

nope! :D
is really hard to craft an "universal board" with correct wiring for all and any flavor of avr's AND all Arduinos and Arduino-like dev boards available...
so, wiring and breadboarding is the only realistic solution, unless you have tons of bricked "this type" of avr chips or boards... :)

and thanks! :D
i used your sketch and schematic for a lot of times, but on different boards, very rarely on bare tht chips, so... it was useless to brag about doing it, because it was done for one or two times... :)
it was a success, unless the chip was fried and toasted. the only times when it was working strangely, was the times i was in a hurry, and i don't triple checked all the wires... finally it works but that hurry cost me more time, so... lesson learned! :D

0
sod.almighty
sod.almighty

7 months ago

What is this "FTDI-like module" with an antenna you are using?

0
sod.almighty
sod.almighty

Reply 6 months ago

That is a really awesome idea. Thanks for getting back to me (and sorry this reply is so late).

0
kay Sagaragi
kay Sagaragi

Question 1 year ago

I want to use it in a atmega644A-pu, can it be adapted?

0
dmjlambert
dmjlambert

Answer 1 year ago

The answer is most likely yes. Read the datasheet of the ATmega328P and compare to the datasheet of ATmega644A where they talk about Parallel Programming Parameters, Pin Mapping, and Commands. It is there were you can find how to wire it. You will also need to know what fuse settings you want on the ATmega644A.

0
Carlos J.S
Carlos J.S

1 year ago

Tenia un Atmega328p bloqueado desde hace mucho tiempo, guardado en una caja, ahora, estuve trabajando con un Atmega8-16pu y tambien se bloqueo, ambos por accidente de haber deshabilitado el pin de reset en la programación de los fuses, ya habia probado con Avrdudes, con Sinaprog2.1, Arduino Isp y Usbasp, y con todos fue imposible hacer lectura ni grabarlos, aplique frecuencias distintas en el pin Xtal1 y varie la frecuencia del programador a 1/4 frecXtal1 y no resulto. Consegui este instructable y lo arme en una mañana en mi protoboard, con un arduino nano, subi el sketch, coloque 12V de una fuente regulada y a la primera funciono, me leyo los fusibles del Atmega8-16pu bloqueado, donde observe el error de fuses, en el monitor serie a 115200 baudios, coloque los nuevos valores de fuses que menciono L 0xEF , H 0xDE y reggrabe en el chip logrando volverlo a la vida.Una vez realizado esto, desmonte ese chip e inserte el Atmega328p, aplique los mismos pasos, pero introduje los valores usados en fuses de arduino uno, porque, es para esa aplicacion L 0xFF, H 0xDE, X 0xFD. La interface es bastante amigable y fácil de operar. Gracias amigo @dmjlambert por su generosidad en haber colocado toda la información de este trabajo tan importante para todos, Dios le bendiga con mucha salud.

IMG_20210426_204432.jpg
0
steventadema
steventadema

1 year ago

Worked perfect for Atmega8.
I have just recovered fuses to default (low E1 high D9) with success.
Thanks a lot.

0
panoss
panoss

1 year ago

Hi everybody.
I have two Arduinos Mini Pro, 8MHz. 3.3V.
The one is working fine, the other one must be bricked.
Can I unbrick it without desoldering the ATMega328p?

This is how I think I should connect them. Can you tell me if I have matched them correctly?
(the programmer Arduino is named 'Master'. The bricked is named 'Slave')

programmer......................bricked
Master........Label............Slave
PD1............DATA1...........PB1
----------------------------------------
----------------------------------------
GND.................................GND
PD2............DATA2...........PB2
PD3............DATA3...........PB3
PD4............DATA4...........PB4
PD5............DATA5...........PB5
PD6............DATA6...........PC0
PD7............DATA7...........PC1
PB0............XA0/SII..........PD5
PB1............BS2...............PC2


----------------------------------------
GND..................................GND
----------------------------------------
VCC..................................VCC
PC3(A3)........XTAL1.........PB6
PC2(A2)........BS1/SCI.....PD4
PC1(A1)........DATA0........PB0
PC0(A0)........12V_EN
PB5...............RDY/SDO..PD1
PB4...............VCC...........VCC
PB3...............OE..............PD2
PB2...............WR.............PD3

PC5(A5)........PAGEL.......PD7
PC4(A4)........XA1/SDI.....PD6

But, according to Mini Pro's schematic, XTAL1(PB6) is not connected to any pin.
So I can't access it through the pins but, maybe, desoldering it and soldering a wire?

0
douggorgen
douggorgen

1 year ago

I just stumbled across this thread again. It's been a couple years since I built Mr.
Dmjlambert's HV Rescue circuit but my opinion has not changed. Mr Dmjlambert's work is brilliant. If you read the comments, so many of them end
with "I found my wiring error". I think
the key here is to follow Mr. Dmjlambert's suggestion to create wiring
labels. I did, and the project worked
the first time for me. While I was
testing this, I hooked it up to my oscilloscope and the waveforms were rock
solid, indicating well designed hardware and software. Afterwards for comparison, I built one of
the other Instructables and scoped it.
The signals contained multiple noise spikes and at one point the power
and ground leads drooped indicating a power to ground short, probably caused by
a software error. This did not occur
anywhere in Mr. Dmjlambert's hardware and software. Mr. Dmjlambert's Instructable is
excellent. If it does not work for you,
please follow his instructions carefully.
Creating labels is a must in my opinion.


On a side note, I even followed his suggestion
and created a circuit board with an up converter to 12 volts. Since I only use Nanos, it is socketed for Nanos
and not as useful as Mr. Dmjlambert's design, but is useful for me.

0
rana_jee773
rana_jee773

2 years ago

I made it and it worked fifty fifty. i mean it recovered 2 out of my 4 ATmega8A's . On remaining two AVR's it hanged and serial monitor didn't responds. What may be the cause. Are these two AVR's gone? Please do reply. Regards

0
dmjlambert
dmjlambert

Reply 2 years ago

If it works reliably on the two MCUs you were able to successfully program with this method, and all you do is remove the ATmega8A and plug in another and it does not work, then my guess is the one that won't program is damaged beyond recovery. This high voltage programming method is intended to recover or rescue from fuse settings that disable regular ICSP programming, such as setting a fuse that disables the reset pin or fuse that disables SPI programming. It does not recover an MCU that is electrically damaged, such as one that was in a circuit that was shorted out, in a circuit that had design problems, or had too much current on some of the pins.

0
LouDNL
LouDNL

2 years ago

Hi there,

I made your instructable to try and revive a bricked Nano clone. At first I had to replace the Schottky diode on the Nano because that was broken. Then the Nano/Ch340 had USB again but alas no working m328pb. I tried several different programmers, but always had wrong output. Using an Arduino as ISP I could read the signature but was unable to write any fuses.
I then tried using the HVP sketch and schematic your instructable is based on but had no succes.
After implementing your schematic I can read the fuses, but writing doesn't change them. What could be wrong?
Would it be easy to implement reading the signature to check if the chip is indeed still working?

Edit: I checked if the needed 12v is applied with a dmm by setting the delay you proposed in another reply.
I also checked if the clock pulse is going to Xtal1 with logic pen tester, which is also the case.
Edit2: Could it be because i haven't removed the cap between rst-dtr and the pullup resistor?
Edit3: removed the cap and resistor but its still not writing the fuses. read out stays the same value though.

log:
Enter a command:
Read

Read Low Fuse hex: FF bin: 11111111
Read High Fuse hex: 1E bin: 00011110
Read Ext Fuse hex: F5 bin: 11110101

Enter a command:
ATMEGA mode

Enter a command:
Proposed High Fuse hex: DE bin: 11011110

Enter a command:
Write
Burning fuses
???
Burn complete

Read Low Fuse hex: FF bin: 11111111
Read High Fuse hex: 1E bin: 00011110
Read Ext Fuse hex: F5 bin: 11110101

Enter a command:

0
dmjlambert
dmjlambert

Reply 2 years ago

If Arduino as ISP works well enough to read the signature, then I think ISP programming is possible and high voltage programming will not increase likelihood of reviving the Nano. Some of the pins of the MCU may be damaged internally.

0
LouDNL
LouDNL

Reply 2 years ago

USBASP and MKII cannot read signature, only garbled hex values. Arduino as ISP can read the signature but the fuses are all zeros. The HVP programmer can read the fuses but not set them.
I have sent the Nano to the graveyard.

0
AhmedT146
AhmedT146

Question 3 years ago

thank you for the great project.

can i apply the same wiring of atmega328 28 pins with atmega32 40 pins ?

0
dmjlambert
dmjlambert

Answer 3 years ago

I had a brief look at the data sheet for the ATmega32. When I compare the parallel programming sections of the data sheets for ATmega32 and ATmega328P I notice they are very similar, but there are differences in how to go into programming mode. On the ATmega328P all you do is set 4 pins low, power the target VCC at 5V and a short time later bring RST high to 12V. On the ATmega32 there is a more complex way described where you bring RST low and toggle XTAL1 at least 6 times, then set 4 pins low and bring RST high to 12V. I don't believe the provided sketch for programming does those elaborate steps. However, it is interesting that the data sheet mentions an alternate way of going into programming mode of powering the target VCC at 5V and simultaneously bring RST high to 12V, used in certain circumstances to reprogram the fuses.
So, with all that said, I suggest just try it and see what you get. If you need to remove the delay between the time VCC gets power and RST gets 12V, that should be an easy fix in the sketch. But it could be the sketch as-is provides close enough to simultaneous applying of voltages to accomplish entering programming mode.
You'll have to study the data sheets to figure out the wiring.

pins.png
0
MatyášK2
MatyášK2

3 years ago

Can I use MOSFET??