Which Commands to Implement?

24 Mar

Which Commands to Implement?
A question many firmware programmers have is which SCSI commands a device must implement. Each device specifies a command set in the response to a SCSI INQUIRY command, and the command set’s specification lists mandatory commands. For example, a device that returns an INQUIRY response with PERIPHERAL DEVICE TYPE = 00h (direct access block device) and VERSION = 05h (SPC-3) should implement all commands defined as mandatory in the SPC-3 specification and all mandatory commands in a SCSI block commands specification such as SBC-2 or SBC-3. Table 6-1 shows the mandatory commands and some optional commands for devices that use SCSI block commands. In practice, however, many devices don’t implement every mandatory command.

The USB-IF is developing a USB Mass Storage Class Compliance Test Specification, which names required and optional SCSI and multimedia commands for different peripheral device types. At this writing, a preliminary version of the specification is available from the USB-IF. Also available is a preliminary version of the USB-IF’s Command Verifier software (USBCV) with mass-storage compliance tests. Check usb.org for the latest versions.

It’s also useful to learn what commands your device’s host(s) typically use and to be sure to implement those commands in your device. Some developers concentrate on supporting these commands rather than implementing every command a specification dictates. To learn what commands a host issues, use a bus analyzer to observe bus traffic when your device or similar devices are attached to a host.

In practice, to enable communications, a device should implement at minimum these SCSI commands:
INQUIRY
READ CAPACITY(10)
READ(10)
REQUEST SENSE
TEST UNIT READY
WRITE(10) (for writable devices)

A specific host or device is likely to require commands in addition to these, however. When a device claims to implement a command set, it’s reasonable for a host to assume that the device supports all commands declared as mandatory in that command set.

Table 6-1: Mandatory SCSI commands and common optional SCSI commands for USB mass-storage devices that comply with SBC-2 or SBC-3.

On receiving an unsupported command, a device must not crash or hang. The correct response to an unsupported command is this:
• Return 01h (command failed) in the CSW ‘s bCSWStatus field.
• In the sense data, set the SENSE KEY parameter to 05h (ILLEGAL REQUEST) and set the ADDITIONAL SENSE CODE parameter to 20h (INVALID COMMAND OPERATION CODE), as described below.

Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.