Arduino Uno R3 as HID: Difference between revisions
No edit summary |
No edit summary |
||
| Line 11: | Line 11: | ||
== Install dfu-programmer == | == Install dfu-programmer == | ||
Download dfu-programmer from your distribution repos. For Ubuntu and Debian: | Download dfu-programmer from your distribution repos. For Ubuntu and Debian: | ||
sudo apt-get install dfu-programmer | sudo apt-get install dfu-programmer | ||
Once installed, check the version with | Once installed, check the version with | ||
dfu-programmer --version | dfu-programmer --version | ||
It has to be at least 0.6.1 for the following steps to work. If it's not, download the programmer directly from the authors: | It has to be at least 0.6.1 for the following steps to work. If it's not, download the programmer directly from the authors: | ||
| Line 32: | Line 32: | ||
Check if the programmer sees the 16U2: | Check if the programmer sees the 16U2: | ||
sudo dfu-programmer atmega16u2 dump | sudo dfu-programmer atmega16u2 dump | ||
You should get a gazillion of qustion marks on the terminal as a response. | You should get a gazillion of qustion marks on the terminal as a response. | ||
Erase the chip, upload firmware and reset: | Erase the chip, upload firmware and reset: | ||
sudo dfu-programmer atmega16u2 erase | sudo dfu-programmer atmega16u2 erase | ||
sudo dfu-programmer atmega16u2 flash Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex | sudo dfu-programmer atmega16u2 flash Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex | ||
sudo dfu-programmer atmega16u2 reset | sudo dfu-programmer atmega16u2 reset | ||
Unplug your Arduino and plug it back in. It should work as before. Try uploading a sketch from the Arduino environment to check. | Unplug your Arduino and plug it back in. It should work as before. Try uploading a sketch from the Arduino environment to check. | ||
Revision as of 10:14, 26 August 2014
Overview
To change your arduino into a usb HID device - for example a USB-keyboard - you will have to load a new firmware on the ATMEGA 16U2 chip on your Arduino board. That is the small square chip just behind the USB port on the board. This procedure is called DFU-programming or updating the firmware.
Updating the ATMEGA 16U2
First step is to reflash the ATMEGA 16U2 so we know that our setting is actually working. This instructions are based on some useful sites and forum hints on the web: - Updating the Atmega8U2 and 16U2 on an Uno or Mega2560 using DFU - Arduino-forum: Using Uno R3 on Linux? And some more hints in different forums I cannot recall already.
Install dfu-programmer
Download dfu-programmer from your distribution repos. For Ubuntu and Debian:
sudo apt-get install dfu-programmer
Once installed, check the version with
dfu-programmer --version
It has to be at least 0.6.1 for the following steps to work. If it's not, download the programmer directly from the authors: DFU-Programmer at GitHub
Reset 16U2
The Arduino Uno R3 (I'll call it just R3 from now on) comes with pin headers for the 16U2. To reset the chip, connect the two pins closest to the usb-port.
Flash ATMEGA 16U2
The following instructions are for linux OS's.
Download the latest firmware from GitHub. The file is called Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex at the time of writing. You will have to open the file on GitHub and download it as raw. Otherwise, the flashing will fail with the error message: "Error parsing the line."
Open a terminal and change to your download directory.
Check if the programmer sees the 16U2:
sudo dfu-programmer atmega16u2 dump
You should get a gazillion of qustion marks on the terminal as a response.
Erase the chip, upload firmware and reset:
sudo dfu-programmer atmega16u2 erase sudo dfu-programmer atmega16u2 flash Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex sudo dfu-programmer atmega16u2 reset
Unplug your Arduino and plug it back in. It should work as before. Try uploading a sketch from the Arduino environment to check.