EmbeddedRelated.com
Forums

USB dual mass storage device options

Started by medw...@hotmail.com March 18, 2007
Hi All,

I've coded up a dual FAT file system using the Philips LPC2148, serial flash and SD card.

I basically use a file system on the serial flash for a data logger and then transfer the files to the SD card when I'm done. I've got a USB mass storage interface to the Serial flash and thought it would be useful to have the SD card show up as a second drive.

So here's the thing. I've read that I can have a seperate interface descriptor for my composite USB device or use the LUNs bit of the spec to represent both devices on one interface.

Any suggestions on what works best? I've been scratching around for examples of a dual composite MSD without success...

Cheers,

Mark.

An Engineer's Guide to the LPC2100 Series

Hi Mark,

> So here's the thing. I've read that I can have a seperate interface
descriptor
> for my composite USB device or use the LUNs bit of the spec to
represent both
> devices on one interface.

LUN approach is definitely better.

The mass storage class implementation is roughly divided into four
layers as follows.
1) Standard request/ bulk endpoint handling
2) MSC BOT (Mass Storage Class Bulk-Only Transfer) handling
3) SCSI command handling
4) Serial FLASH / SD handling

When you apply a separate interface for the another storage, you
should modify whole stack of these layers to support it. But for the
LUN approach, most of modification is applied just to the SCSI command
handling.

> I've been scratching around for examples of
> a dual composite MSD without success...

As you have a successful MSD implementation for the serial FLASH, it's
not so much difficult to add another LUN support to it. In your
implementation, the serial FLASH is already handled as LUN=0. Then,
add LUN=1 for the SD.

LUN is specified by the bCBWLUN field of the CBW.
- GetMaxLUN request - return 1 instead of 0
- CBW validity check - allow bCBWLUN == 0 and 1
- SCSI commands - When LUN equals to 1, apply the command to SD.

You'll find SCSI command handling for SD/MMC in this example from SiLabs.
It is written for 8051, but you'll easily port it to LPC2148
"AN282: USB Mass Storage Reference Design" from SiLabs
http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/USB/en/AN282.pdf
http://www.silabs.com/public/documents/software_doc/othersoftware/Microcontrollers/en/AN282SW.zip

F34x_MSD_Scsi.c: SCSI command handler
F34x_MSD_MMC.c: SD/MMC interface handler over SPI
SD and MMC have common interface over SPI.

SD and MMC manuals are downloaded from SanDisk
http://www.sandisk.com/Oem/Manuals/

For the MMC/SD command reference, see this MMC manual rather than SD,
because the SD manual is not revised recently.
http://www.sandisk.com/Assets/File/OEM/Manuals/ProdManRS-MMCv1.3.pdf

Tsuneo

--- In l..., medwar19@... wrote:
>
> Hi All,
>
> I've coded up a dual FAT file system using the Philips LPC2148,
serial flash and SD card.
>
> I basically use a file system on the serial flash for a data logger
and then transfer the files to the SD card when I'm done. I've got a
USB mass storage interface to the Serial flash and thought it would be
useful to have the SD card show up as a second drive.
>
> So here's the thing. I've read that I can have a seperate interface
descriptor for my composite USB device or use the LUNs bit of the spec
to represent both devices on one interface.
>
> Any suggestions on what works best? I've been scratching around for
examples of a dual composite MSD without success...
>
> Cheers,
>
> Mark.
>
>> I've been scratching around for examples of
>> a dual composite MSD without success...
>>

The IAR Mass Storage Example implements SD and RAM drive. The link to
download can be found in the link area of this group.

Joel