Author Topic: Composite devices - anything undocumented to consider ?  (Read 17571 times)

erdmann

  • Member
  • ***
  • Posts: 43
Composite devices - anything undocumented to consider ?
« on: June 09, 2015, 04:34:29 am »
Hallo,

I am updating the OS/2 USB driver stack. Currently I am stuck with composite devices and I wonder if there is anything to consider that is undocumented. Currently I am working on the MSD class driver.

1) I have a USB microphone that also contains a "virtual CD-ROM" that contains Windows SW to use with the USB microphone. I now have the problem that the MSD class driver finds the MSD "virtual CD-ROM" (it's a SCSI interface subclass, BULK ONLY interface protocol) but when I attempt to read the virtual CD-ROM the sense code always tells me that "no medium is inserted". Now how am I going to insert a medium into a "virtual CD-ROM" ? Is there some trick to make the virtual medium load ? In particular is there any reliable sequence of SCSI commands to properly bring a MSD device into normal operation ? Do some devices require a full blown "reset MSD" before they will work at all ?

2) someone else has a USB printer with a bult-in SD card reader. Here, the card reader is found by the MSD class driver but it cannot be accessed.

Questions:
a) is it enough to do the "SET CONFIGURATION" for the (one single) configuration of the composite device just exactly once or is it necessary that every class driver does the "SET CONFIGURATION" ?

b) is it necessary to explicitely do the "SET INTERFACE" even if the alternate interface 0 is to be used ? Are there quirky devices that would require that ? Will it hurt to always do a "SET INTERFACE" ?

I am happy for any other hints or help. In particular with regards to how you properly get a MSD device into operation. I have found that some devices are not happy with SCSI command "START_STOP_UNIT" (I have one USB stick that returns with sense code indicating invalid command while all other USB sticks are happy with it) while others are not happy with "MODE_SENSE" (the virtual CD-ROM rejects this command with a "invalid parameter in command" sense code when I try to read "flexible disk" page which is what I need to do for USB floppy drives).


Lars

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Composite devices - anything undocumented to consider ?
« Reply #1 on: June 09, 2015, 09:47:52 pm »
To inform the host that media has been inserted, a device can generate a UNIT ATTENTION condition and set ASC = 28h and ASCQ = 00h, which the SPC specification defines as NOT READY TO READY CHANGE, MEDIUM MAY HAVE CHANGED.

Set Configuration is directed to the device so once is sufficient.

The specification doesn't require Set Interface. I don't know of any devices that require the request for interface zero, but that doesn't mean there are none. Devices that don't support the request should stall it.

For other mass-storage issues, see:

http://janaxelson.com/device_errors.htm


Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Composite devices - anything undocumented to consider ?
« Reply #2 on: June 10, 2015, 04:49:03 pm »
The mic's CD-ROM no doubt works best on Windows. Looking at the transactions Windows does to the device and what causes it to wake up is probably the best way to reverse engineer its logic.

Having a removable device with no "medium" inserted is a reasonable way to have the host have access to the "medium" at times you feel are convenient. The logic to make the device show up are device dependent. I've worked with devices which successfully use this trick to share storage with the host. It could be selectively set so that the medium was present so the host could sync files to it, or selectively "ejected" so that the device could examine those files for its own use.

Usually plugging the device into the host is enough to make the medium (logically) show up. There may be some particular SCSI command that windows sends that causes this to happen. The command could be as innocuous as test Unit Ready. Hence seeing what happens on Windows.

A host will usually send Test Unit Ready commands to a device periodically, and when one succeeds it will then access the medium. This works for real devices with real media and virtual devices with virtual media. I've never known any device use the Unit Attention mechanism, if there is one.

Same answer for the printer. Send Test Unit Readys to it periodically (about 1/sec is good) until something happens.

This really isn't a question about composite devices, but about MSC devices.

erdmann

  • Member
  • ***
  • Posts: 43
Re: Composite devices - anything undocumented to consider ?
« Reply #3 on: June 11, 2015, 08:13:42 am »
1) The device can return sense info of UNIT ATTENTION to tell me that a medium changed, but the question is: how do I "tell" it to take a medium (as it's only a "virtual CD-ROM")
2) In my case, plugging in the device leaves the device with "no medium". I just cannot see any SCSI command that would allow me to "load" a CD-ROM as I cannot physically do it myself (being only a virtual CD-ROM). But maybe the repeated "TEST_UNIT_READY" will do, I will need to try out ..
3) Is there any free SW for Windows that I can use to examine the command sequence that goes from host to device (maybe some driver that hooks into the USB drivers) ?
I don't know of any and I cannot afford to buy a USB HW tracer ...
4) yes you are right this really is a problem about MSD devices, it just popped up with the composite device


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Composite devices - anything undocumented to consider ?
« Reply #4 on: June 11, 2015, 10:59:41 am »
I have links to free software-only analyzers here:

http://janaxelson.com/development_tools.htm#analyzers

USBPcap + Wireshark will decode mass storage commands.

erdmann

  • Member
  • ***
  • Posts: 43
Re: Composite devices - anything undocumented to consider ?
« Reply #5 on: June 12, 2015, 06:49:11 am »
Thank you very much !
I think the software-only solutions will be sufficient for what I need to do.