The AVR Dragon is a little more of an expensive route to go if you’re looking to burn Arduino Bootloaders. They can ring in around $50 per unit, though they do come in a beautiful red box with a dragon painted on it. The USBTinyISP is about $10, for comparison, and will get the job done just as easily — actually, it’s easier. So if you’re going out to buy a programmer I’d recommend the USBTinyISP, however, if you’re lucky like me and have tons of gadgets like this lying around at work to play with then it’s certainly a viable option. I found this unit hiding in a dusty box on a shelf, seemingly forgotten as no one in knew what it was or why we had it, even though I already had an STK500 hooked up and ready to go as well as a USBTinyISP at home I thought I’d fire it up just for the experience.
The first thing you’re going to need is AVR Studio. Even if you’ll be burning your bootloader through the Arduino program you’ll still need AVR Studio for the drivers. Unfortunately I could not locate stand alone drivers and was forced to download all 600mb of AVR Studio for this purpose only, so I suggest starting that process first so you can get everything else ready while it downloads.
You Will Need
- Atmel AVR Dragon Board
- An ATMEGA or ATTiny chip
- An Arduino board (or breadboard)
- 6 pin ISP Programming Cable
- AVR Studio 4/5 Software
- Arduino Bootloader HEX File
Setup the AVR Dragon
In this example I’ll be using the 6 pin ISP header which I will connect to my Arduino board. The AVR Dragon can do High Voltage Programming (HVSP) if you solder on a DIP or ZIF socket on the breadboard area to the right side. See this Instructables Guide for instructions on how to do that.
Unlike setting up the STK500 for HVSP programming the setup for the AVR Dragon in ISP mode is a breeze. The only “gotchya” is when hooking up the ISP cable make sure to align the cable so the wire with the red stripe matches the Pin 1 marker on each end. The AVR Dragon does provide power to the destination board via the VCC headers but I found it’s easier to power the Arduino by hooking it up to another USB cable or via a walwart adapter. Once both boards have power and are connected via the ISP header you are ready to fire up AVR Studio and program the bootloader onto the chip.
Programming it in AVR Studio 4
AVR Studio is a free program that only requires you register with AVR in order to download it. AVR Studio 5 is now available, and is the recommended software for this task, but this guide will stand for all who have not yet chosen to update.
After loading the program you will be prompted to create a new project or load an old one. We will do neither so hit Cancel and then on the main menu select Tools -> Program AVR -> Connect…. Now select the AVR Dragon as your platform and the USB Port and then click Connect again.
On the next screen select your device, in this case the ATmega168, and select ISP as your Programming Mode. I always hit Read Signature to make sure everything is connected properly. Now move on to the Program tab and under the Flash section select your HEX file. They can be found in your Arduino installation directory, check /hardware/arduino/bootloaders and you will find several variations there, more can be found online. After you have loaded the correct one hit Program and then when complete move to the next tab.
Next you’ll sit the Fuse settings. The correct settings for the ATmega168 chip are 0xF8, 0xDF, 0xFF but make sure to use the correct settings for the chip you are using. Click Program then go to the Fuse Bits tab and set it to 0xCF and hit Program again.
At this point your Arduino is ready. You can plug it in as per usual and upload a Sketch in the Arduino software. I usually start by loading the Blink program as it is a quick and easy way to test the bootloader as the built in LED on Pin 13 will allow you to easily access if the program is running. Make sure to upload a sketch again to make sure your lock bits were set properly, as if they are not the sketch will overwrite the bootloader and a subsequent upload will fail.
Programming it in AVR Studio 5
AVR Studio 5 is the new and improved way to build your AVR programs. It runs off the Visual Studio Shell which gives .Net developers an “at home” feeling when using the software. Beyond that I couldn’t tell you what the extra features are as I only use it for programming the bootloaders and everything else I do right in the Arduino software. The software can still be downloaded for free after registering, and is unfortunately about 600mb to download, which is a lot for what we’ll be doing today.
Uploading the bootloader is pretty much the same. Start off by going to Tools then AVR Programming. On the next window select AVR Dragon as your Tool and ATmega168 as your Device. Then ISP as your Interface then click Apply. Click Read for both Device ID and Target Voltage to make sure everything is hooked up correctly and to initialize some settings.
Jump to the Memories tab and under Flash select your HEX file from the Arduino folder. They can be found in /hardware/arduino/bootloaders or easily found online. Make sure to load the proper HEX file for the chip you are working with, in this case we are using an ATmega168 chip so the file I use is ATmegaBOOT_168_atmega328.hex since I was too lazy to complile the ATmegaBOOT_168.c file. Once the proper file is loaded click Program.
Now move on to the Fuses tab and set them to 0xF8, 0xDF, 0xFF and then hit Program before moving on to the Lockbits tab where you will set it to 0xCF before hitting Program again. Once again, verify the settings for your chip as they will vary. You may also want to tweak them to your own needs, for instance you may want to use the internal oscillator to run the chip at 8 MHz instead of the 16 MHz you get with the external crystal. The lockbits will be configured to prevent the bootloader from being wiped each time you upload a sketch, so if you’re bootloaded chip only works once through the Arduino software’s upload method, then you likely forgot to set the lockbits or didn’t set them correctly.
Testing Your Bootloaded Chip
After flashing the bootloader you can disconnect the ISP header and plug the Arduino board into your USB port before loading the Arduino software. Once it is loaded open the Blink sketch and then select your board and port before uploading. The blink sketch is the best tool for testing a chip as Arduinos now come with a mini LED and a resistor already installed on Pin 13 which this sketch is configured to use. Please note that older versions of the Arduino only had the 1k ohm resistor preinstalled so it will still need an external LED on Pin 13. If your sketch uploads without an error you shouldn’t have any problems, but either way I suggest watching the LED for a few seconds to ensure that it alternates between on and off, if it does this then upload the sketch one more time to make sure you didn’t set the lockbits wrong. If it works the second time then your bootloaded ATmega is ready to go!
Only registered users can comment.
I would like to know about the programming software that you are using in to burn the Arduino bootloader expect to help me in this.
There seems to be a little mistyping in the chapter about programming with AVR Studio 4. 0xCF has to be programmed into the Lock Bits, not into the Fuse Bits.
Thank you for the description.