Wednesday, September 11, 2013

DFU programming the atmega16u2 on the Arduino UNO R3

If you don't know what the title means, then probably you don't need this information :)

I wanted to have my own MIDI instrument, so I had to reprogram the atmega16u2 chip on my Arduino UNO R3 board. There is a somewhat outdated tutorial for that, but to completely do that, and easily I had to gather information from various blogs, forums, projects.
Though actually the process is very easy and fast, you can write a .bat file or shell script to change the firmware in seconds.

Programming with the dfu-programmer tool is very easy, for me seems easier than any other options. So these are the steps - written for Linux, but with some straightforward adjustments should apply to Windows as well - mainly the difference is that on Windows you need only the dfu-programmer package, no other installation/compiling needed - and to run dfu-programmer you don't need sudo.

Install necessary software
Download latest dfu-programmer (which knows about the atmega16u2 on the R3 Uno) from

On Linux you need to install some extra:
- sudo apt-get install libusb-1.0

On Windows you might get a 'libusb0.dll missing' error - in that case you need to install - from the zip file you can download, unzip bin/x86/libusb_x86.dll to the same folder as dfu-programmer.exe and rename the dll to libusb0.dll
Also, on Windows - after you put the Arduino into DFU mode - you need the USB drivers for the atmega16u2 - the best is to get it from atmel's Flip programmer, there you find an Atmel\Flip 3.4.7\usb folder - so go to Device Manager (in Windows Control Panel), select Install Software for your "Unknown Device" - then set this folder as driver source - it will be installed correctly.

Unzip the downloaded file. On Windows you can use it straight away. On Linux you need some extra steps (and might need to install gcc and others tools, see compiler messages.)

To unzip and install on Linux: 
- tar xzvf ~/Downloads/dfu-programmer….tar.gz
- cd into the unzipped directory
- run ./configure
- run make
- run sudo make install

Programming a new firmware consists of the following steps:
  1. Put the atmega16u2 chip into DFU mode
  2. Erase the atmega16u2 flash memory
  3. Upload the new content for the atmega16u2 flash memory
  4. Reset the atmega16u2
  5. Plug off and in the Arduino

Put Arduino into DFU mode
First connect the Arduino to the computer using the USB port.
To reprogram the atmega16u2, you must put the chip into DFU (Device Firmware Update) mode. 
On the Arduino R3 that's very easy: shortcut briefly the 2 leftmost ICSP headers next to the USB port. 

Led on pin 13 will flash. (Might not flash if the firmware installed doesn’t do that.)
running lsusb should now show 03eb:2fef Atmel Corp., that is the Arduino is no longer visible as Arduino.
At this point you have not changed anything on the board, if you want to abort the process, just plug off and in the board.

Put new firware
First erase: sudo dfu-programmer atmega16u2 erase
Then flash the new one: sudo dfu-programmer atmega16u2 flash MYFIRMWARE.hex
Reset the chip: sudo dfu-programmer atmega16u2 reset
pull out the usb cable then put it back

Put back old firmware
To put back the original firmware, you must locate it first in your arduino installation, it is Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
You must first erase the flash (see previous section), then flash the new one with one more special parameter:

sudo dfu-programmer atmega16u2 flash ~/prog/arduino-1.0.4/hardware/arduino/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex --suppress-bootloader-mem

Then reset the chip (see previous section) and replug the Arduino.

Running lsusb should now show Arduino SA Uno R3 (CDC ACM)


  1. You fix my arduino uno thanks very much !!!

  2. Im' not getting past part install udf program on win 8. It won't install.

  3. Its extremely instructive, intelligent and quality substance. I wish all of you good fortunes for your coming sites and posts. Continue sharing! . ivr telephony

  4. DRESSES,WOMEN DRESSES,MEN DRESSES, KIDS DRESSES,BRIDAL DRESSES,MAKEUP ,FASHION SHOW,HAIRSTYLES,JEWELLERY,attorney,claim,classy lakhany silk mills,lawn wear dresses,lsm fabrics,midsummer wear dresses designs,pajama wear dresses,stylish dresses,zainab chottani,zainab chottani collection,zainab chottani midsummer dresses,zainab chottani midsummer wear dresses,arabic mehndi designs,beautiful mehndi designs,bridal mehndi designs,dulhan mehndi legs,easy mehndi designs,indian mehndi designsPakistani,credit,degree,donate,dresses,hosting,insurance,lawyer,lehenga choli,loans,mortgage,salwar kameez,suits design

  5. This comment has been removed by the author.

  6. This worked very well even for this old newby. Thank youi

  7. great tutorial!!! i bought an arduino board from Arduino Uno R3 and i want to learn and use about it. please help me its basic use and tutorial sites about Arduino Uno R3