Difference between revisions of "Arduino: Restore Arduino UNO bootloader using avr dragon"

From Luky-Wiki
Jump to: navigation, search
(Step 1)
Line 1: Line 1:
 
If you "play" a lot with Arduino UNO then you may end up with locked up device or broken boot loader. There is way out of this problem but you will need additional device. I am using avr dragon for ISP programming and following commands can be used to restore Arduino UNO boot loader.
 
If you "play" a lot with Arduino UNO then you may end up with locked up device or broken boot loader. There is way out of this problem but you will need additional device. I am using avr dragon for ISP programming and following commands can be used to restore Arduino UNO boot loader.
  
''Note:'' This work also for other Atmel based devices but configuration needs to be modified accordingly.
+
Arduino UNO use optiboot and recent version can be found at [https://github.com/Optiboot/optiboot github]. Download  <code>optiboot_atmega328.hex</code> before continuing.
  
 
==== Step 1 ====
 
==== Step 1 ====
Download <code>optiboot_atmega328.hex</code> from [https://github.com/Optiboot/optiboot optiboot at github].
+
Erase flash (to start with clean device).
 +
<pre>avrdude -p m328p -c dragon_isp -P usb -e</pre>
  
 
==== Step 2 ====
 
==== Step 2 ====
Erase chip:
+
Configure fuse and lock bits (to be sure that boot loader will work as expected).
<pre>sudo avrdude -p m328p -c dragon_isp -P usb -e</pre>
+
<pre>sudo avrdude -p m328p -c dragon_isp -P usb   -u -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m -U lock:w:0x3f:m</pre>
  
 
==== Step 3 ====
 
==== Step 3 ====
Configure fuse and lock bits:
+
Burn boot loader.
<pre>sudo avrdude -p m328p -c dragon_isp -P usb    -u -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m -U lock:w:0x3f:m</pre>
+
<pre>avrdude -p m328p -c dragon_isp -P usb -e   -U flash:w:optiboot_atmega328.hex                    -U lock:w:0x3f:m</pre>
  
==== Step 1 ====
+
'''Note 1:''' this will work also with other Atmel devices. Just adapt configuration and retrieve correct file from optiboot repository at github.
sudo avrdude -p m328p -c dragon_isp -P usb -e    -U flash:w:optiboot_atmega328.hex                    -U lock:w:0x3f:m
 
  
==== Step 1 ====
+
'''Note 2:''' LED will blink periodically on Arduino UNO once all steps are done. It is because boot loader will try to start application . Because app code is missing Atmel mCPU start boot loader again.
==== Step 1 ====
 
==== Step 1 ====
 

Revision as of 21:51, 13 February 2016

If you "play" a lot with Arduino UNO then you may end up with locked up device or broken boot loader. There is way out of this problem but you will need additional device. I am using avr dragon for ISP programming and following commands can be used to restore Arduino UNO boot loader.

Arduino UNO use optiboot and recent version can be found at github. Download optiboot_atmega328.hex before continuing.

Step 1

Erase flash (to start with clean device).

avrdude -p m328p -c dragon_isp -P usb -e

Step 2

Configure fuse and lock bits (to be sure that boot loader will work as expected).

sudo avrdude -p m328p -c dragon_isp -P usb    -u -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m -U lock:w:0x3f:m

Step 3

Burn boot loader.

avrdude -p m328p -c dragon_isp -P usb -e    -U flash:w:optiboot_atmega328.hex                     -U lock:w:0x3f:m

Note 1: this will work also with other Atmel devices. Just adapt configuration and retrieve correct file from optiboot repository at github.

Note 2: LED will blink periodically on Arduino UNO once all steps are done. It is because boot loader will try to start application . Because app code is missing Atmel mCPU start boot loader again.