newbie help: avr-usb translation into AVR Studio 4

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
smellsofbikes
Posts: 2
Joined: Mon Dec 01, 2008 8:19 am
Location: Denver, CO

newbie help: avr-usb translation into AVR Studio 4

Post by smellsofbikes » Mon Dec 01, 2008 8:30 am

I can't get the linux toolchain to talk to my USB programmer, so I'm reluctantly trying to use AVR Studio 4. The problem is: I can't get any of the example code to compile in AVR S4. Basically, I'm wondering how to translate from makefile-based c-code to what AVR S4 expects. (Which is frustrating, since I know it's based on gcc too.)
So, in essence, what I do is copy all the .c and .h files into a directory, open a new project in AVR S4, and add all the .c files to the project source files, and all the .h files to the project header files, save everything, then try to build it. It has 8376945 (or thereabouts) errors because it can't find the header files, claims syntax errors everywhere in the .c files.
examples:

Build started 30.11.2008 at 22:17:19
avr-gcc.exe -mmcu=attiny85 -Wall -gdwarf-2 -O0 -MD -MP -MT main.o -MF dep/main.o.d -c ../../main.c
In file included from ../../main.c:16:
c:/program files/winavr/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for <util/delay.h>"
../../main.c:18:20: error: usbdrv.h: No such file or directory
../../main.c:43: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'reportBuffer'

and so forth.
Any suggestions?
I'm working on getting the USB programmer working under linux and then everything should be dandy. But Studio4 simply confuses me, and some googling under avr studio4 makefile translation or the like doesn't get me anything useful so far.

Thanks for any help.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Mon Dec 01, 2008 12:14 pm

You need to pass additional compiler flags. Most importantly: -DF_CPU=12000000 (or whatever your clock frequency is) and -Iusbdrv unless you move all the usbdrv files into your main source directory.

You also need to add the assembler file usbdrvasm.S to the project.

smellsofbikes
Posts: 2
Joined: Mon Dec 01, 2008 8:19 am
Location: Denver, CO

Post by smellsofbikes » Mon Dec 01, 2008 5:30 pm

Thanks!
I also didn't know how to use an external makefile, which I figured out last night, so now at least I'm getting a .hex file out. I haven't had a chance to try it on the chip itself, yet.

Post Reply