=========================
LUFA (Lightweight USB For AVRs) on the Arduino!
Modern Arduinos (Arduino Leonardo, Arduino Micro, Arduino Esplora, Arduino Lilypad USB, and the Upcoming Arduino Tre) came with a ATmega32u4 which have a native USB interface on the MCU. The Arduino IDE also came with a tiny USB stack that has a USB CDC Serial, a Keyboard, and a Mouse. It might be enough if you're migrating old projects (form ATmega168/328's) to the new hardware, but when you want to unleash the full power of it, you'd find that the current implementations lasks extensibility (BADLY!).
Thus, I managed to bring the powerful LUFA to Arduino!
For the automatic installation, you need to have both git and Python 3.3 (or later) installed. These instructions work on both Linux and Windows. Alternatively, there are instructions for manual installation.
-
Close all open Arduino IDE windows!
-
Navigate into your Arduino IDE's
libraries
folder. Replace<arduino_install_path>
with the install path of the Arduino IDE.$ cd <arduino_install_path>/libraries
-
Clone both Arduino-Lufa and the LUFA submodule:
$ git clone --recursive https://github.com/Palatis/Arduino-Lufa.git LUFA
-
Activate LUFA (more on this below)
$ ./LUFA/activate.py
-
Done! Proceed with the steps below to try out Arduino-Lufa
To test Arduino-Lufa, open the LUFA_DualVirtualSerial example and click Verify. (See Note on Upload below)
To use Arduino-Lufa, include it as a library in your sketch:
By uploading this sketch to the board, you will prevent the Arduino IDE from automatically reset the board before uploading another sketch. This is normally done by setting up a seial connection with 1200 baud, connecting, then disconnecting.
You can, however, manually reset the board by pressing the hardware reset button when the upload starts. To better see this, enable "Show verbose output during upload" in your preferences and wait until the IDE repatedly prompts something like this:
PORTS {COM1, COM5, COM6, } / {COM1, COM5, COM6, } => {}
If done correctly, the LED on pin 13 will begin flashing and you'll see the upload progressing in the console.
This is not permanent, however. To go back to the original state, upload a sketch compiled without Arduino-Lufa, as explained below.
If you need to compile sketches that use the Arduino Core USB Stack, you'll have to deactivate LUFA like so:
$ ./<arduino_install_path>/libraries/LUFA/deactivate.py
If you work with a lot of different boards and find switching tedious, it is recommended to copy your Arduino IDE into a new directory called something like Arduino-LUFA
, and activiting LUFA only in that installation. To avoid confusion, you can then also delete libraries/LUFA
from the original install, but make sure to run deactivate.py
first!
- Victor Tseng: palatis AT gmail DOT com (Original Author)
- Daniel Korgel (Contributor)
- Felix Uhl (Contributor)
- Arduino: http://arduino.cc
- LUFA: http://www.fourwalledcubicle.com/LUFA.php
The MIT License (MIT)
Copyright (c) 2014, Victor Tseng
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.