Problem to compile a program with V-USB library [SOLVED]

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Luca89
Posts: 2
Joined: Wed Aug 01, 2012 12:24 pm

Problem to compile a program with V-USB library [SOLVED]

Post by Luca89 » Wed Aug 01, 2012 12:53 pm

Hi,
i tried to compile a simple program that i found at this link: http://codeandlife.com/2012/01/29/avr-a ... al-part-3/ using the v-usb library
This is the code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include "usbdrv.h"

#include <util/delay.h>

USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
return 0; // do nothing for now
}


int main() {
uchar i;

wdt_enable(WDTO_1S); // enable 1s watchdog timer

usbInit();

usbDeviceDisconnect(); // enforce re-enumeration
for(i = 0; i<250; i++) { // wait 500 ms
wdt_reset(); // keep the watchdog happy
_delay_ms(2);
}
usbDeviceConnect();

sei(); // Enable interrupts after re-enumeration

while(1) {
wdt_reset(); // keep the watchdog happy
usbPoll();
}

return 0;
}

I use Arduino and i red here http://balau82.wordpress.com/2011/03/29 ... in-pure-c/ how program my Arduino board with avr-gcc.
So i wrote in my terminal:

avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o prova.o prova.c

and it's work, but when i wrote

avr-gcc -mmcu=atmega328p prova.o -o prova

i receive this error messages:

prova.o: In function `main':
prova.c:(.text+0x1a): undefined reference to `usbInit'
prova.c:(.text+0x3a): undefined reference to `usbPoll'

i think this could be a linker problem.
Can someone help me please?
Thank you and i apologize for my bad English.
Last edited by Luca89 on Fri Aug 03, 2012 10:41 am, edited 1 time in total.

horo
Rank 2
Rank 2
Posts: 63
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: Problem to compile a simple program with V-USB library

Post by horo » Thu Aug 02, 2012 3:27 pm

Hi Luca,

Code: Select all

prova.o: In function `main':
prova.c:(.text+0x1a): undefined reference to `usbInit'
prova.c:(.text+0x3a): undefined reference to `usbPoll'


you also need the V-USB part linked to your program. The best way to do this is the use of a makefile - look into a sample V-USB project.

Ciao, Martin

Luca89
Posts: 2
Joined: Wed Aug 01, 2012 12:24 pm

Re: Problem to compile a simple program with V-USB library

Post by Luca89 » Fri Aug 03, 2012 10:40 am

Thank you very much Martin.
I followed your advice and now it's work.

tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by tytower » Tue Sep 18, 2012 12:10 am

So how come V-USB does not come with a makefile?
Running make usbdrv.c
gives

Code: Select all

#avr-gcc usbdrv.c
In file included from usbportability.h:121:0,
                 from usbdrv.c:11:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/io.h:364:6: warning: #warning "device type not defined"
usbdrv.c: In function 'usbPoll':
usbdrv.c:595:1: error: 'PIND' undeclared (first use in this function)
usbdrv.c:595:1: note: each undeclared identifier is reported only once for each function it appears in
usbdrv.c: In function 'usbInit':
usbdrv.c:613:5: error: 'MCUCR' undeclared (first use in this function)
usbdrv.c:613:21: error: 'ISC01' undeclared (first use in this function)
usbdrv.c:618:5: error: 'GICR' undeclared (first use in this function)
usbdrv.c:618:30: error: 'INT0' undeclared (first use in this function)
 

Coda
Posts: 18
Joined: Thu Apr 26, 2012 10:56 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by Coda » Wed Sep 19, 2012 9:38 am

tytower wrote:So how come V-USB does not come with a makefile?

You're right it doesn't. It comes with 8 of them:

$ find . -name Makefile
./vusb-20120109/examples/custom-class/commandline/Makefile
./vusb-20120109/examples/custom-class/firmware/Makefile
./vusb-20120109/examples/hid-custom-rq/commandline/Makefile
./vusb-20120109/examples/hid-custom-rq/firmware/Makefile
./vusb-20120109/examples/hid-data/commandline/Makefile
./vusb-20120109/examples/hid-data/firmware/Makefile
./vusb-20120109/examples/hid-mouse/firmware/Makefile
./vusb-20120109/examples/usbtool/Makefile
./vusb-20120109/tests/Makefile

The original poster is coming from Arduino land and probably didn't understand the concept of Makefiles.

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by ulao » Thu Sep 20, 2012 4:09 am

This is exactly why I tell everyone not to start off on the silly Arduino boards. Learn the right way first ;)

Ok make file 101.

go to project->config settings
in the general section check use external makefile, brows to it.
Make sure your makefile is configured, there are hundreds of info's out there. There is also a mfile program that will configure it for you.

tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by tytower » Thu Sep 20, 2012 9:14 am

Coda wrote:
tytower wrote:So how come V-USB does not come with a makefile?

You're right it doesn't. It comes with 8 of them:

$ find . -name Makefile
./vusb-20120109/examples/custom-class/commandline/Makefile
./vusb-20120109/examples/custom-class/firmware/Makefile
./vusb-20120109/examples/hid-custom-rq/commandline/Makefile
./vusb-20120109/examples/hid-custom-rq/firmware/Makefile
./vusb-20120109/examples/hid-data/commandline/Makefile
./vusb-20120109/examples/hid-data/firmware/Makefile
./vusb-20120109/examples/hid-mouse/firmware/Makefile
./vusb-20120109/examples/usbtool/Makefile
./vusb-20120109/tests/Makefile

The original poster is coming from Arduino land and probably didn't understand the concept of Makefiles.


Well thats a pretty cheeky ,rude,assunptive and completely wrong post.
These are all makefiles for the tools and specific devices it comes with or so the blurb says?.
There is no makefile for the basic driver as far as I can see so why not just supply one?
Why the crap?
The previous poster and the answers given indicate that he needed a Makefile so obviously there is not a Makefile supplied for the basic driver if he had to make up one himself

Your assertion that I know not Makefiles is just stupid . In fact I use Linux and am compiling and using software weekly and have been doing so for 30 years Sonny. What you may not understand is that most software comes with a ./configure file and a makefile . Thats the STANDARD !
V-USB does not
Last edited by tytower on Thu Sep 20, 2012 9:35 am, edited 1 time in total.

tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by tytower » Thu Sep 20, 2012 9:20 am

ulao wrote:This is exactly why I tell everyone not to start off on the silly Arduino boards. Learn the right way first ;)

Ok make file 101.

go to project->config settings I dont have a project or run an editor which uses a project file s there is no configure file except for that created in usbdrv directory
in the general section check use external makefile, brows to it.
Make sure your makefile is configured, there are hundreds of info's out thereExactly what and where do you refer to?. There is also a mfile program that will configure it for you,Can you point to a site for this and save all the bullshit?.

Silly might be your interpretation and welcome to it you are !
Personally I see that Arduino is bringing in a multitude of users who otherwise would not have even tried because wherever you go you find confusion and complication when dealing with microprocessor programming.

Personally I go back to starting to study and program 8080 chips in the 70's and frankly it has not gotten much better in my opinion.
Arduino has and will continue to attract big numbers because it is well presented , documented and mostly complete.
I do not understand a viewpoint that sees it as a competitor or lesser skilled approach to chip programming
I think you should hang your head in shame
I think you are jealous
Last edited by tytower on Thu Sep 20, 2012 9:38 am, edited 1 time in total.

horo
Rank 2
Rank 2
Posts: 63
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: Problem to compile a program with V-USB library [SOLVED]

Post by horo » Thu Sep 20, 2012 9:37 am

tytower wrote:...
Well thats a pretty cheeky ,rude,assunptive and completely wrong post.
...
Why the crap?

The pot calling the kettle black ;)
tytower wrote:The previous poster and the answers given indicate that he needed a Makefile so obviously there is not a Makefile supplied for the basic driver if he had to make up one himself

Please try to understand how v-usb works and don't take the term "driver" as you know it from e.g. windows.
You don't need a makefile to make the basic driver separately. It is supplied as source code and must be compiled/assembled together with your program (you need some defines/constants from _your_ config).
The right way is to take an example, replace the "main" file with your file(s), adapt the makefile and start. The benefit is that you can try to compile and load the example first to see if the usb part of your hardware works (if your pc detects it).

Ciao, Martin

tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by tytower » Thu Sep 20, 2012 9:44 am

horo wrote:
tytower wrote:...
Well thats a pretty cheeky ,rude,assunptive and completely wrong post.
...
Why the crap?

The pot calling the kettle black ;) Seems you have learnt an english phrase today and can't wait to use it .
tytower wrote:The previous poster and the answers given indicate that he needed a Makefile so obviously there is not a Makefile supplied for the basic driver if he had to make up one himself

Please try to understand how v-usb works and don't take the term "driver" as you know it from e.g. windows.
You don't need a makefile to make the basic driver separately. It is supplied as source code and must be compiled/assembled together with your program (you need some defines/constants from _your_ config).Yes I have made a copy of usbconfig_prototype.h and called it usbconfig.h and made changes to suit my needs
The right way is to take an example, replace the "main" file with your file(s), adapt the makefile and start. The benefit is that you can try to compile and load the example first to see if the usb part of your hardware works (if your pc detects it).Thank You I will attempt it this way however I find it a cockeyed way of doing it

Ciao, Martin
Last edited by tytower on Thu Sep 20, 2012 10:20 am, edited 1 time in total.

horo
Rank 2
Rank 2
Posts: 63
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: Problem to compile a program with V-USB library [SOLVED]

Post by horo » Thu Sep 20, 2012 10:09 am

Tytower, you are rude and ignorant. You come here, hijack a thread formerly marked as solved and claim that the project has to fit your needs.
<*)))><
from my side EOD

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by ulao » Thu Sep 20, 2012 4:30 pm

Tytower, you are rude and ignorant.
My thoughts exactly. You continue to misunderstand peoples candor for arguments. You continue to to argue and insult while ignoring the responses you are given. You have shown all of us you dont care to read ( if the rules are not clear enough ) and you make no attempts get along. Thus far the only contribution you are making is a mess of every thread you touch.

Quit the attitude it does no one any good. Not to mention anyone willing to help will see this childishness and pay no attention to what you are asking. If you want to be part of this board, and it does not look like it, then park the attitude or you will be asked to leave.

Let us review...

"So how come V-USB does not come with a makefile?" You did see the answer to that yes? This is your question yes? We can only assume you are referring to the example projects and not v-usb its self? Its clear now that you need to set up a make file to compile a project example, has this been done? Let stay on topic here, just let us know what you are having problems with.

"There is no makefile for the basic driver as far as I can see so why not just supply one?" Perhaps this golden nugget I was able to extract from the mess above may explain the issue. v-usb is more like an api if you will it does not need a make file. You make a project, you make a make file and you just include the v-usb. All examples should run if you point to the make file like I showed you. This project does require some reading and understating and I agree its not as easy as the Arduino board. V-usb follows a more traditional compile. It is assumed you have the knowledge to make a simple project in avr studio or like and produce a hello world or such. Then you just include the v-usb stuff and use it. All examples show you how.

Disclaimer, I dont mean to sound like I'm talking down to you. I'm just answering your quest as its asked. The question itself suggests this information was needed. There is no need to blast off some rude reply claiming you know all of this, its just for understating and getting on the same page here. Now please retort or ask your next question.

tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by tytower » Thu Sep 20, 2012 10:16 pm

[ offensive post try again ]

Coda
Posts: 18
Joined: Thu Apr 26, 2012 10:56 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by Coda » Thu Sep 20, 2012 11:34 pm

Ulao, you get provoked and yet you still try to help. You are a better man than me. Good job I am not a mod here. Out of respect for the kind people at ObDev who spent countless hours writing this library (not DRIVER!) for us to play with for FREE, I'm going to keep my mouth shut.

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Problem to compile a program with V-USB library [SOLVED]

Post by ulao » Fri Sep 21, 2012 12:01 am

eh, I figure I'd try. Oh well. He is gone for now.

Post Reply