A blog by Devendra Tewari
The Device Firmware Upgrade (DFU) firmware for the ATmega16U2 on Arduino Uno R3 is used to flash the USB Serial firmware, among others, using Atmel’s FLIP tool.
This post documents how you can build from scratch DFU firmware using Atmel Studio 7 and its LUFA Library extension. You’ll need an ISP/ICSP programmer to program the ATmega16U2.
You can install the LUFA extension from the Extensions and Updates dialog (Tools -> Extensions and Updates).
Create a new project based on the DFU Bootloader example (File -> New -> Example Project…).
Change the compiler optimization setting to -Os in toolchain properties (Project -> Properties).
Build the solution and flash (Tools -> Device Programming) using an ISP/ICSP programmer connected to the ICSP2 header.