Following on from my post about using the AVR dragon to program blank AVR ICs, here is the process of buring the Arduino bootloader code onto an ATMEGA 328P.

Firstly install AVR studio 5.0, as explained in the previous post. You will also need a version of the Arduino IDE installed. This post is for Windows users (sorry…). Let me know the instructions for linux distributions, please.

You will need to wire up a connector as shown in the AVR Dragon user guide. In my guide the ATmega 328P is not listed, as this component was added to the range later. The wiring is the same as the connections for the ATmega48, ATmega88 and ATmega128, which are listed in the guide. I built a hard-wired connector, but you can also use fly leads and a breadboard to connect to the blank IC. The configuration is for ISP and debug wire emulation, so follow that wiring diagram.

Take a blank ATmega328P IC and put it into the programmer. Plug in the programmer o a spare USB port – you should hear the ‘device inserted and OK’ sound. Open AVR studio 5. Click onto Tools -> AVR programming. This will open a pop-up. Select the programmer (AVR Dragon), he device (ATmega 328P) and the interface (ISP). Click on the ‘read’ button to find the device ID and the target voltage. If his is working then you know you have communication to the IC.

Click on ‘Memories’. Under the Flash heading you can browse to find the .hex file you would like to upload. In this case I wanted to upload the Arduino bootloader for the ATmega328. This can be found within the Arduino IDE program files. In my version (version 0.22) it is found in arduino-0022 -> hardware -> arduino -> bootloaders -> atmega. You can also find other bootloaders there if you want to burn to other ICs (but please check the fuses required (see later) if you want to program other ICs). The bootloader for the ATmega328P is “ATmegaBOOT_168_atmega328.hex”. This is the Duemilanove for the ATTmega328, rather then the newer and smaller UNO bootloader. I will update when I have found the UNO bootloader code and the fuse settings.

Click ‘program’ and watch the status bar as the IC is programmed and verified.

The next thing to do is to set the fuses for the IC. Fuses allow the device to be set to run with different oscillators and in different configurations. A factory fresh IC will be set with a fuse to use the internal oscillator. The Arduino uses a 16MHz crystal oscillator for the frequency (which gives more accurate timing). We need to set fuses to tell the IC what oscillator to use (along with some other parameters). To do this you need to click on the ‘Fuses’ tab. This shows a list of fuse settings. I found that the parameters to use (for ATmega328 and  Duemilanove) are:

  • Extended: 0x05
  • High: 0xDA
  • Low: 0xFF

Update 16/7/12: The fuse values for the UNO bootloader are:

  • Extended: 0x05
  • High: 0xDE
  • Low: 0xFF

From: http://www.estechnical.co.uk/case-studies/50-embedded-devices-and-software/90-atmega-fuses-and-arduino-bootloaders

and: http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/

So write these into into the various fuse registers and then program them. Be very careful to double check them. If you put the wrong fuse setting then you will end up with a mis-programmed IC, which will need the high voltage programmer to re-set the fuses.

Once programmed with the correct fuses then device will no longer work/connect in the AVR Dragon. This is because you have just told the IC that it should use an external crystal oscillator, but there is not one wired in. This is OK.

Place the IC with the Arduino bootloader into your Arduino platform (I generally use the Xino from Ciseco). Try uploading a simple sketch (I generally use a serial output test). The device should function as expected. Try uploading a different sketch and check it is working, just to make sure.

Hopefully you should have a programmed ATmega328 with the Arduino bootloader. The AVR Draogn can be used to program in circuit (as the term In-System Programming might suggest). Let me know if this works for you or any issues you might come up against.Also – please let me know about the UNO bootloader and fuses required.

Note: I will try and add screenshots when I have the system rigged up again.

2 responses to “AVR Dragon to program Arduino Bootloader

  1. hello i make everything as you describe but i have error avrdude: stk500_getsync(): not in sync: resp=0x00 🙁

  2. Hi,
    That error means there is no communication between the computer and the target within the Arduino environment.

    Did the AVR Studio give any errors?
    I would suggest that the fuse settings have not been written correctly.
    Are you using the ATmega328 with a 16MHz crystal? Thats what the fuses set.

    In the Arduino IDE did you select Board -> Arduino UNO (or whatever bootloader you have programmed)?

    I’d check the Arduino IDE to the Arduino first, if possible with a working Arduino. Then you can start to figure out the issue.
    Good luck with it,

    Matt

Leave a Reply to Guest Cancel reply

Your email address will not be published. Required fields are marked *