OH NO!!! You've screwed up and now the Arduino bootloader on your 'duino is gone! What are you going to do? Go spend money for a programmer??? Well don't! I've got a solution that only requires your 'duino and some wires! So its not the end of the world, it is just a minor glitch in the space-time continuum!!! In just under an hour you can have your 'duino back!***
Well you know those pads near the USB that have the label X3? Well those will become your programmer!!!
Ok, ok. Not everybody messes up, but this will help you if you want to put the bootloader on a new chip, or you actually do mess up. This setup can even program other AVR's using ICSP.
***The amount of time you will spend is not garunteed to be under an hour, and I will NOT take responsibility if you can't reprogram your bootloader.
!!!This will not work with the Uno or Mega2560!!!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What You Need
This programmer requires minimal physical components, only wire, an Arduino, (with the FDTI USB to Serial converter built in, so no Uno, Pro, Lilypad, Mega2560, etc.) and a soldering iron and solder.
However, you will need some programs and files to operate the programmer.***
Below are the included program files.
The last download wouldn't work so the link is to the page where you will find it. You will have to scroll down until you find the link labeled serjtag-0.3.zip. The mirror site is the one that works. Save all 3 files in one folder where ever you would like, we will get to those in a minute.
***Currenly available for Windows only.All files are virus FREE.
Step 2: The Hardware Setup
Setting up the hardware is pretty simple. First you need to solder 4 pins onto the X3 pads. Next you need to wire it up.
There are a few methods:
1. You can connect the pins to the pin header on the board, which would go as follows: Pin 1 on the X3 would connect to pin 12 on 2009 and Diecimila or pin 50 on Mega. Pin 2 would connect to pin 13 on 2009 or Diecimila or pin 52 on Mega. Pin 3 would connect to pin 11 on the 2009 and Diecimila or pin 51 on Mega. Pin 4 of the X3 would connect to the RESET pin.
2. You can run jumpers to the ICSP pin header, which would go as follows: Pin 1 would connect to pin 1 on the ICSP header. Make sure that it is pin 1, it should be labeled. Pin 2 would connect to pin 3. Pin 3 would connect to pin 4. And finally, pin 4 would connect to pin 5.
3. Tha last way is to use a 6 or 10 pin (must have a 6 pin connector on it as well for Arduino ICSP) ISP cable. To connect the 6 pin connector to your arduino, you need to find the ICSP pins, then when you plug the connector in, the wires should cover the reset button - on the 2009 and Dieimila only! On the Mega, they should not cover the reset button, but instead cover part of the chip. Connecting the X3 pins is a bit trickier. Below shows the pinouts in picture 5. Pin 1 is in the top right when you look at the pin connectors, and the wires are going to the right!!*** For the 6 pin connector, pin 1 of the X3 goes to pin 1. Pin 2 of the X3 goes to pin 3. Pin 3 of the X3 goes pin 4 of the connector. Pin 4 of the X3 goes to pin 5. For the 10 pin connector, pin 1 of the X3 goes to pin 9. Pin 2 of the X3 goes to pin7. Pin 3 goes to pin 1 and pin 4 goes to pin 5.
***Refer to pictures 6 and 7. Also be careful because the pin diagrams show pin 1 on the left. but it should be on the right. The reason is that the diagram is of the pin headers, not the cable.
Step 3: The Software Setup
Remember those files you downloaded and saved? Well now your going to set them up.
We are going to start with the folder named serjtag-0.3.zip. First you will want to upzip the folder and save it somewhere. Next, open it up, then open the folder inside named avrdude-serjtag. Next open up the "binary" folder. Inside you should see an avrdude.CONF file, an avrdude.exe file, a COPYING text document and a ftd2xx.dll file. Leave that window open, and open the folder where all of the downloads are stored and copy the avrdude.CONF file from it into the serjtag folder that you were working with. Replace the document and now your good with that.
Next, to setup the actual program. Open the folder with the downloads, and open the avrdude-GUI.exe file. This is the actual program.
You will need to find the input field with the title "avrdude.exe File" Click on the browse box next to the input field and find the serjtag folder and go into the avrdude-serjtag folder then binary folder and select the avrdude.exe file.
Next select the programmer: FT232R Synchronous BitBang (diecimila).
The device: Either ATmega168p, ATmega328p or ATmega1280.
NOTE: Leave the port box empty!!!
The Command line operation: -P ft0 -B 4800
Now you're ready to go!
Step 4: Running Avrdude
On the first test, you are going to read the device's fuses. In the Fuse category, click read. In a few seconds you should get the fuses. If you get an error message, first make sure that the 'duino is connected, then if it persists, see the troubleshooting page.
If its a success, then try reading the lockbit. If you can read the lock bit too, then you can set the fuses.
Click the Chip Erase button. Then choose the correct fuse settings from below:
Step 5: Programming the Bootloader
Now, to program the Bootloader. You will need to find the boot loader HEX file, so open up the browse option under the Flash section on the program. The bootloaders can be found at: ...\arduino-00xx\hardware\arduino\bootloaders\atmega8, or ...\arduino-00xx\hardware\arduino\bootloaders\atmega. The first one has the normal bootloaders for 2009 or earlier and the second one has the bootloader for the Mega.
Choose the correct HEX file and click open.
Then in the Command line Option box, take off the -B 4800!! It is optional but leaving it there makes programming last up to ten minutes!!
Now in the Flash option, click Erase-Write-Verify.
As long as no errors pop up, you should have the new bootloader, or your regular one back!
If you have multiple chips and you are upgrading, leave one chip unprogrammed until you are sure that it worked, until you tested it.
Now that the bootloader is loaded onto the chip, unplug it from your computer and plug it back in (this resets the FTDI chip which can't be done by hitting reset.) You should now see the LED on pin 13 repeatedly blink, as it runs the bootloader. Good job! Now you can test it.
Step 6: Testing the Bootloader
Now open up the Arduino IDE and run some test sketches. I would recommend running the ACSII table sketch to make sure the seial works properly, and a few sketches that use I/O pins. If it doesn't upload, first make sure you unplugged and plugged the Arduino back in. If it still doesn't upload, try burning the bootloader again. (If you cannot get it to work, you may have to use a different method, such as an external programmer.)
Step 7: How It Works
As you may know, the Arduino uses the FTDI FT232RL USB to TTL Serial converter chip. What you may not know is that the chip has the ability to control all of the Serial pins over the USB Port, called Bit Banging, because you are turning the pins on and off as needed. In the setup we are using, the X3 pins are connected to the CTS, DCD, DSR, and RI pins. In the avrdude program, the input hex file is used to toggle the 4 pins in such a way to act as a programmer, writing the data in the file. Once the programmer is done though, you still have to unplug and plug the board back in though because the chip has to be reset in order to go back to being a USB to Serial conveter. If the board had a reset pin connected to FTDI chip's reset line then the board wouldn't have to be plugged back in, but until then... oh, wait Arduino doesn't use the FTDI chip anymore!
Step 8: Programming AVRs
***Again I am NOT responsible if you mess up your chip(s).
Step 9: The Other Boards...
Say you don't have a board with the FTDI chip, but you have a FTDI breakout board, for your mini or lilypad, etc., you could potentially use it but you would have to change the avrdude.CONF file to accomodate a board that only has the RX, TX, DTR, and CTS. Included is a revised .CONF file that only will work with those four pins. The ISP connections are: RXD=MISO, TXD=MOSI, DTR=SCK, CTS=Reset.
Note: I don't have the means to test this configuration so if you find that it doesn't work, please let me know and I'll try to fix it and get back to you.
Here it the new avrdude.CONF file:
Step 10: Troubleshooting
Here is where you can try to troubleshoot any problems that you have. If you can't solve it here, please send me a message and I will try to help you as best I can.
If you get an error that reads: avrdude.exe: ft0 open failed
Then make sure your board is plugged in.
If you get a error that reads:
avrdude.exe: BitBang OK
avrdude.exe: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude.exe: drain OK
ft245r: bitclk 230400 -> ft baud 115200
avrdude.exe: ft245r_program_enable: failed
avrdude.exe: initialization failed, rc=-1
Double check connections and try again, or use -F to override
avrdude.exe done. Thank you.
Then check your wiring first. After you have made sure that all of your wiring is correct, try doing the operation, but add -b 4800 to the Command line Operation if it's not already there.
If you are trying to write something to the chip and you get an error that ends in a similar fasion to:
avrdude.exe: verification error, first mismatch at byte 0x0000
0xff != 0x3f
This means that you will need to click the Erase Chip box before you can write whatever you were writing.
If you have successfully written the bootloader but you don't see the LED blinking, or your sketch won't upload, unplug and plug the board back in.
These are the only troubles that I have run into so far, so if you experience something else, please let me know!!
Good luck and happy programming!!
Don't forget to rate!
Participated in the