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-serial-lufa.png

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

lufa-install

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

usb-serial-project.png

usb-serial-project-board.png

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

usb-serial-asf-wizard.png

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

usb-serial-symbols.png

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

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

usb-serial-flip

Reboot the Arduino.

Advertisements

One thought on “Arduino USB Serial firmware from scratch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s