I have need to change the USB descriptors of the Arduino Uno R3, for a project that will have it acting as a peripheral to another device.
This post documents how you can make from scratch the USB Serial firmware for ATmega16U2 on the Arduino Uno R3, using Atmel Studio 7 and its LUFA Library extension. It can be flashed quite easily using the built-in DFU firmware and Atmel’s FLIP tool. Source code is available at GitHub.
Install LUFA Library extension if not already installed (Tools -> Extensions and Updates…).
Source files that perform the actual USB/serial proxying are reused from USB to Serial Converter example project for at90usb1287 (File -> New -> Example Project…). Go ahead and create that project and grab the files. Some additions to the USB/serial code such as allowing a sketch to be uploaded from the Arduino IDE, have been taken from the official source code at GitHub.
Create a new project for the ATmega16U2 (File -> New -> Project…).
Use ASF Wizard (ASF -> ASF Wizard) to add LUFA modules and remove the Generic board support (driver) module.
Configure GCC symbols (Project -> Properties). Change BOARD to BOARD_UNO, and add F_CPU=16000000UL, and F_USB=16000000UL.
Resolve build errors by mostly eliminating code. Source code that builds without errors is available for comparison at GitHub. Program (Tools -> Device Programming) the firmware using the FLIP tool.
Reboot the Arduino.