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: Apr 15, 2012 - 12:12 AM
Hangaround


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

LUFA & Studio5 - Beginner's Guide,
Part 3: Create New Project with USB CDC Connectivity

In Part 3, we create a Studio5 New Project and use LUFA to add USB CDC connectivity.

Part 1 can be found here:
http://www.avrfreaks.net/index.php?name ... p;t=118597

Part 2 can be found here:
http://www.avrfreaks.net/index.php?name ... p;t=119003

The tutorial is in the attached pdf and the software files in the attached .zip
(You need to be logged in to download the attached files.)
 
 View user's profile Send private message  
Reply with quote Back to top
protheusdk
PostPosted: Apr 16, 2012 - 06:36 AM
Newbie


Joined: Apr 09, 2009
Posts: 1


Thanks!!! it works great with atmega32u2!!

I just wonder what is the optimization level?
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Apr 16, 2012 - 09:00 PM
Hangaround


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

Glad it worked for you.

protheusdk wrote:
I just wonder what is the optimization level?

From the makefile:
Code:
# Optimization level, can be [0, 1, 2, 3, s].
#     0 = turn off optimization. s = optimize for size.
#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s

 
 View user's profile Send private message  
Reply with quote Back to top
chotan
PostPosted: May 11, 2012 - 07:54 PM
Rookie


Joined: Dec 05, 2010
Posts: 27


Thanks Chuck99 for your effort and nice tutorial.

/Chotan
 
 View user's profile Send private message  
Reply with quote Back to top
hsieber
PostPosted: Jun 11, 2012 - 06:44 PM
Newbie


Joined: Jun 02, 2009
Posts: 15


Chuck99-
Thanks for the excellent tutorial & other material. Have you tried the LUFA demos with Studio6? I think they should work fine since S6 is a superset of S5 (I have read this elsewhere on the forum). I have tried the ASF stack and found it quite opaque & hard to set up, specially for XMEGA256A3BU on a custom board.
Thanks!
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Jun 11, 2012 - 09:23 PM
Hangaround


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

hsieber wrote:
Chuck99-
Have you tried the LUFA demos with Studio6?

I haven't tried Studio6 yet. I may wait for 6.1 Wink
 
 View user's profile Send private message  
Reply with quote Back to top
hsieber
PostPosted: Jun 11, 2012 - 11:09 PM
Newbie


Joined: Jun 02, 2009
Posts: 15


Chuck99-

I am following Part 1 of the tutorial and am stumped by the most basic of tasks- I can't get the path to the LUFA makefile right. This is quite frustrating since I think I'm doing everything per the example (which is quite clear and explicit, by the way).

Project path (moved from the LUFE Demo folder):
...My Documents\AVR_Sw\LUFA_HID_Test1\GenericHID
LUFA Path:
...My Documents\AVR_Sw\LUFA\LUFA-120219\LUFA-120219\LUFA\makefile

Altered project makefile in the project directory:
# Path to the LUFA library
LUFA_PATH =../../LUFA/LUFA-120219/LUFA-120129

Attempt to clean the project yields error message:
../../LUFA/LUFA-120219/LUFA-120219/LUFA/makefile: No such file or directory

This error comes from the local makefile so at least that's being read properly. If I manually change directories (back up two, down per the makefile), either in Windows or via a DOS box, I always seem to end up at the correct LUFA makefile OK, but the compiler can't find it.

You may notice that I have elected to do the generic HID rather than the CDC project, but otherwise the paths should be ok. This has all the earmarks of a really dumb mistake but I can't find it. Does Windows need back slashes rather than forward?? I would use an absolute path but I think C: is not permitted.

Aggravated in Annandale....
 
 View user's profile Send private message  
Reply with quote Back to top
hsieber
PostPosted: Jun 11, 2012 - 11:19 PM
Newbie


Joined: Jun 02, 2009
Posts: 15


Chuck99-
Tried copying the original LUFA makefile into

..My Documents\AVR_Sw\LUFA_HID_Test1\LUFA

and changing the local makefile to:

# Path to the LUFA library
#LUFA_PATH =../../LUFA/LUFA-120219\LUFA-120129
LUFA_PATH =../

This allows a clean and compile. I would prefer to leave the LUFA makefile where it belongs, I must be doing something wrong with the path specifiers.

Thanks,
H
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Jun 11, 2012 - 11:59 PM
Hangaround


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

hsieber wrote:
If I manually change directories (back up two, down per the makefile), either in Windows or via a DOS box, I always seem to end up at the correct LUFA makefile OK, but the compiler can't find it.


Everything looks ok.

My only guess is that the make program (which is the one that can't find it) is not starting from where you think it is starting.

1) The make file you are editing should be located in the project folder. (Same folder as .c file.)
2) In the project properties, under build, specify the path to this makefile.

When I get a chance, I'll try compiling the HID demo.
 
 View user's profile Send private message  
Reply with quote Back to top
hsieber
PostPosted: Jun 12, 2012 - 03:20 PM
Newbie


Joined: Jun 02, 2009
Posts: 15


That was my thought too, but there is only one image of the altered (from demo) makefile and it's in what I think is the project directory (the one with the relevant .c and .h files).

I have bigger problems, I was incorrect when I mentioned that the project would clean and build. It will clean but the build throws:

Task "RunCompilerTask"
C:\WinAVR-20100110\utils\bin\make.exe -C "C:\Documents and Settings\Harry Sieber\My Documents\AVR_SW\LUFA_HID_Test1\GenericHID" -f "makefile" all
make: Entering directory `C:/Documents and Settings/Harry Sieber/My Documents/AVR_SW/LUFA_HID_Test1/GenericHID'
-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
make: Leaving directory `C:/Documents and Settings/Harry Sieber/My Documents/AVR_SW/LUFA_HID_Test1/GenericHID'
make: *** No rule to make target `GenericHID.elf', needed by `elf'. Stop.
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "GenericHID.cproj" -- FAILED.
Done building project "GenericHID.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Looks like a makefile problem. I'm not used to using external makefiles and I think something is very wrong- need to decode the 'No rule to make target `GenericHID.elf' statement. Normally I get a long string of compiler results, in this case it's jumping out almost immediately. Oh well, time to look for an app note on constructing makefiles... I might try doing the CDC example with Studio 5.1 as a sanity check.
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Jun 13, 2012 - 01:07 AM
Hangaround


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

hsieber wrote:
I have bigger problems, I was incorrect when I mentioned that the project would clean and build. It will clean but [not build]

It is important that LUFA_PATH points to the LUFA library. The Studio5 project makefile (which is the one that we edit) "include"s the makefile located in LUFA/
Code:
# Create the LUFA source path variables by including the LUFA root makefile
include $(LUFA_PATH)/LUFA/makefile

This included makefile references other files in LUFA by specifying directories relative to its own location.
Code:
LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA
LUFA_SRC_USB          = $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c

If you use a copy of this makefile located in another directory, it messes this up. The files referenced can't be found.

The solution is to specify LUFA_PATH so that the LUFA makefile can be found where it is.

Using Studio5 (5.1.208) I was able to import the GernericHID Demo and compile it.
Initially it failed. It turns out that I had mixed '/' and '\' in the path specifications. Easy to do when you copy and paste from Windows. Once that was corrected, it cleaned and built with no errors.

Always use '/' in the makefile for specifying a directory.

Here is the LUFA_PATH:
Code:
LUFA_PATH = ../../../Atmel_Studio_Libraries/LUFA/LUFA-120219/LUFA-120219

Here is the directory structure on the computer:
Code:
makefile in the Studio5 project folder:
I:\_Files\Programming\Atmel_Studio_Projects\GenericHID_Demo\GenericHID
   makefile

makefile in LUFA library:
I:\_Files\Programming\Atmel_Studio_Libraries\LUFA\LUFA-120219\LUFA-120219
   LUFA\makefile


You can instruct the makefile to display files in a directory, and thus test the LUFA_PATH as specified.

In the project makefile, find the "begin:" section.
Code:
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
   @echo
   @echo $(MSG_BEGIN)

end:
   @echo $(MSG_END)
   @echo

Insert the "# Test:" code as shown below
(be sure that a TAB character precedes @echo and ls, not spaces)
Code:
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:

# Test:
   @echo " "
   @echo Show LUFA Directory
   ls $(LUFA_PATH)/LUFA/
   @echo " "
# End Test

   @echo
   @echo $(MSG_BEGIN)

end:
   @echo $(MSG_END)
   @echo


When you clean or build, the output will show the directory and files.
Code:
      Show LUFA Directory
      ls ../../../Atmel_Studio_Libraries/LUFA/LUFA-120219/LUFA-120219/LUFA/
      CodeTemplates
      Common
      Doxygen.conf
      DoxygenPages
      Drivers
      LUFA - Shortcut.lnk
      License.txt
      Platform
      Scheduler
      Version.h
      makefile
      
      -------- begin --------
      Cleaning project:


If there is a problem with files not found, this will show you what the make program is finding and thus help you debug.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jun 13, 2012 - 09:58 AM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

Chuck, have you seen the new LUFA build system currently in trunk?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
hsieber
PostPosted: Jun 13, 2012 - 03:06 PM
Newbie


Joined: Jun 02, 2009
Posts: 15


Great points! I was afraid that moving things around would foul up relative paths so I managed to point to the right LUFA directory, still the dreaded 'no rule to make target' message. I also requested tech support on this issue, and the inestimable Mr. Camera indicated that there were new LUFA files available for XMEGA support. I plan to download those & try again.

One little nugget- contrary to various posts, spaces in makefile filenames will not respond to double quotes or double slashes. I found that a single forward slash will escape the spaces in the filenames.

Thanks for taking so much time to assist with this!!!
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Jun 13, 2012 - 09:00 PM
Hangaround


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

abcminiuser wrote:
Chuck, have you seen the new LUFA build system currently in trunk?

- Dean :twisted:

No, I haven't. Where do I find it?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 13, 2012 - 09:14 PM
10k+ Postman


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

Quote:

Where do I find it?

The website seems to suggest:

SVN: http://www.lufa-lib.org/svn
GIT: http://www.lufa-lib.org/git
src archive: https://github.com/abcminiuser/lufa-lib/archives/master

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Jun 13, 2012 - 09:40 PM
Hangaround


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

clawson wrote:
Quote:

Where do I find it?

The website seems to suggest:

SVN: http://www.lufa-lib.org/svn
GIT: http://www.lufa-lib.org/git
src archive: https://github.com/abcminiuser/lufa-lib/archives/master

Thanks Clawson.
I was looking in fourwalledcubicle.com. I forgot about lufa-lib.org.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jun 13, 2012 - 09:45 PM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

Specifically, what I mean are these new makefile modules:

https://github.com/abcminiuser/lufa-lib ... LUFA/Build

Which are used in user projects thusly:

https://github.com/abcminiuser/lufa-lib ... I/makefile

Which means much, much easier to understand and edit project makefiles (no more 1000+ line makefiles for each project). Try "make help" from the project makefiles, which will print out information about the included build module targets.

You can find information on the new build system in the manual (run "make doxygen" on the core) in the new chapter. Also note the new chapter on how to easily export the core and import it into a new AVR Studio 5/Atmel Studio 6 project in the documentation.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Chuck99
PostPosted: Jun 14, 2012 - 03:31 AM
Hangaround


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

Looks interesting. Is there going to be a new release soon?

abcminiuser wrote:
You can find information on the new build system in the manual (run "make doxygen" on the core) in the new chapter.

I'm not sure what run "make doxygen" on the core means. What directory do I switch to to run it?
Quote:
Also note the new chapter on how to easily export the core and import it into a new AVR Studio 5/Atmel Studio 6 project in the documentation.

That will be very nice. Smile
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jun 14, 2012 - 07:05 AM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

Quote:

Looks interesting. Is there going to be a new release soon?


I'm tossing up whether to wait for more improvements (preliminary IAR support, proper board driver init system) or whether I should release now and potentially change up the APIs yet again. Given that I've never had a release without API changes I suppose it's not a huge issue, but I don't want to upset users more than I have to.

Quote:

I'm not sure what run "make doxygen" on the core means. What directory do I switch to to run it?


To re-make the documentation for the library, navigate inside the core library folder (the "LUFA" folder with the "Drivers", "Common", etc. subfolders) and run "make doxygen". You will need to install Doxygen from www.doxygen.org .

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Chuck99
PostPosted: Jun 14, 2012 - 08:04 AM
Hangaround


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

abcminiuser wrote:
I'm tossing up whether to wait for more improvements ...

I didn't mean to press you. I'm quite happy with LUFA-120219.
It gives me the USB CDC which is what I was after.
I will be looking at the "import to Studio5" capability that you mentioned.

Any plans to extend LUFA to the ATSAM3S series?

Also, thanks for the explanation on how to generate the documentation.
 
 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