USB Mass Storage Class Devices

From OSDev Wiki
Jump to navigation Jump to search

This article is a stub! This page or section is a stub. You can help the wiki by accurately contributing to it.

The contents here were originally located on the USB entry but have been moved here to provide minimal information until replaced with more details.

Subclasses

Types

CBI

"Control/Bulk/Interrupt (CBI) transport is only for full-speed floppy disk drives. It will not be used in conjunction with LSDFS, and it's use in ANY new design id discouraged." - USB MSC specification.

BBB

Bulk Only (BBB)

Bulk Only Mass Storage Devices are the most common type of USB storage device, and they include most USB thumb drives, hard drives, CD, DVD and Blu-ray drives as well. They normally use the SCSI Command Set, but the USB Mass Storage specifications allow devices to use other command sets as well.

The USB Mass Storage Class adds two additional USB commands to the default control endpoint to allow the system to reset the mass storage device, and to get the number of "logical" devices supported by the physical mass storage device.

The SCSI Command block is encapsulated in a "Command Block Wrapper" (CBW), which contains information about the length of the command, the direction, the logical unit to send the command to, and a unique identifier that will be returned in the response from the device that can be used to match up the request with the response by the host. The Command Block Wrapper is sent to the device using the first Out direction, Block only endpoint on the interface, before any data is sent to or received from the device. Then, a final "Command Status Wrapper" (CSW) is sent to the host by the device that contains the results of the operation.

Command Block Wrapper

Offset (Hex) Type Description
0x00 int32 Signature (0x43425355)
0x04 int32 Tag (Transaction Unique Identifier)
0x08 int32 Length
0x0c byte Direction (0x00 = ToDevice, 0x80 = ToHost)
0x0d byte Logical Unit Number
0x0e byte Command Length
0x0f byte[16] Command Data

Command Status Wrapper

Offset (Hex) Type Description
0x00 int32 Signature (0x53425355)
0x04 int32 Tag (Copied From CBW)
0x08 int32 Residue (Difference Between CBW Length And Actual Length)
0x0c byte Status (0x00 = Success, 0x01 = Failed, 0x02 = Phase Error)

UFI

LSDFS

Locakable Storage Devices Feature Specification (LSD FS)


Booting

Booting off of a USB flash disk

If the BIOS supports it is it as simple as selecting USB-FDD in the boot order and putting a simple bootloader (grub might do, I rolled my own) into the first 512 bytes of the device. The BIOS will handle all the fancy PCI / USB stuff via int 0x13. Note that there is no need for any specific filesystem or partitions (which means you can just "dd" a 2.2 linux kernel (which used to contain a simple floppy loader) to /dev/sda and it will easily come up).

See Also

Forum Topics

  • USB stick - discusses the feasability of booting from an USB memory stick

Specifications