Secondary Menu

Burning Bootloaders Into AVRs Using Arduino

Introduction: Burning Bootloaders Into AVRs Using Arduino

This instructable is the result of my failure with Optiboot(8Mhz) bootloader on ATmega8. While trying that, the clock fuse had been accidentally set to 16MHz which prevented me from using my AVR because I didn't have a 16MHz oscillator and my AVR would only boot up if I provided it an external 16MHz oscillator. While looking up for multiple solutions, I finally stumbled upon this link!

This instructable aims at the usage of two Arduinos, one as a programmer and the other as a pre-built Arduino circuit. Therefore method is a real help for those who have multiple Arduinos but no programmers such as USBasp etc. Now coming back to my ATmega8, since it required a 16MHz oscillator and Arduinos have them soldered in at the respective pin for ATmega328, wouldn't it be wise to use ATmega8 in place of ATmega328 because both have the same pin configuration? Now my external oscillator issue was solved and hence I proceeded with everything as shown in this instructable.

I'd like to add that this procedure will work with all the AVRs having the same pin configuration as that of ATmega328. In other words, your AVR has to be pin compatible with ATmega328. In my knowledge, this includes all the variants of ATmega8, ATmega328, ATmega48 and ATmega88. There may be others as well. If you know them, comment them down.

Step 1: Gather Around Some Stuff

The best thing about this method for burning bootloaders is that it doesn't require even require a single electronic component. All that it requires are only the basics!

Requirements:

Male to Male Jumper Wires - 6

AVR Chip (in which bootloader is to be burnt)

I'll be proceeding with the instructable by taking the ATmega8 as an example. The AVR should be pin compatible with ATmega328.

Arduino UNO(or any Arduino with 28 Pin IC Base)

Make sure that its ATmega328 is removable and not SMD. It will be used to insert your AVR and to burn a bootloader in it .I'll be referring to this board as Arduino-1 throughout this instructable.

Another Arduino (any version capable of storing ArduinoISP)

This Arduino board will be used as an ISP because I don't have one. If so, then simply hook up your ISP with the other Arduino. I'll be calling it Arduino-2 throughout this instructable.

Now that you have all the prerequisites, let's move on and start tackling the problem head on!

Step 2: Replacing the Arduino IC

Pick up Arduino-1, remove its IC(ATmega328) and insert your AVR in its place. The IC can be easily removed using tweezers by applying leverage at one of its ends and slowly pushing in the tweezers below the IC.

After that, insert your AVR in the correct indentation according to the IC base.

Step 3: Using Arduino As an ISP

If you have an ISP beforehand, skip this step! If not, then proceed with this.

Arduino IDE has a lot of useful sketch examples pre-installed. One of them is the ArduinoISP sketch which configures Arduino in such a way that it acts as an ISP. Therefore, to make your Arduino an ISP, simply upload ArduinoISP sketch to it.

In our case, this sketch has to be uploaded to Arduino-2.

The pin assignments of Arduino when it acts as an ISP are shown above in the form of pictures. Refer to them for better understanding of its wiring.

Step 4: Wiring Up the Arduino

We are almost halfway!

By referring to the above wiring diagram, connect your Arduino-1 with Arduino-2.

In this step, all that we're doing is connecting the pins of the AVR directly to Arduino-2. Note that Arduino-1 doesn't play any more role than that of supplying an external oscillator in this case. I'm only using it to get female headers for the pins of the AVR inserted in it, and because it has in-built oscillator circuitry. The main schematic from which this setup has been derived has been attached to this step.

If you intend to use your programmer rather than Arduino and are feeling out of place, then don't worry, refer to the diagrams for ISP to Arduino connections which are in this step as well as in the previous step.

Step 5: Burning the Bootloader

Considering you've done everything correctly up till now , we can proceed with the burning of the bootloader into our AVR.

Follow these steps to do so:

Connect your PC with Arduino-2.

Open Arduino IDE, no matter which version, and do the following.

Select the board whose bootloader is to be burnt in the AVR. For example, as shown in the picture, you'll choose Arduino UNO if you're burning the bootloader onto ATmega328 because Arduino UNO is based around ATmega328 and therefore it's bootloader will be the same.

Set the COM Port to Arduino-2's COM port. In my case, it was COM1. Yours might differ.

Set the Programmer as "Arduino as ISP".

Hit Burn Bootloader under Tools menu.

After clicking on "Burn Bootloader", the burning will begin. You should see the constant blinking of Rx and Tx LEDs on Arduino-2. After about half a minute you should also get a message saying "Done Burning Bootloader".

I would like to add that I didn't upload any official board's bootloader onto my ATmega8! I wanted to use the internal oscillator of my ATmega8 because I don't have any oscillator. Therefore I used a different bootloader. The method I used is covered over here. Keep in mind that the wiring used here is the same as the one used there. Therefore you can continue using the wiring you've done till now to proceed with that method.

That concludes this step.

Step 6: Congratulations!

Phew! That was some work! Anyways, now your desired bootloader has been burnt into the inserted AVR successfully and it is up to you whether you use it in combination with Arduino-1 or in other circuits. I was able to get my two ATmega8s in working condition, and replace a busted ATmega328 of an Arduino UNO(Arduino-1).

I have embedded the video of the ATmega328, in which I have burnt the bootloader, programmed with Blink sketch.

Wondering About Sketch Uploading?

I'd like to add that sketches can be uploaded to the AVR using the identical setup you used to burn the bootloader. However, instead of clicking on "Burn Bootloader", you use "Ctrl+Shift+U" key combination to upload the opened sketch onto the AVR. All this key combination does is that it tells the IDE to upload the sketch using the programmer.

I'd like to write more but I think that I've written all there is to write in this instructable. If you think I'm missing something, you're more than welcome to mention suggestions!

By:

Utkarsh Verma

Thanks to Ashish Choudhary for lending his camera and to Abhishek Kumar for lending his Arduino(Arduino-1).

Yes, it is possible. You "might" require a 16MHz crystal oscillator, but that depends on whether your device has the clock fuse set to 16Mhz. If it isn't then you won't even need the oscillator. So tell me about your device.

Regarding the availability of electronics goods in India, it's really bad. That's why I always order my components from Aliexpress. It has all the required stuff.