0

I am trying to talk to a MSC USB device (interface class 8, subclass 6, protocol 0x50) via a plain USB API with endpoints (all set up for me).

Provided I have a valid CDB, such as for "Test Unit Ready", how to I send that over the USB interface?

Where can I find examples or docs for how this is done?

Background: The actual platform is macOS, which doesn't provide SCSI-passthrough for block devices, and the native SCSI API is also not available in this case.

I have, however, been able to initiate communication on the USB level with the device, and am now trying to circumvent the blocked SCSI device level access by talking thru USB directly.

pmdj
  • 22,018
  • 3
  • 52
  • 103
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
  • I've so far found https://aidanmocke.com/blog/2020/12/30/USB-MSD-1/ and the document DS01169A from microchip.com, which both seems to describe how this works. I'll update my question or add an answer once I found out more. – Thomas Tempelmann Feb 09 '22 at 22:01
  • Are you looking to call a library to do the transfer for you? Are you on "bare metal", or under a Windows or *nix platform? Do you have a USB stack set up? Are you writing your own OS, currently [working on the USB](https://www.fysnet.net/the_universal_serial_bus.htm)? Please add a few more, quite a few more details. – fysnet Feb 09 '22 at 22:05
  • @fysnet - added some info. You can delete your comment, and once you do, I'll delete this mine as well. – Thomas Tempelmann Feb 09 '22 at 22:16

1 Answers1

1

Most such devices implement the so-called “Bulk Only” protocol, which is specified here: https://usb.org/document-library/mass-storage-bulk-only-10

Essentially, you send a 31-byte “Command Block Wrapper”, which includes the CDB and is specified in section 5.1 of the spec, to the device via the bulk out endpoint. You then read or write the data to be transferred from the input bulk endpoint or to the output bulk endpoint and finally read the 13-byte command status wrapper from the bulk in pipe.

However, note that you’ll need to make sure the OS hasn’t already loaded a driver for the device - from user space, the system won’t give you access to the endpoints when a kernel driver has claimed them anyway, but if you were to attempt to use the same pipes as the default driver from a kext, you’d get unpredictable results.

pmdj
  • 22,018
  • 3
  • 52
  • 103