Author Topic: Trying to talk to a complex (right word?) USB mass storage device using a PIC.  (Read 10557 times)

st2000

  • Member
  • ***
  • Posts: 44
I have a USB media player that appears, when connected to a Ubuntu box, as two mass storage devices.  The first, I believe, is a fake mass storage device and is used to control the video player.  The second is an actual SDcard mass storage device and contains the media files.

This all works fine on the fully equipped USB host Ubuntu box.  But I ultimately want to control the media player using a PIC processor acting like a USB host.

Currently, the PIC processor can read a USB thumb drive.  I was hoping I could start off by connecting the media player in place of the USB thumb drive and similarly read the SDcard inside the media player.   But no such luck.

On the Ubuntu system the SDcard was the second of the two mass storage devices found on the media player.  So I am thinking the SDcard would be the 2nd enumerated device.  Humm, if true, anyone know how to point the PIC processor to the 2nd enumerated mass storage device?

-thanks

st2000

  • Member
  • ***
  • Posts: 44
Re: Trying to talk to a composite USB mass storage device using a PIC HOST.
« Reply #1 on: January 07, 2011, 09:37:08 am »
As a follow up...

In the "Microchip Solutions" package there are examples of composite (not complex, my bad, I'll change that in the title now) HOST code.  I have not found an MSD + MSD example and would appreciate any help WRT this.  What I have found is MSD + HID and MSD by it's self.  To put me on the right path, can anyone outline what the HOST is doing WRT enumeration and what other hose-keeping in order to communicate with composite devices.  That would help a lot as I try to identify the Microchip code I need to change for my particular needs.

-thanks


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
usb_host_msd.c says:

/* Max Number of Supported Devices

This value represents the maximum number of attached devices this class driver
can support.  If the user does not define a value, it will be set to 1.
Currently this must be set to 1, due to limitations in the USB Host layer.
*/
#ifndef USB_MAX_MASS_STORAGE_DEVICES
    #define USB_MAX_MASS_STORAGE_DEVICES        1
#endif

I'm not sure if the limit also affects composite devices with multiple MSDs. If you only need to access one of the MSDs, you might be able to ignore one of the interfaces and use the other for this specific device.

Someone on the Microchip USB forum might have more specific advice.

Jan

st2000

  • Member
  • ***
  • Posts: 44

Thanks Jan.

That does toss a wrench into the works.

But I am hopeful that I really only need to access 1 MSD at a time.  Let me explain...

The 1st MSD is not FAT.  It is just memory mapped control locations.  The trick here is to figure out how to read and write directly into and from this MSD.  I think all I need to do is peal back the Microchip FAT drivers to find the actual read and write functions.  But finding them and understanding them is confusing.  Probably because these read / write functions contain overhead to handle USB transfers.  If any can clue me in on which function to study I would appreciate it.

The 2nd MSD is expected to be a normal FAT formatted device.  If I can figure out how to switch between these two MSDs I should be in good shape.  Any one care to suggest something here?

-thanks



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
On the Ubuntu system, if the first drive appears in  /proc/mounts, it supports a file system.

Jan

st2000

  • Member
  • ***
  • Posts: 44
What I found out was a PIC using modified Microchip Solutions functions will by default access (I think) the 1st MSD.  This turned out to be the Controller MSD (not the SDCard MSD).  What I did was to make a private copy of a chain of Microchip Solutions functions leading to a function which tested for a FAT formatted MSD.  I gutted that fuction (as my MSD has no FAT formatting but was only control registers memory mapped into the space of an MSD) and simply read the sector, modified the copy in memory and wrote back the sector.  I was able to control the media device at that point.

I've started another thread concerned with accessing the 2nd MSD in the composite USB device.  I believe it to be a trivial matter once I understand where in the Microchip Solutions code the decision to use which of the two USB Interfaces is made:

http://www.lvr.com/forum/index.php?topic=305.0