EmbeddedRelated.com
Forums
Memfault Beyond the Launch

interfacing USB flash disk

Started by Tim Mitchell March 23, 2004
I am designing a microcontroller based device which needs to connect to 
PC, probably by USB, and also needs some removable storage.

My first thought was to use compact flash for the storage because I've 
done that before & know how to use it. But then I wondered about using 
the USB flash disks you can get (the pen-type things built into a USB 
plug). I presume the problem with this would be (A) my device would have 
to be a USB host which adds a lot of complication and (B) getting the 
information on how to communicate with the flash disk. Has anyone tried 
to do this?
-- 
Tim Mitchell
> My first thought was to use compact flash for the storage because I've > done that before & know how to use it. But then I wondered about using > the USB flash disks you can get (the pen-type things built into a USB > plug). I presume the problem with this would be (A) my device would have > to be a USB host which adds a lot of complication and (B) getting the > information on how to communicate with the flash disk. Has anyone tried > to do this?
Yes, you would have to be a host to drive one of these USB flash discs. You would also have to implement the host portion of the Mass Storage device class in your system (the specifications for which is downloadable from www.usb.org). It would be easier to use a CF card (SD/MMC/etc.) as your storage media. I've not tried the USB-flash disc route myself (preferred CF card!). Andrew
Tim Mitchell wrote:
> I am designing a microcontroller based device which needs to connect to > PC, probably by USB, and also needs some removable storage.
As I think you know, when connected to the PC, your device would need to be a USB "device." When connecting to the removable storage, your device would need to be a USB host.
> My first thought was to use compact flash for the storage because I've > done that before & know how to use it. But then I wondered about using > the USB flash disks you can get (the pen-type things built into a USB > plug). I presume the problem with this would be > (A) my device would have to be a USB host which adds a lot of complication and
Yep. You need a USB host-controller, and a USB software stack (non-trivial).
> (B) getting the information on how to communicate with the flash disk.
The USB mass storage specification is your starting point for this.
> Has anyone tried to do this?
I have written an OHCI USB host controller framework, that supports control, bulk, and interrupt transfers (no isochronous support yet.) On top of this, I have written a USB mass storage bulk-only driver. This amounts to running SCSI commands using the USB Transparent Transport mechanism, over bulk-in and bulk-out pipes. However, I have found that there are *many* non-standard behaviors associated with different devices :-( Different devices support different sub-sets of SCSI commands. After that, I have FAT16 running over a block device driver adapter. All of my code is written in C++ running under an RTOS. The current implementation is running on a powerpc 860 class board. If you don't need the RTOS and have plenty of resources, you can always run Linux, and use their USB mass storage support without so much pain ;-) -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 "... abstractions save us time working, but they don't save us time learning." Joel Spolsky, The Law of Leaky Abstractions The Beatles were wrong: 1 & 1 & 1 is 1
> done that before & know how to use it. But then I wondered about using > the USB flash disks you can get (the pen-type things built into a USB > plug). I presume the problem with this would be (A) my device would have > to be a USB host which adds a lot of complication and (B) getting the > information on how to communicate with the flash disk. Has anyone tried
This problem is actually not as intractable as it sounds (for small values of "not difficult" - anything involving USB is inherently more difficult than it ought to be, partly because USB is evil, and partly because vendors of USB hardware only test their products with Windows, if at all, and frequently assume the existence and/or rely upon the presence of Microsoft-specific implementation noncompliance). The hostishness problem can be solved with an embedded USB host controller. Faced with a similar problem recently, I selected the Cypress SL811HS. This is available in a 28-pin PLCC (or 48-pin TQFP) package and is mechanically easy to prototype. It can function as either a host or a peripheral. It's about $8.50 in qty 1 (price goes down rapidly with quantity) and readily available. There are other options too. The communication problem is "simple" in that there is a vanilla storage device class, which those pen disks implement. That is why they don't require drivers when used with Windows Me, 2000 or XP, all of which include a driver for the generic storage class.
You might want to consider AT45DBCxxx Dataflash cards.
SPI interface, well documented in the datflash datasheets
and low cost.
Only drawback is that the size is currently limited to 8 MBytes.


-- 
Best Regards,
Ulf Samuelsson   ulf@a-t-m-e-l.com
This is a personal view which may or may not be
share by my Employer Atmel Nordic AB


"Tim Mitchell" <timng@sabretechnology.co.uk> skrev i meddelandet
news:PgEKhQVANCYAFAJH@tega.co.uk...
> I am designing a microcontroller based device which needs to connect to > PC, probably by USB, and also needs some removable storage. > > My first thought was to use compact flash for the storage because I've > done that before & know how to use it. But then I wondered about using > the USB flash disks you can get (the pen-type things built into a USB > plug). I presume the problem with this would be (A) my device would have > to be a USB host which adds a lot of complication and (B) getting the > information on how to communicate with the flash disk. Has anyone tried > to do this? > -- > Tim Mitchell
I'm finishing a project that uses the AT89C51SND1 chip.  The dev kit comes
with source code, board, etc as an MP3 player that uses USB and Windows Mass
Storage Device Driver.  It also comes with documenatation on how to hook it
to a CompactFlash card.  I suggest this chip.

Sean


"Tim Mitchell" <timng@sabretechnology.co.uk> wrote in message
news:PgEKhQVANCYAFAJH@tega.co.uk...
> I am designing a microcontroller based device which needs to connect to > PC, probably by USB, and also needs some removable storage. > > My first thought was to use compact flash for the storage because I've > done that before & know how to use it. But then I wondered about using > the USB flash disks you can get (the pen-type things built into a USB > plug). I presume the problem with this would be (A) my device would have > to be a USB host which adds a lot of complication and (B) getting the > information on how to communicate with the flash disk. Has anyone tried > to do this? > -- > Tim Mitchell
does anyone know of a  USB master for embedded use ??

hamilton wrote:
> > does anyone know of a USB master for embedded use ?? >
i.e. Philips ISP1362 and much time to write an USB host firmware stack. There are a few companies offers more or less suitable stacks for several platforms... Steffen -- http://www.da0hq.de
> You might want to consider AT45DBCxxx Dataflash cards. > SPI interface, well documented in the datflash datasheets > and low cost. > Only drawback is that the size is currently limited to 8 MBytes.
I came to the same conclusion. Running a USB host on a 'real' embedded system (8 & 16 bit) is non-trivial. Interfacing to Compactflash can be done. Sandisk has got some application notes on the topic: http://www.sandisk.com/oem_application_notes.html Using SD/MMC SPI compatible devices seems to be the simplest solution. My only problem is that they are a bit to small for my application (industrial equipment). Having a small card sounds great for a cell phone. But not so great when you are working in a heavy industry. Thus anyone know of any other (SPI comp.) form factor ? I haven' looked yet, but any suggestions for SD/MMC connectors ? I was also wondering what happens if you take out the card, is it directly interfaced to the uP or is there some power-off sequence to follow ? Stijn
These comments are intended to be my own opinion and they
may, or may not be shared by my employer, Atmel Sweden.

"hamilton" <hamilton@deminsional.com> wrote in message
news:40625fe3_3@omega.dimensional.com...
> > does anyone know of a USB master for embedded use ??
Check out the AT43USB370/380... Includes a CPU with the USB Stack. The main CPU needs a library for the different device classes. Currently Mass Storage is available and Printer in the works. -- Best Regards Ulf at atmel dot com

Memfault Beyond the Launch