Restoring Arduino Uno Bootloader
25 January 2016
After programming an Arduino Uno 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 Uno 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 Uno Bootloader File
Locate the bootloader hexadecimal or hex file for the Arduino Uno 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 optiboot_atmega328.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\optiboot\ 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.
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 Uno, 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.
In the Device Programming dialog box, select the Tool (AVRISP mkII or AVR Dragon), Device (ATmega328P) and Interface (ISP) then 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.
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.
Navigate to and select the hexadecimal bootloader file called optiboot_atmega328.hex found in the Arduino IDE software sub-folder hardware\arduino\avr\bootloaders\optiboot\. Click the file in the dialog box and then click the Open button as shown in the image below.
Click the Program button in the Device Programming dialog box to load the bootloader to the ATmega328P AVR. Close the dialog box when done by clicking the Close button.
If programming the bootloader to a new ATmega328P microcontroller, the fuses must be set to the correct values. This is not necessary if the microcontroller was previously working with the bootloader.
To program the fuses, click Fuses in the left pane of the Device Programming dialog box. Set the values for the EXTENDED (0xFD), HIGH (0xDE) and LOW (0xFF) fuses near the bottom of the dialog box as shown in the image below. Click the Program button to program the fuses.
4. Test the Bootloader using Arduino IDE
After loading the bootloader to the Arduino Uno, 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 Uno 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.
Open the Blink example sketch from the top menu under File → Examples → 01.Basics → Blink. Load the Blink sketch to the Arduino Uno from the Arduino IDE using the Upload button on the Arduino IDE toolbar.
If everything is working, the Arduino IDE will compile and load the sketch and the L LED on the Arduino Uno will blink on and off continually.