LUFA and the Arduino Leonardo
Just a quick update, because I know I’m going to get email on this otherwise. If you’re looking to use LUFA on the Arduino Leonardo board, here’s what you have to do.
Firstly, you need the current trunk version of LUFA – not the latest release. Not only does the latest trunk have board hardware definitions that the current release lacks, but it also contains a (preliminary) compatibility fix to the core to make it work with the Leonardo bootloader. Special thanks to Simon Inns for both his debugging help and the donation of an Arduino Leonardo board so that I can continue my development efforts with it. You can download the latest LUFA trunk here.
Secondly (Windows only), you’ll need to have downloaded the Arduino 1.0 IDE from the Arduino website. You’ll need this for two reasons; firstly, you’ll need the driver INF file it contains in the arduino-1.0\drivers directory, and secondly, you’ll need the Windows build of the AVRDUDE application that it includes in the arduino-1.0\hardware\tools\avr\bin. You need to add the latter to your system PATH variable so that you can run it from any folder from the command line. You can download the Arduino 1.0 IDE from here.
Thirdly, you’ll need to alter the project makefile that you want to compile. The relevant makefile magic here is:
MCU = atmega32u4 # Change this BOARD = LEONARDO # And this F_CPU = 16000000 # And finally this AVRDUDE_PROGRAMMER = avr109 # Add this AVRDUDE_PORT = COM32 # And this too (use your correct COM port)
Those are the only lines that need to be changed from the standard LUFA makefile template. Note that on my system the bootloader appears as COM32, but on your system this will no doubt be different, so alter the AVRDUDE_PORT line to suit your own environment. If you use Linux, this line will most likely be /dev/ttyACM0 or another similarly named virtual USB TTY device.
That’s it – with the small changes to the project makefiles, you can then download a new application by pressing the reset button on the board, and running make avrdude from the command line shortly afterwards (while the L LED is still fading in an out to signal the bootloader is running).