View on GitHub

Devendra's Log

Arduino USB Serial firmware from scratch

I have need to change the USB descriptors of an Arduino Uno R3 acting as a peripheral to another device. This post describes how I built a USB Serial firmware for the ATmega16U2 on an Arduino Uno R3, using Atmel Studio 7 and its LUFA Library extension. It can be flashed using the built-in DFU firmware and Atmel’s FLIP tool.

Source files that perform the actual USB/serial proxying are derived from USB to Serial Converter example project for the at90usb1287 (File -> New -> Example Project…). I suggest creating a project based on that example and copying the files over. I have also borrowed code from the official source code at GitHub to enable additional functionality such as allowing a sketch to be uploaded from the Arduino IDE.

USB to Serial Converter Example Project

Install LUFA Library extension if not already installed (Tools -> Extensions and Updates…)

Install LUFA Extension

Create a new project for the ATmega16U2 (File -> New -> Project…)

New Atmel Studio Board Project

Board Selection

Use ASF Wizard (ASF -> ASF Wizard) to add LUFA modules and remove the Generic board support (driver) module.

ASF Wizard

Configure GCC symbols (Project -> Properties). Change BOARD to BOARD_UNO, and add F_CPU=16000000UL and F_USB=16000000UL.

GCC symbols

Copy over source files from the example project mentioned earlier. Resolve any build errors.

Flash (Tools -> Device Programming) the firmware using the FLIP tool

Flash using FLIP

Reboot the Arduino.