How to create a project in AS7 based on USBKEY2 Demo Software

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like to start a project based on the Host mass storage/mouse demo(ref : AVR287) provided by Atmel with the AT90USBKEY2 so that I can get off the ground running as it were. Can someone point me in the right direction on how I go about using this demo software within AS7 so that I can make changes, compile and build it without hitting too many hurdles.

 

I notice that the AT90USBKEY2 board is not supported in AS7, does anyone know why.

 

Any help will be most appreciated.

Last Edited: Fri. Sep 30, 2016 - 09:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go to the Extension Gallery and download the "LUFA" extension. That has projects for AT90USB1287. (LUFA = Lightweight USB Framework for Atmel, written by the genius Dean Camera).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm back - Having downloaded the LUFA extension into AS7 I have been using the LUFA Host MS demo and I wanted to link up FATFs as abcminiuser had provided as part of the following forum thread,

 

https://www.avrfreaks.net/forum/c...

 

The problem I have at the moment is with copying the FATFs library into the host MS demo project in AS7, I'm sure it must be simple but I just don't get it. When I created the project it generated a library folder containing "libm" above the LUFA src folder, but I don't think it need to go there. Anyway, I just need to know how and where in the project structure(solution window) to add the FATfs library file that abcminiuser supplied. Then I have to try to understand what is meant by "add it to the make file" and "use diskio.c wrapper file to link FATFs to it"

 

I would be so happy to get some help with this exercise. smiley

 

 

Last Edited: Tue. Oct 4, 2016 - 12:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How well do you know FatFs already? It's quite complex to set up at first. This is not helped by the fact that the releases don't maintain backwards compatibilty so each time Chan makes a new release of FatFs it requires some work to get it into a usable form. For example, in the latest code you don't get a choice about connecting the SD/MMC to SPI. It must be connected to the USART in SPI mode.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have no FATFs experience, I wanted to to be able to transfer files to/from a USB memory stick and started by running an old demo on the USBKEY2 board that transfered a file in each direction when triggered by the left/right joystick, then I read some of the forum posts which recommends using LUFA as a base for all USB projects. I then tried out the LUFA host mass storage class driver but I need to learn how to use it. The old forum post I mentioned supposedly demos file transfer using FATFs so I thought I would try it out before I went any further, all good experience you know. But, I do struggle with the Atmel studio project structure and the different ways people explain the actions necessary in the various forum posts.

 

I'm trying to slowly learn a little about USB interfacing using the USBKEY2 which I purchased quite a while ago but haven't managed to do much with up till now, I connected it to a prototyping square-pad board and added an RS232 interface and can see the streamed text from the LUFA host MS demo in my PC terminal window.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh I see - so it's not the h/w driver level of FatFs you need anyway - only ff.c, ff.h and fconfig.h (or whatever it is called). That will give you the higher level FAT access. I presume the USB layer itself handles the SCSI level interface to the MSC to do the raw sector read/writes then the FatFs layer just puts an interpretation on the data sectors that are read.

 

If I were you I'd contact Dean directly. I doubt many people here are skilled enough in the specific area of LUFA+Host+OTG+SCSI+FatFs to help very much.

 

(PS you do realise that if you want bulk storage from a simple micro then SD/MMC is about a million times easier to use than USB-MSD ?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Love your bracketed last comment Cliff, I'm sure you're right. I'll try to get in touch with Dean via the 2012 forum post that I first referenced. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most immediate access to Dean is @abcminiuser on Twitter in fact. (he doesn't appear in Freaks much at all these days since he left Atmel).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After adding a library to my project, I was told to add it to the makefile - Please can anyone tell me how I make this change to the makefile in AS7, how do I find the makefile to edit it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AS7 is an Integrated Development Environment (IDE). The whole point of using an IDE is so you don't need to get your hands dirty with messy details like Makefiles. In an IDE you have a "project configuration". You tick boxes and radio buttons and make selections from drop lists and stuff like that. Finally you use "Build Solution" or "Build Project" and at that moment the IDE looks at all the config options you have set and uses the details to create a Makefile. It then passes this to the "make" utility that builds the code. As the Makefile is erased and recreated each time you build you don't edit it directly. If you want to make changes then you edit them into the project and those changes will go into the Makefile the next time you build.

 

There is an option in AS7 to say "use external Makefile" which says "don't create it each time, just use one that already exists on disk" but this "turns off" almost all the features that made you use the IDE in the first place. You might as well just use a plain editor and build at the command line in this case.

 

So what is it you need adding to the Makefile? If a library then I presume you have some kind of lib<something>.a file and you want the linker to link your code against it? There is a section in the IDE project configuration for adding such things. That will lead to "-Wl,-l<something>" being passed to the linker. The linker knows that -l<something> means "link with libsomething.a - it adds the "lib" on the front and the ".a" on the back.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got your message on Twitter. Cliff is right, I'm not around here much these days; my last job nearly destroyed my will to live (NEVER WORK AT A START UP COMPANY), and my new job keeps me so busy with challenging but awesome development that I haven't got the stomach in my downtime to troubleshoot even more problems :P.

 

FatFS is relatively easy to cram into a project. The base LUFA mass storage host demo doesn't use it - it just shows raw block reads and writes for simplicity, with the intention that people will glue it to their filesystem driver of choice (if they want to use one at all). FatFS just comes as a "source library" like LUFA itself, just a small pile of C files you can dump into your project and wire up to your application.

 

A good example of using LUFA in mass storage host mode along with FatFS is my old University thesis project, "ExplorerBot". In that project I logged sensor data to an attached USB stick, using FatFS. The important glue code that connects FatFS's disk IO layer to LUFA's USB Mass Storage code is here.

 

You should be able to grab the files from the FatFS directory of that project, and add them to the "Mass Storage Host (Class Driver)" LUFA example project. From there, use the init code from this file to initialize FatFS when a USB disk is inserted, and then you can use the high level f_open(), f_read(), f_write() and other FatFS calls to access the disk's FAT32 partition.

 

- Dean

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

Last Edited: Wed. Oct 5, 2016 - 08:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply Dean - I think I have attempted to action this the other day but I think I am having more problems understanding how to use AS7. I'll keep trying to build a solution and may eventually have some luck.

 

Your experience with the start up company will make you a better man as long as you take away the positives and forget all the other stuff(if you can, time will tell) - Oh, congrats to you and your other half for earlier in the year.

 

- Ray

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Dean,

 

I tried to build a project like you suggested with AS7 but my problems always seem to be outside of the project code, added FATfs to the Host MS demo project and used your makefile to build the project but get a "recipe for target sizebefore failed" message. This kind of message of course leaves me cold and turns my motivational neurons to the OFF state.

 

Have you ever tried your old projects with AS7?

 

kind regards, Ray : not twisted quite yet :

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have now imported AVR287 demo into AS7 with the help of the Atmel support team and refer anyone interested to the comments made in the following post,

 

https://www.avrfreaks.net/forum/h...