Getting started with AVR-USB
Getting started with AVR-USB
Hi,
I am currently doing a project where I need to send and receive information from a computer to a microcontroller.
I have read through examples and read the corresponding information. I am however getting unstuck when it comes to the computer side. I understand I need the libusb, but do I need to install this onto the computer that will use the program I write or do I just need these files when compiling my code?
I am using windows xp and am real trouble getting started testing some of the example projects. I am trying to use Visual studio c++, as this is the environment I am most comfortable with and am also using avr studio 4, using a c project.
Can some one please help me out and tell me eactly what files I need where when it comes to comiling my code into exe/hex
Thanks
Sam
I am currently doing a project where I need to send and receive information from a computer to a microcontroller.
I have read through examples and read the corresponding information. I am however getting unstuck when it comes to the computer side. I understand I need the libusb, but do I need to install this onto the computer that will use the program I write or do I just need these files when compiling my code?
I am using windows xp and am real trouble getting started testing some of the example projects. I am trying to use Visual studio c++, as this is the environment I am most comfortable with and am also using avr studio 4, using a c project.
Can some one please help me out and tell me eactly what files I need where when it comes to comiling my code into exe/hex
Thanks
Sam
To compile AVR firmware you'll also need WinAVR. As for how to use libusb, check out the AVRUSBBoot project.
You need libusb only if you create a custom class device. If you rely on libusb, you need the runtime library on every machine where the device is connected. And it must be properly installed. You need to read through the docs of libusb to manage all this.
If you base your design on a HID class device, you can get away without libusb. However, if you use VC, you need Microsoft's DDK. If you use minGW (which is free), the DDK is included. See the Automator project to see an example.
If you base your design on a HID class device, you can get away without libusb. However, if you use VC, you need Microsoft's DDK. If you use minGW (which is free), the DDK is included. See the Automator project to see an example.
Compiling the Automator
Hi,
I am a member of the project group working with Sam. I have managed to compile the firmware, however the i cannot get the Automator to compile. The steps i've taken are as follows:
-Installed: WinAVR, MinGW, MSYS (in that order)
-Built the fltk library's (configure, make and make install in MSYS)
-Downloaded the libusb win32 device bin and copied the files into the MinGW include and lib directories (usb.h and libusb.a) as described in the avrusbboot project readme
The instructions for the automator suggest that the next step should be as simple as running the make file in the application directory, after commenting out the 3 lines and un-commenting the windows lines. However this does not work for me, i'm getting endless errors in the MSYS windows the current is:
usbcalls.o(.text+0x50):usbcalls.c: undefined reference to HidD_GetHidGuid@4'
plus a few more lines all relating to the HidD_.......... from the Hidsdi.h file
from playing around a bit ive got the impression that solving this problem will just reveal more.
Can anyone point out any problems with what i've done thus far? im using windows XP and have uninstalled Visual studios
Im just trying to get the automator to compile so i can then make the mods required for our project to the code. As i have aquired the gui.h and gui.c files from the fluid part of the make file would it be a better idea to try and compile it with visual studios? what DDK files would i need to achieve this?
Many Thanks
Rich
I am a member of the project group working with Sam. I have managed to compile the firmware, however the i cannot get the Automator to compile. The steps i've taken are as follows:
-Installed: WinAVR, MinGW, MSYS (in that order)
-Built the fltk library's (configure, make and make install in MSYS)
-Downloaded the libusb win32 device bin and copied the files into the MinGW include and lib directories (usb.h and libusb.a) as described in the avrusbboot project readme
The instructions for the automator suggest that the next step should be as simple as running the make file in the application directory, after commenting out the 3 lines and un-commenting the windows lines. However this does not work for me, i'm getting endless errors in the MSYS windows the current is:
usbcalls.o(.text+0x50):usbcalls.c: undefined reference to HidD_GetHidGuid@4'
plus a few more lines all relating to the HidD_.......... from the Hidsdi.h file
from playing around a bit ive got the impression that solving this problem will just reveal more.
Can anyone point out any problems with what i've done thus far? im using windows XP and have uninstalled Visual studios
Im just trying to get the automator to compile so i can then make the mods required for our project to the code. As i have aquired the gui.h and gui.c files from the fluid part of the make file would it be a better idea to try and compile it with visual studios? what DDK files would i need to achieve this?
Many Thanks
Rich
You don't need libusb for this project, but it should not harm either.
The undefined symbol means that you are not linking one of the required libraries or that the libraries are not in the appropriate order. In my version of MinGW, HidD_GetHidGuid is contained in libhid.a. This file is at mingw/i386-mingw32msvc/lib on my computer.
There are only a few HID calls, so I expect no more problems once you have this part settled.
The undefined symbol means that you are not linking one of the required libraries or that the libraries are not in the appropriate order. In my version of MinGW, HidD_GetHidGuid is contained in libhid.a. This file is at mingw/i386-mingw32msvc/lib on my computer.
There are only a few HID calls, so I expect no more problems once you have this part settled.
"mingw" is the directory where minGW is installed on my machine.
I'm afraid you can't expect ANY makefile to work "out of the box" these days because software versions change so fast and nobody has the time to test with all versions currently in use.
Can you please post (or mail me, throug the support form) the following information:
- the Makefile you use
- the exact output of "make" after a "make clean"
Maybe the real cause is somewhere else.
I'm afraid you can't expect ANY makefile to work "out of the box" these days because software versions change so fast and nobody has the time to test with all versions currently in use.
Can you please post (or mail me, throug the support form) the following information:
- the Makefile you use
- the exact output of "make" after a "make clean"
Maybe the real cause is somewhere else.
# Name: Makefile
# Project: Automator
# Author: Christian Starkjohann
# Creation Date: 2006-02-01
# Tabsize: 4
# Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
# License: Proprietary, free under certain conditions. See Documentation.
# This Revision: $Id: Makefile 126 2006-02-12 14:45:15Z cs $
# Please read the definitions below and edit them as appropriate for your
# system:
# Use the following 3 lines on Unix and Mac OS X:
#USBFLAGS= `libusb-config --cflags`
#USBLIBS= `libusb-config --libs`
#EXE_SUFFIX=
# Use the following 3 lines on Windows and comment out the 3 above:
USBFLAGS=
USBLIBS= -lhid -lusb -lsetupapi
EXE_SUFFIX= .exe
CC= gcc
CXX= g++
CFLAGS= -O2 -Wall $(USBFLAGS)
CXXFLAGS= -O2 -Wall `fltk-config --cxxflags`
LIBS= `fltk-config --ldstaticflags` $(USBLIBS)
ARCH_COMPILE=
ARCH_LINK=
OBJ= automator.o gui.o parser.o usbcalls.o
PROGRAM= Automator$(EXE_SUFFIX)
all: $(PROGRAM)
$(PROGRAM): $(OBJ)
$(CXX) $(ARCH_LINK) $(CXXFLAGS) -o $(PROGRAM) $(OBJ) $(LIBS)
fltk-config --post $(PROGRAM)
automator.o: automator.cpp gui.h
gui.cpp gui.h: gui.fl
fluid -c gui.fl
strip: $(PROGRAM)
strip $(PROGRAM)
clean:
rm -f gui.cpp gui.h $(OBJ) $(PROGRAM)
.c.o:
$(CC) $(ARCH_COMPILE) $(CFLAGS) -c $*.c -o $*.o
.cpp.o:
$(CXX) $(ARCH_COMPILE) $(CXXFLAGS) -c $*.cpp -o $*.o
# Project: Automator
# Author: Christian Starkjohann
# Creation Date: 2006-02-01
# Tabsize: 4
# Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
# License: Proprietary, free under certain conditions. See Documentation.
# This Revision: $Id: Makefile 126 2006-02-12 14:45:15Z cs $
# Please read the definitions below and edit them as appropriate for your
# system:
# Use the following 3 lines on Unix and Mac OS X:
#USBFLAGS= `libusb-config --cflags`
#USBLIBS= `libusb-config --libs`
#EXE_SUFFIX=
# Use the following 3 lines on Windows and comment out the 3 above:
USBFLAGS=
USBLIBS= -lhid -lusb -lsetupapi
EXE_SUFFIX= .exe
CC= gcc
CXX= g++
CFLAGS= -O2 -Wall $(USBFLAGS)
CXXFLAGS= -O2 -Wall `fltk-config --cxxflags`
LIBS= `fltk-config --ldstaticflags` $(USBLIBS)
ARCH_COMPILE=
ARCH_LINK=
OBJ= automator.o gui.o parser.o usbcalls.o
PROGRAM= Automator$(EXE_SUFFIX)
all: $(PROGRAM)
$(PROGRAM): $(OBJ)
$(CXX) $(ARCH_LINK) $(CXXFLAGS) -o $(PROGRAM) $(OBJ) $(LIBS)
fltk-config --post $(PROGRAM)
automator.o: automator.cpp gui.h
gui.cpp gui.h: gui.fl
fluid -c gui.fl
strip: $(PROGRAM)
strip $(PROGRAM)
clean:
rm -f gui.cpp gui.h $(OBJ) $(PROGRAM)
.c.o:
$(CC) $(ARCH_COMPILE) $(CFLAGS) -c $*.c -o $*.o
.cpp.o:
$(CXX) $(ARCH_COMPILE) $(CXXFLAGS) -c $*.cpp -o $*.o
That must have been a misunderstanding. I meant that you should do a "make clean" and then type "make" in the command line. The interesting part is the output of this second command, the "make" without parameters. This is where the errors are printed, after all. I only asked for the "make clean" to be sure that all modules are built and thus all warnings printed.
$ make clean
then
$ make
g++ -O2 -Wall `fltk-config --cxxflags` -c automator.cpp -o automator.o
automator.cpp: In function `void mainSaveToFile()':
automator.cpp:150: warning: `fl_ask' is deprecated (declared at
C:/1.0/local/include/FL/fl_ask.H:59)
g++ -O2 -Wall `fltk-config --cxxflags` -c gui.cpp -o gui.o
gcc -O2 -Wall -c parser.c -o parser.o
gcc -O2 -Wall -c usbcalls.c -o usbcalls.o
g++ -O2 -Wall `fltk-config --cxxflags` -o Automator.exe automator.o gui.o parse r.o usbcalls.o `fltk-config --ldstaticflags` -lhid -lusb -lsetupapi
usbcalls.o(.text+0x50):usbcalls.c: undefined reference to `HidD_GetHidGuid@4'
usbcalls.o(.text+0x149):usbcalls.c: undefined reference to `HidD_GetAttributes@8 '
usbcalls.o(.text+0x1ad):usbcalls.c: undefined reference to `HidD_GetManufacturer String@12'
usbcalls.o(.text+0x1fd):usbcalls.c: undefined reference to `HidD_GetProductStrin g@12'
usbcalls.o(.text+0x2de):usbcalls.c: undefined reference to `HidD_SetFeature@12'
usbcalls.o(.text+0x36e):usbcalls.c: undefined reference to `HidD_GetFeature@12'
make: *** [Automator.exe] Error 1
then
$ make
g++ -O2 -Wall `fltk-config --cxxflags` -c automator.cpp -o automator.o
automator.cpp: In function `void mainSaveToFile()':
automator.cpp:150: warning: `fl_ask' is deprecated (declared at
C:/1.0/local/include/FL/fl_ask.H:59)
g++ -O2 -Wall `fltk-config --cxxflags` -c gui.cpp -o gui.o
gcc -O2 -Wall -c parser.c -o parser.o
gcc -O2 -Wall -c usbcalls.c -o usbcalls.o
g++ -O2 -Wall `fltk-config --cxxflags` -o Automator.exe automator.o gui.o parse r.o usbcalls.o `fltk-config --ldstaticflags` -lhid -lusb -lsetupapi
usbcalls.o(.text+0x50):usbcalls.c: undefined reference to `HidD_GetHidGuid@4'
usbcalls.o(.text+0x149):usbcalls.c: undefined reference to `HidD_GetAttributes@8 '
usbcalls.o(.text+0x1ad):usbcalls.c: undefined reference to `HidD_GetManufacturer String@12'
usbcalls.o(.text+0x1fd):usbcalls.c: undefined reference to `HidD_GetProductStrin g@12'
usbcalls.o(.text+0x2de):usbcalls.c: undefined reference to `HidD_SetFeature@12'
usbcalls.o(.text+0x36e):usbcalls.c: undefined reference to `HidD_GetFeature@12'
make: *** [Automator.exe] Error 1
OK. This may be a mismatch in the declaration of the HID functions.
We have a bit of a hack with these declarations since a header file was missing with my version of MinGW. Your MinGW may have this header and you should use it if it's there.
The header file is "hidsdi.h". Simply rename the file in the project to "hidsdi.h.disabled" and try to build (make clean; make). The library may require the right version of this header file.
We have a bit of a hack with these declarations since a header file was missing with my version of MinGW. Your MinGW may have this header and you should use it if it's there.
The header file is "hidsdi.h". Simply rename the file in the project to "hidsdi.h.disabled" and try to build (make clean; make). The library may require the right version of this header file.