| Interfaces, Protocols, and Technologies
Designing and programming a USB mass-storage device or embedded USB
host involves a variety of interfaces, protocols, and structures.
Every USB mass-storage device must support two interfaces:
- A USB device interface to enable the device to communicate with a PC
or other USB host.
- An interface between the device’s microcontroller or other CPU and
the storage media. Flash-memory cards typically use the Serial
Peripheral Interface (SPI), MultiMediaCard bus, SD-Card bus, or a bus
derived from the ATA interface or PC-Card bus. Hard drives typically
use the ATA parallel interface.
A USB mass-storage device must implement these protocols and
structures:
- Generic USB protocol. Every USB device must respond to requests sent
by the USB host and other events on the bus.
- USB mass-storage protocol. Every USB mass-storage device must detect
and respond to requests that are specific to the USB mass-storage
class.
- SCSI commands. USB hosts access mass-storage devices via commands
originally developed for devices that use the Small Computer Systems
Interface (SCSI).
- Media-specific protocol. The storage media’s controller typically
supports a command set for accessing the media’s contents. Many
flash-memory cards use the MultiMediaCard protocol or the SD Card
protocol. Hard drives use the ATA protocol.
Reading and writing data to a mass-storage device also involves
understanding logical structures in the media:
- Media structure. Program code accesses the storage area in drives as
a series of logical blocks, or sectors. Dedicated areas in the media
store information about the logical blocks and other logical
structures in the media.
- File system. If the device firmware reads or writes to files on its
own, rather than via a USB host, the device must implement a file
system such as FAT16 or FAT32.
This book shows how to put all of these interfaces, protocols, and
structures to work in a USB mass-storage device. The book assumes you have
a basic familiarity with microcontroller programming and interfacing. For
more about USB, I recommend my book, USB Complete:
Everything You Need to Develop Custom USB Peripherals. |