Saturday 29 August 2015

Burning the Bootloader on ATMega328 using USBasp Programmer

            In this tutorial you'll learn how to burn arduino bootloader on new ATmega328 using USBasp ISP programmer.Please be noted that every Arduino Board comes with a microcontroller ATmega328 pre-program with arduino bootloader firmware. Therefore, there is no need to burn the bootloader firmware again.But if you want to make your own DIY arduino board than you need to burn arduino bootloader into ATmega328.So here i'll show you how to load arduino bootloader into atmega328 step by step.  

Required components:
  1. USBasp Programmer
  2. Bread Board 
  3. ATmega328 
  4. 2pcs 22pf Cap.
  5. 16MHz Crystal
  6. 10K Resistor 
  7. Hook up wire 
  8. AVRdude Software
     First of all wire up the circuit in breadboard as show in below diagram.Please connect all the connection carefully. 


ATmega328 connection with USPasp



      Show in above circuit JP1 is from USBasp programmer. Connect all the connection carefully as per above diagram using jumper wire.If you wire up your circuit correctly than it's time to load hex file which is located in your arduino software folder here is complete path arduino-1.0.5-windows\arduino1.0.5\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex  you can also download from here optiboot_atmega328


        
First of all you need to install AVRdude software and USBasp Programmer Driver.
         

 Open AVRdude software and select programmer type from the drop-down list show in below image.In our case programmer is USBasp programmer. 
         

       After Selecting programmer type click on "Detect" so programmer automatically detect  ATmega328. If you have any problem with detecting microcontroller check all connection carefully. 


        
        After detecting microcontroller now it's time to read fuse bits and lock bits. Show in below screen shot click on "Read". Make sure do not write wrong fuse bit otherwise your microcontroller stop working.

Default value of fuse bit.
LOW Fuse : 0x62
HIGH Fuse : 0xD9
Extended : 0x07
LOCK :0xFF
Reading fuse bits

           Now browse hex file which is located in your arduino software package"arduino-1.0.5-windows\arduino1.0.5\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex" you can also download from here optiboot_atmega328. Select file and click "Open".



          Now click on "Program!" button. It will take like 30 seconds, You can now use your cheap, ATMega328 as a normal Arduino.


I hope you found this useful,don't forgot to share this with your friends.

17 comments:

  1. Hi, great to see how to do it manually and have more control over the process. I have just use the Arduino IDE to burn the bootloader. It supports about 5 programmers.

    ReplyDelete
  2. This is a very good tips especially to those new to blogosphere, brief and accurate information… Thanks for sharing this one. A must read article.
    Used Lab Equipment Distributors

    ReplyDelete
  3. avrdude.exe: set SCK frequency to 1500000 Hz
    avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
    avrdude.exe: error: programm enable: target doesn’t answer. 1
    avrdude.exe: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.

    avrdude.exe done. Thank you.
    this error show. how to sort out this error… plz give advice….

    ReplyDelete
  4. Dear Firat G,

    Check the connection between programmer and target microcontroller and also check the clock frequency target microcontroller.

    ReplyDelete
  5. I did it thank you very much for your help.I had connection problem and corrected it.But i want to ask you something else.When i read fuse bit, i see different values from values you write here as default.I couldn't decide which one i have to use.

    ReplyDelete
    Replies
    1. Dear KOÜ Diş Hekimliği Sosyal Etkinlikler Topluluğu KOUDHSET,

      First of all erase chip and check connections,and write Low fuse (0xFF),High fuse(0xDE), Extended fuse(0x05), lock fuse(0x0f).

      Delete
  6. I did it thank you very much for your help.I had connection problem and corrected it.But i want to ask you something else.When i read fuse bit, i see different values from values you write here as default.I couldn't decide which one i have to use.

    ReplyDelete
  7. Hello,
    Don't you think that, for reset must be connected pin 1 no 29?
    Thank you!

    ReplyDelete
  8. Oppsss I'll update very soon.

    Thank you very much for point out mistake.

    ReplyDelete
  9. avrdude.exe: set SCK frequency to 1500000 Hz
    avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
    avrdude.exe: error: programm enable: target doesn’t answer. 1
    avrdude.exe: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.

    avrdude.exe done. Thank you.
    this error show. how to sort out this error… plz give advice….

    ReplyDelete
    Replies
    1. you should update your USBASP firmware to get rid off that error. google for "Updating firmware on USBASP bought from eBay" by Roger Clark.
      i've done it successfully to my USBASP. good luck.

      Delete
  10. I am getting different fuse bits when i read from my atmega328p

    ReplyDelete
  11. Open Electronics blog is one of my favorite blogs which I often keep visit to keep me up to date. prototype pcb assembly

    ReplyDelete