Why am I getting these couple of errors?

405 views
Skip to first unread message

Joseph Orbegoso Pea

unread,
Jun 18, 2014, 8:46:40 PM6/18/14
to lufa-s...@googlegroups.com
Hello LUFA users! I'm new here (this is my first time ever trying to program something other than a PC or smart phone). :)

I'm trying to set up a LUFA project to make convert an Arduino Uno R3 into a USB device (e.g. a "keyboard"). I'm in Arch Linux.

I'm trying to 'make' the project and it says things like:
 
./LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h:84:5: error: #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
 
Descriptors.h:43:40: fatal error: LUFA/Drivers/USB/Class/HID.h: No such file or directory
 #include <LUFA/Drivers/USB/Class/HID.h>
                                        ^
F_USB is in fact defined in my makefile. I was following this tutorial on turning an Arduino into a keyboard, and I'm trying to compile the project myself to learn how to generate the hex images on my own, but no luck yet. The direct download to the project source code is here: http://hunt.net.nz/users/darran/weblog/b3029/attachments/bd341/arduino-keyboard-0.3.tar.gz

I downloaded it, but it doesn't come with the LUFA library, so I grabbed the LUFA lib from github, then I made a symlink to it in the project folder

ln -s ~/path/to/lufa/LUFA ~/path/to/arduino-keyboard-0.3/LUFA

so that the library is available to the project (e.g. Descriptors.h looks for the LUFA folder in the same folder that it's in).

Then I modified a couple of things in the makefile. It complained about ARCH not being defined, so I added ARCH = AVR8 and that solved that problem. Then it started complaining about F_USB not being defined, but adding F_USB = $(F_CPU) to the makefile doesn't fix the error. That's where I'm stuck.

My makefile looks like this: http://hastebin.com/oqasizical.makefile
See lines 65, 71, and 115.

Why does it say that F_USB isn't defined? Also, where's HID.h? Was that part of LUFA before? Or do I need to get that from somewhere?

Joseph Orbegoso Pea

unread,
Jun 20, 2014, 1:51:59 PM6/20/14
to lufa-s...@googlegroups.com
EDIT: I haven't seen the old LUFA, but I'm guessing perhaps HID.h got merged with USB.h in newer versions? I've got a lot of learning to do. xD

Nevada Smith

unread,
Jun 21, 2014, 6:40:24 PM6/21/14
to lufa-s...@googlegroups.com
Hi Joseph!
Are you trying to change the official Arduino Firmware? They used an old version of Lufa, that wont work with the newest.

And i think i exactly did what you are trying to do. Feel free to test it and tell me what you think or what could be done better. I just released a new update.
https://github.com/NicoHood/HID

Nico

Joseph Orbegoso Pea

unread,
Jun 23, 2014, 8:30:34 PM6/23/14
to lufa-s...@googlegroups.com
Hi Nevada,

Yeah, I'm using dfu-programmer like in the tutorial I linked. I touch the two pins, flash to the Arduino official firmware with dfu-programmer, power cycle, upload my keyboard script in Arduino IDE, touch the two pins, flash the keyboard firmware with dfu-programmer, then power cycle.

I want to learn how to imitate any USB device with LUFA. For example, I'd like to learn how to imitate a USB flash drive. So what I'm wanting to learn is how to compile my own firmware hex file like the one used in the tutorial. I thought I'd start by using their example, but it doesn't work with recent LUFA.

I guess I need to learn LUFA basics first, then I can modify the old code from the tutorial to work with the new LUFA. That's what I really want to do. :D

Joseph Orbegoso Pea

unread,
Jun 26, 2014, 8:13:32 PM6/26/14
to lufa-s...@googlegroups.com
In case anyone stumbles on this thread searching for answers, my solution was to just get the latest LUFA source, then compile the latest Keyboard demo in the Demos folder. Before you can compile it, you'll have to create a Board folder in the demo project's root folder, and inside there you need to create two files: Buttons.h and Joystick.h. Use the example code template files (also in the LUFA source tree) to learn how to write the Buttons.h and Joystick.h files. I am not using the buttons or any type of joystick input with the Arduino UNO, so I simply defined the values in those files with random numbers. Basically, before you can compile any of the demos for a specific board, you must create the driver files (.h files) that define how your board handles specific things like buttons and LEDs, etc.

Two good places to get more help at are the LUFA forums and avrfreaks forums.


On Wednesday, June 18, 2014 5:46:40 PM UTC-7, Joseph Orbegoso Pea wrote:

Nevada Smith

unread,
Jul 1, 2014, 12:10:26 PM7/1/14
to lufa-s...@googlegroups.com
Keep in mind that the 16u2 has a 500byte ram limit which is very critical for some usb devices. And for the HID thing... just use my work :P

Or you could download my Hoodloader and try to modify it. This should compile without errors. The lufa examples dont always run out of the box.
Reply all
Reply to author
Forward
0 new messages