Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Chuck99
PostPosted: Mar 16, 2012 - 03:30 AM
Hangaround


Joined: Oct 31, 2009
Posts: 353
Location: Vancouver, WA, USA

LUFA & Studio5 - Beginner's Guide
Part 1 – Compiling the VirtualSerial Demo.

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:
Part 2: Modifying VirtualSerial for OLIMEX162 Board
http://www.avrfreaks.net/index.php?name ... highlight=

Part 3: Create New Project with USB CDC
http://www.avrfreaks.net/index.php?name ... highlight=

--------------------

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;".

-


Last edited by Chuck99 on Apr 18, 2012 - 08:54 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 16, 2012 - 09:39 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71188
Location: (using avr-gcc in) Finchingfield, Essex, England

Nice looking guide!

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Mar 16, 2012 - 01:06 PM
Moderator


Joined: Jan 23, 2004
Posts: 10215
Location: Melbourne, Australia

Brilliant!

- Dean Twisted Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Chuck99
PostPosted: Mar 17, 2012 - 01:12 AM
Hangaround


Joined: Oct 31, 2009
Posts: 353
Location: Vancouver, WA, USA

clawson & Dean, thanks for the compliments.
 
 View user's profile Send private message  
Reply with quote Back to top
runborg
PostPosted: Mar 18, 2012 - 09:03 PM
Newbie


Joined: Mar 18, 2012
Posts: 1


Ah! Thanx for the tutorial!
Finally, got a demo project to compile! Very Happy
 
 View user's profile Send private message  
Reply with quote Back to top
peter_moulin
PostPosted: Dec 13, 2012 - 05:38 PM
Rookie


Joined: Dec 11, 2011
Posts: 48


Chuck99 wrote:
LUFA & Studio5 - Beginner's Guide
Part 1 – Compiling the VirtualSerial Demo.

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

in Descritors.h we have
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);

and in device.h we have
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress
#if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \
!(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
, uint8_t* MemoryAddressSpace
#endif
) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);

Project is compiled under avrstudio5, device AT90USB162

Any suggestion?

Thanks
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
abcminiuser
PostPosted: Dec 13, 2012 - 11:34 PM
Moderator


Joined: Jan 23, 2004
Posts: 10215
Location: Melbourne, Australia

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 Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Chuck99
PostPosted: Dec 14, 2012 - 06:36 AM
Hangaround


Joined: Oct 31, 2009
Posts: 353
Location: Vancouver, WA, USA

peter_moulin wrote:
none of the demo like Mouse or virtualSerial Would compile.

What LUFA build are you using?
The guide uses LUFA-120219, while Dean's latest is LUFA-120730 (which I haven't tried yet).

abcminiuser wrote:
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.

Is this just for the latest release (120730)?
I don't recall needing to do that for 120219.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Dec 14, 2012 - 07:25 AM
Moderator


Joined: Jan 23, 2004
Posts: 10215
Location: Melbourne, Australia

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 Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
peter_moulin
PostPosted: Dec 14, 2012 - 08:42 AM
Rookie


Joined: Dec 11, 2011
Posts: 48


abcminiuser wrote:
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 Evil

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.

Pierre Shocked
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
peter_moulin
PostPosted: Dec 14, 2012 - 08:57 AM
Rookie


Joined: Dec 11, 2011
Posts: 48


peter_moulin wrote:
abcminiuser wrote:
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 Evil

I keep doing my analysis with AVRStudio5 now.

Pierre Shocked


"you need to add it to your project's global definitions,"
Yes it is there. Just import the .aps, keep the external make file, use WinAVR (project properties) and it works fine. the make file include:

"-DBOARD=BOARD_USBKEY -DARCH=ARCH_AVR8 -D USB_DEVICE_ONLY -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_FLASH_DESCRIPTORS -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"

which need to be added in AVRStudio5 tool chain symbol if you don't use the external make file

Pierre Wink
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
peter_moulin
PostPosted: Dec 14, 2012 - 11:24 AM
Rookie


Joined: Dec 11, 2011
Posts: 48


peter_moulin wrote:

I keep doing my analysis with AVRStudio5 now.

Pierre Shocked


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 " " Question value in LUFA_make is -I../../../../
There is also -I. in LUFA make , but again I don't see this as a major issue

Peter
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
Chuck99
PostPosted: Dec 14, 2012 - 11:30 AM
Hangaround


Joined: Oct 31, 2009
Posts: 353
Location: Vancouver, WA, USA

peter_moulin wrote:
The demo VirtualSerial build without any issue using WinAVR with make. I keep doing my analysis with AVRStudio5 now.

You have me confused now. In your post of 13 Dec @6:38pm you state
Quote:
Really nice guide, "but"
none of the demo like Mouse or virtualSerial Would compile.

The guide clearly shows how to use the make file provided in the demo while using Studio5.

If you chose not to follow that process, that's fine, but why didn't you mention that in your post when you said it wouldn't compile?
 
 View user's profile Send private message  
Reply with quote Back to top
peter_moulin
PostPosted: Dec 14, 2012 - 12:37 PM
Rookie


Joined: Dec 11, 2011
Posts: 48


Chuck99 wrote:

If you chose not to follow that process, that's fine, but why didn't you mention that in your post when you said it wouldn't compile?


You are right, I was not clear enough and in fact, I compiled successfully only after installing Winavr on my PC.
The Demos does not compile with the native AVRStudio flavour

Pierre Sad
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
delcon
PostPosted: Apr 14, 2013 - 04:12 PM
Newbie


Joined: Apr 12, 2013
Posts: 2


Hi Chuck

I am trying to get your Virtual Serial Compiled.

I am using AtmelStudio 6 and an old copy of LUFA120219.
The current LUFA 130303 has no .aps file to import.

The make file seams to be found. But I am getting an Error on compile:
RunCompilerTask-Aufgabe
C:\Program Files (x86)\Atmel\Atmel Studio 6.1\shellUtils\make.exe -C "C:\Users\Leo\Documents\Atmel Studio\VirtualSerial\VirtualSerial" -f "makefile" all
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.

....
....
make: *** [gccversion] Error 2

Do you have any idea why I am getting this error?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Apr 14, 2013 - 04:18 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71188
Location: (using avr-gcc in) Finchingfield, Essex, England

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.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
delcon
PostPosted: Apr 14, 2013 - 08:24 PM
Newbie


Joined: Apr 12, 2013
Posts: 2


Oh thanks for the tip! Works perfect now...
 
 View user's profile Send private message  
Reply with quote Back to top
rogertrullo
PostPosted: May 21, 2013 - 04:56 PM
Newbie


Joined: Sep 02, 2012
Posts: 18


I'm starting to try to get it working with atmega32u4, this seems so good for the newbies, thanks for sharing.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: May 21, 2013 - 04:58 PM
Moderator


Joined: Jan 23, 2004
Posts: 10215
Location: Melbourne, Australia

Please upgrade to Atmel Studio 6.1 and use the new LUFA extension instead, as it makes generating the demos and configuring them MUCH easier (using the GUI).

http://gallery.atmel.com/Products/Detai ... 998b3d789d

- Dean Twisted Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Chuck99
PostPosted: May 21, 2013 - 10:15 PM
Hangaround


Joined: Oct 31, 2009
Posts: 353
Location: Vancouver, WA, USA

rogertrullo wrote:
thanks for sharing.

I glad you found it helpful, but Dean is right. This tutorial is now more than a year old and both LUFA and Studio have been revised.

Dean, you used to write tutorials. How about a step by step tutorial on using LUFA with 6.1 to add a Virtual Serial port to a user's application? Something similar to the part 3 of my old tutorial?
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits