Introduction: Programming Arduino Bootloader Without Programmer

Picture of Programming Arduino Bootloader Without Programmer

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!***

How?

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!!!

Step 1: What You Need

Picture of 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.

avrdude-GUI  
avrdude.conf 
serjtag-0.3
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

Picture of 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

Picture of 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

Picture of 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:

Duemilanove ATmega328
hFuse=DA
lFuse=FF
eFuse=05
Lock Bit=3F

Duemilanove ATmega168/Diecimila:
hFuse=DD
lFuse=FF
eFuse=00
Lock Bit=3F

Mega:
hFuse=DA
lFuse=FF
eFuse=F5
Lock Bit=3F

Step 5: Programming the Bootloader

Picture of 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

Picture of 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

Picture of 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

Picture of Programming AVRs

To use this as an ISP programmer is an easy task, and can save you some money!  First, you need to compile your code and save the HEX file generated in a location that you can remember.  Then you open the browse tab in the Flash area of the avrdude program abd choose the hex file.  Then you just wire up the connections from the X3 to your chip and click the Erase-Write-Verify button, and you have a programmed AVR.  You can also use this javascript applet to calculate the fuses for your AVR: AVR Fuse Calculator You just select your device and then what you want the fuses to be set for.  Just be careful that you don't mix up the hFuse and lFuse because you may end up disabling ISP programming accidentally.*** At which point you will need a HV programmer to fix it!

***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

Picture of 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
this check.

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!

Comments

DmitryP2 (author)2016-08-16

I do this like bootloader reflashing just now.

I used SparkFun FT232RL breakout board (china clone HEX FT232R Breakout)

First I try to use fast direct FT2XX bitbang, but I use Win7 x64 and got error "pthread not supported", so I was forced to use very slow (*) serial bitbang.

(*) but universal: serial bitbang can be done on any RS232 or USB-Serial converter.

I found that all logic volage levels on my FT232 was inverted, so I add special iverted configuration into hardware/arduino/avr/etc/avrdude.conf file:

programmer

id = "invdasa";

desc = "serial port banging, reset=!rts sck=!dtr mosi=!txd miso=!cts";

type = "serbb";

connection_type = serial;

reset = ~7; # RTS

sck = ~4; # DTR

mosi = ~3; # TXD

miso = ~8; # CTS

;

Also I rewired your connection scheme:

my device -> USBserial:

1 MISO -> CTS

2 VCC3.3 -> 3.3V

3 SCK -> DTR

4 MOSI -> TXD

5 RST -> RTS

6 GND -> GND

DmitryP2 (author)DmitryP22016-08-16

Also I added this ISP programmer into hardware/arduino/avr/programmers.txt file:

bitbang.name=Serial BitBang

bitbang.protocol=invdasa

bitbang.program.tool=avrdude

bitbang.program.extra_params=-P\\.\{serial.port}

(note \.\\ prefix -- I have COM10 порт so avrdude can use it only with prefix)

After that I restared Arduino IDE and got Serial BitBang programmer in menu.

DmitryP2 (author)DmitryP22016-08-16

Flashing looks like halted, so I closed ArduinoIDE and manually restarted arvdude from comman line:

C:\AVR\Arduino\hardware\tools\avr>bin\avrdude.exe -C etc\avrdude.conf

-c invdasa -p m328 -P \\.\COM10 <additional parameters>

1) test run

-n

2) erase chip and reset fuses

-e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

3) write bootloader (long time, but it must be done once)

-Uflash:w:C:\AVR\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m

victor.valadez.547 (author)2015-04-23

There is an alternative set of instructions that works if you have an Arduino Uno and want to transform it into an universal programmer for any stand alone AVR. Read this tutorial:

"Arduino Uno R3 as a true ISP programmer for any Attiny and Atmega AVR"

see:

No boot-loader has to be first loaded into your target AVR. You can simply program the Attiny or Atmega micro-controllers, existent on the breadboard, directly with the hex file generated from the source code you wrote (Blink a led, for example).

DanG10 (author)2015-01-04

Thanks a lot for this instructable! Worked flawlessly on a bricked ArduinoProMini using a breakout FT232RL (using avrdude.conf from step 9). While I have everything set up I'm now gonna try burning bootloaders on some bare Atmega328 chips.

The problem with the bricked Arduino manifested as the following output during programming from Arduino IDE:

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01

FourthDr (author)2011-02-12

I found this information independently via google searches (http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html) before finding your instructable. This method seems to have a few limitation.

1. Requires soldering (not a problem for me).
2. Only works with the bundled version of avrdude, does not work if you update to latest version.
3. Does not seem to be able to correctly program the new optiboot bootloader used on all newer arduino uno boards. (the reason I wanted to program the chip in the first place was to upgrade my arduino 2009 and mega 1280 boards with optiboot).
4. And finally, does this method work on a mega board? The arduino to arduino programming scheme on the arduino website only works between regular arduinos not with the mega board. Sketch needs to be tweaked??

The method you outline works fine with other bootloader variants designed for the standard arduino boards and with the older original bootloader only.

You might consider updating or creating another instructable that covers upgrading older boards with optiboot.

I'm still trying to find a reliable way to upgrade since I don't currently have an avr programmer.

Teslaling (author)FourthDr2011-02-14

1. Yeah, but its only 4 pins and TRUST ME, it can save you butt plenty of times!!

2. Actually, I didn't have WinAVR installed when I wrote the 'ible, it comes with its own avrdude that is designed to handle the Bit Banged FTDI programmer method.

3. Are you doing everything correctly, because it workes very efficiently for me, in fact, I use it as my main AVR Programmer too. How doesn't it work right? Did you select the right bootloader file? Did you update the fuses? Did you update the avrdude.conf file?

4. Yeah it will work with the Mega. The Bit Banged FTDI programmer doesn't use the Arduino programming scheme. It just programs the chip as a regular AVR that has a bootloader being written onto it.

FourthDr (author)Teslaling2011-02-19

This method does not work on an Uno. The Uno does not have the 4 pin header pads that the adruino 2009 has on it.

I tried updating the the avrdude software that was bundled with the avrGUI and serial-jtag software. If you make any changes to the avrdude.conf file then the GUI doesn't work properly or crashes. I also tried updating the FTD2xx.dll to the latest since that is a really old version and that does not work either. Something must be hard coded into the avrGUI.

If you have the arduino IDE installed, then you have a version of avrdude since that is what it uses to upload to the arduino. It is possible to update that version by copying the avrdude directory from the latest winavr to the same folder as avrdude in the arduino IDE.

Teslaling (author)FourthDr2011-02-19

I think I said that it won't work with the Uno, or Mega2560 (but I will make that more clear.)

Ok, thats strange, about the avrdude.conf file. Again, it works fine for me, no crashing or other problems.

I'm not sure what you mean by updating the avrdude in the Arduino IDE, that has nothing to do, whatsoever, with the avrdudeGUI as it has its own avrdude file.

This is really bothering me now why this isn't working for you, but I'm gonna keep trying to figure it out. :)

FourthDr (author)Teslaling2011-06-05

@gigavolt

After swapping 328 chips between my first arduino 2009 and a more recently acquired board. It seems the 328 chip is defective in some way. Because I can program both with optiboot ok. But when actually using the programmed avr, the older chip does not operate reliably where as the newer chip does. It's possible the chip had some flaw that was not apparent using the older bootloader. I'll have to pickup some spare 328's on my next order. :-)

PS: How do you edit a comment after it's posted? Seems you can only delete...

Teslaling (author)FourthDr2011-06-06

Yeah, it would seem as if you have a defective chip. My only question is did you remember to change the fuses?? I ran into that problem once. Any code that I put on a chip that had a loop in it within the first 1.5k of memory would get the chip stuck, because i forgot to resize the bootloader (by changing the fuses), so the program kept running that loop in the bootloader making it impossible to upload new code!!!

On another note, having a few extra mircos is always fun because you can do things like make them communicate from across the house to measure temperature and light or control stuff like the TV or lights!!! There is nothing like being able to change the channel to a specific channel the family room TV when you are in your room on the next floor!!!

And yes, it would appear as if you can only delete comments..

Just highlight your comments, copy, and then repaste them into the same reply you want to, then edit, obviously it will change the date to the current date.

FourthDr (author)Teslaling2011-06-05

@gigavolt

I'm now wanting to upgrade the boot loader on my mega 1280. How would this work on that board?

Teslaling (author)FourthDr2011-06-06

It would be the same process, solder the pins, wire them up to the ISP and get the new fuses and optiboot code. Just remember that you can only load 126k of code (i think) instead of the 254k that it says!

If you have any trouble, just let me know and I will do the best I can to help figure it out.

FourthDr (author)Teslaling2011-02-19

Also, have you a had any success programming the optiboot bootloader onto an arduino 2009 using this method? I haven't. Works fine with other bootloaders like the ADABootLoaderR3_9D15.

Teslaling (author)FourthDr2011-02-19

I've had great sucess with the optiboot bootloader. Actually I'm puzzled as to why it isn't working. I may take that part off if anybody else has problems though.

tech industries (author)2011-02-16

Great Instructable! Worked right off the bat!

It's great to hear that!!! And thank you for letting me know of your sucess!

jensenr30 (author)2011-02-01

I'm just getting started with arduino and I have but one question...
Is a bootloader the piece of software that accepts and stores programs on the ATmega chips?

Teslaling (author)jensenr302011-02-01

Yes, on the Arduino, the bootloader is what take the info from the Serial line and stores it in the flash memory. What's cool about Arduino is that it doesn't need an external programmer to program. Instead, it uses the USB to Serial converter to program it! Then it can use the same converter to communicate with your computer.

jensenr30 (author)Teslaling2011-02-02

Neat! Thanks a lot, Man!

About This Instructable

65,534views

44favorites

License:

Bio: I like to make things that move, sense, calculate, compute, blink, and make noise. I like making things that create high voltages, electrical arcs, and ... More »
More by Teslaling:The Valve Caster 2.0: Tube Boost and OverdriveBuild Your Own 555 TimerHelios 3: Homemade Rocket Candy Powered Rocket
Add instructable to: