I had a somewhat difficult time getting started using Studio5 to compile the VirtualSerial demo in LUFA
(Lightweight USB Framework for AVRs), written and maintained by Dean Camera.

Basically, I didn't know what to do or where to begin. With help from a couple of old posts here at AVR Freaks, I slowly put the pieces of the puzzle together. This guide is what I wish I had had when I started.

The tutorial is in the attached pdf (you need to be logged in to download it).

Edit:
The makefile used in this tutorial is a modified copy of the makefile in the LUFA VirtualSerial Demo which uses the compiler option: "CFLAGS += -funsigned-char". This tells the compiler to use unsigned char by default. That is, "char i;" equals "unsigned char i;".

I had a somewhat difficult time getting started using Studio5 to compile the VirtualSerial demo in LUFA

Basically, I didn't know what to do or where to begin. With help from a couple of old posts here at AVR Freaks, I slowly put the pieces of the puzzle together. This guide is what I wish I had had when I started.

-

Really nice guide, "but"

none of the demo like Mouse or virtualSerial Would compile. I get the following error: "conflicting types for 'CALLBACK_USB_GetDescriptor'in descriptor.h line 83, followed by "previous declaration of 'CALLBACK_USB_GetDescriptor' was here device.h line 133

The CALLBACK_USB_GetDescriptor() function signature in your application Descriptors.h header file requires that you build with the compile time symbol "USE_FLASH_DESCRIPTORS", "USE_EEPROM_DESCRIPTORS" or "USE_SRAM_DESCRIPTORS". Setting one of those as the fixed address space for the descriptors changes the function signature and removes the "MemoryAddressSpace" pointer argument in the function.

Most likely you will want to add USE_FLASH_DESCRIPTORS to your project's build macros or uncomment it in your LUFAConfig.h header file.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

It's always been the case for the stock demos - you need to add it to your project's global definitions, or add it to your LUFAConfig.h in more recent versions.

- Dean :twisted:

As explained in your documentation LUFA-120219/Documentation/html/_page__compiling_apps.html The demo VirtualSerial build without any issue using WinAVR with make. I keep doing my analysis with AVRStudio5 now.
I will for example compare the make file given in the demo with the one generated by AVRStudio5. I have noticed that the make file given will call an other make file to make the drivers, in which options -D are given, may be they need to be added in AVRStudio5 project option.

Hereafter the main differences (same values have been deleted) between the call to avr-gcc as generated by make in the LUFA demo code:"avr-gcc -I. -fno-inline-small-functions -fno-strict-aliasing -Wstrict-prototypes -Wa,-adhlns=./Descriptors.lst -I../../../../ -MMD -MP -MF .dep/Descriptors.o.d Descriptors.c -o Descriptors.o"

and as generated by AVRStudio 5:"C:\WinAVR-20100110\bin\avr-gcc.exe" -I"../../../.." -MD -MP -MF "Descriptors.d" -MT"Descriptors.d" -o"Descriptors.o" ".././Descriptors.c"
This last one give: LUFA/Drivers/USB/USB.h: No such file or directory

The difference is probably in the " " around -I"../../../..", but I don't know why AVRStudio add those " " :?: value in LUFA_make is -I../../../../
There is also -I. in LUFA make , but again I don't see this as a major issue

Note that Dean has recently added LUFA as an Atmel Studio 6 extension. So the easiest answer for building LUFA in Studio may now be to get AS6.1 Beta then use the Extension Gallery to add LUFA. You can then just create LUFA projects in the same way that you create ASF projects.