Using AVRDrgon with Atmel Studio/Arduino Ide to Burn the Bootloader

First, information about how you can  use the AVR-Dragon with the Arduino IDE:

Using the AVR Dragon with the Arduino IDE

AVR Dragon

Modifying the box

You can cut a slot for the USB and anchor the Dragon AVR using the opposite tab

Using the Dragon as ISP

The ISP header is marked on the Dragon PCB

In order to use the AVR Dragon with the Arduino IDE, you need to edit the internal programmers.txt file to add an entry for the Dragon. On Mac OS and Arduino 1.0.1, the file is present at:

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/programmers.txt

Quit all running instances of the Arduino IDE, open the file with your favorite text editor and add the following:

dragon.name=Atmel AVR Dragon in ISP mode
dragon.communication=usb
dragon.protocol=dragon_isp

You should now be able to select the AVR Dragon in:

Tools > Programmer > AVR Dragon in ISP Mode

Restoring Arduino MEGA Bootloader with ATMEL Studio

22 January 2016

After programming an Arduino MEGA board using Atmel Studio, the bootloader in the Arduino will be overwritten by the program loaded to the Arduino. The instructions that follow show how to restore the bootloader of an Arduino MEGA 2560 using an Atmel AVRISP mkII or AVR Dragon and Atmel Studio. When the bootloader is restored, the Arduino will be able to be programmed using the Arduino IDE software via the USB port.

1. Locate the Arduino MEGA Bootloader File

Locate the bootloader hexadecimal or hex file for the Arduino MEGA 2560 which is included with the Arduino IDE software. After downloading the Arduino IDE software and unzipping it, open the Arduino IDE folder which is in the form arduino-<Arduino IDE Version Number> and locate the bootloader file called stk500boot_v2_mega2560.hex as described below.

For example, in Arduino IDE version 1.6.7, the hex file is found in arduino-1.6.7\hardware\arduino\avr\bootloaders\stk500v2\ as shown in the image below. This is just to show the location of the file – we will need to navigate to this file from within Atmel Studio.

Arduino MEGA 2560 bootloader file locationLocation of the Bootloader File for the Arduino MEGA 2560

2. Connect the Programmer

Connect the programming device, such as the AVRISP mkII or AVR Dragon to the PC USB port and to the ICSP header of the Arduino MEGA 2560, then power the Arduino from its own USB cable.

Start Atmel Studio and click the Device Programming icon on the top toolbar or select Tools → Device Programming from the top menu.

Atmel Studio Device Programming Button on Top ToolbarAtmel Studio Device Programming Button on Top Toolbar

In the Device Programming dialog box, select the Tool (AVRISP mkII or AVR Dragon), Device(ATmega2560) and Interface (ISP) then the click the Apply button. To test that Atmel Studio can communicate with the AVR on the Arduino board, click the Read button under the Device signature heading.

Connect Atmel Studio to the ATmega2560 AVR on the Arduino MEGA 2560Connecting Atmel Studio to the ATmega2560 AVR on the Arduino MEGA 2560

3. Program the Bootloader using Atmel Studio

Click Memories in the left pane of the Device Programming dialog box. Click the [] button found at the right of the box under the Flash label to browse for the bootloader file.

Browse for the Arduino MEGA 2560 bootloader hex fileBrowse for the Arduino MEGA 2560 Bootloader Hex File

Navigate to and select the hexadecimal bootloader file called stk500boot_v2_mega2560.hexfound in the Arduino IDE software sub-folder hardware\arduino\avr\bootloaders\stk500v2. Click the file in the dialog box and then click the Open button as shown in the image below.

Selecting the MEGA 2560 bootloader fileSelecting the MEGA 2560 Bootloader File in Atmel Studio

Click the Program button in the Device Programming dialog box to load the bootloader to the ATmega2560 AVR. Close the dialog box when done by clicking the Close button.

Programming the bootloader to the Arduino MEGA 2560Programming the Bootloader to the Arduino MEGA 2560

4. Test the Bootloader using Arduino IDE

After loading the bootloader to the Arduino MEGA 2560, test the Arduino to make sure that the correct bootloader was loaded and that the board works with the Arduino IDE USB programming.

If you broke the track between the two RESET-EN pads to use the board with the debugger, first solder the pads together before continuing.

Unplug the USB cable from the Arduino board to power it down and then unplug the programmer from the Arduino board ICSP header. After a few seconds, plug the Arduino MEGA 2560 board back into the PC using a USB cable.

Open the Arduino IDE and select the correct board and port under Tools → Board and Tools → Port. Also make sure that ATmega2560 is selected under Tools → Processor.

Open the Blink example sketch from the top menu under File → Examples → 01.Basics → Blink. Load the Blink sketch to the Arduino MEGA 2560 from the Arduino IDE using the Uploadbutton on the Arduino IDE toolbar.

Using the blink sketch to test that the Arduino MEGA 2560 bootloader is working

If everything is working, the Arduino IDE will compile and load the sketch and the L LED on the Arduino MEGA will blink on and off continually.

You can also add a Button in ATMEL Studio to USE AVRdude programming tool from Arduino Studio :

Tool ->External Tool-> Add NEW  (Title: Send to Arduino Mega)

Command: f:\SW\Electronica\Arduino\IDE\arduino-1.6.12\hardware\tools\avr\bin\avrdude.exe

Arguments: -C”f:\SW\Electronica\Arduino\IDE\arduino-1.6.12\hardware\tools\avr\etc\avrdude.conf” -v -patmega2560 -cwiring -PCOM5 -b115200 -D -Uflash:w:”$(ProjectDir)Debug\$(TargetName).hex”