The developer's resource for computer interfacing, especially USB, serial (COM) ports, mass storage, and embedded networking. (Formerly Lvr.com)

Home > USB Mass Storage > Contents

USB Mass Storage

ContentsUSB Mass Storage

Introduction

1 Mass Storage Basics

When to Use a Storage Device

Benefits

Other Considerations

Requirements

Devices

Embedded Hosts

Selecting a Media Type

Drive Mechanisms

Addressing Methods

Reading and Writing Considerations

Removable Media and Devices

Hardware Interfaces

Hard Drives

Technology

Interfaces

Flash Memory

Technology

Options for Flash Memory

MultiMediaCard

SD Memory Card

CompactFlash

Partner Links

2 Supporting USB

The Interface in Brief

Hosts and Devices

Host Responsibilities

Device Responsibilities

Bus Speeds

Endpoints

Transfer Types

Transactions

The Data Toggle

Descriptors

Mass Storage Requirements

Choosing a Device Controller

Controllers with Support for Flash Memory

Controllers with support for ATA/ATAPI

Firmware Options

Microchip PIC18F4550

Architecture

Firmware Support

The USB Controller

3 The USB Mass Storage Class

Requirements

Specifications

Logical Block Addressing

Mass Storage Requests

Descriptors

Device Descriptor

Configuration Descriptor

Interface Descriptor

Endpoint Descriptors

String Descriptors

Responding to Commands

The Command Block Wrapper

The Command Status Wrapper

Managing Communications on the Bulk Endpoints

More about STALL

Thirteen Cases for Any Situation

PC Support

Windows

Linux

4 Accessing Flash Memory Cards

The Interface

Signals and Power

Example Circuit

Host Programming

Configuring

Hardware Ports

Firmware-controlled Ports

Transferring Data

Default States

SPI on the PIC18F4550

Configuring the Port

Writing a Byte

Reading a Byte

5 MultiMediaCard Protocol

Command and Response Formats

Commands

Response Types

Token Formats

The Commands

Classes

Commands Used by Mass-storage Devices

Registers

Sending Commands

Timing Considerations

Commands with No Data Transfer

Commands that Read Data from the Storage Media

Commands that Write Data to the Storage Media

Application Example

Detecting and Selecting a Card

Sending a Command

Reading a Sector

Writing a Sector

Initializing Communications

6 SCSI Commands

About the Commands

Specifications

Which Commands to Implement?

Sense Data

Fixed-format Sense Data

Setting Default Values

Primary Commands

INQUIRY

MODE SELECT

MODE SENSE

PREVENT ALLOW MEDIUM REMOVAL

REPORT LUNS

REQUEST SENSE

SEND DIAGNOSTIC

TEST UNIT READY

Block Commands

FORMAT UNIT

READ

READ CAPACITY

START STOP UNIT

SYNCHRONIZE CACHE

VERIFY

WRITE

Multimedia Commands

READ FORMAT CAPACITIES

READ TOC/PMA/ATIP

Handling Commands and Events

Decoding Commands

The UNIT ATTENTION Condition

Informing the Host about Media Changes

Reset Behavior

7 Media Structure

A Look Inside

Components of Formatted Media

Drives without an MBR Sector

Byte Order

The Master Boot Record Sector

Executable Code

The Partition Table

Extended Partitions

The Boot Signature

8 FAT File Systems

Inside a FAT16 Volume

Reserved Region

File Allocation Table Region

Root Directory Region

File and Directory Data Region

Inside a FAT32 Volume

Reserved Region

File Allocation Table Region

File and Directory Data Region

Selecting a File System

Cluster Sizes

A Hardware Solution

The File Allocation Table

The First Two Entries

Data Clusters

Accessing the FAT

Volume Information

File Information

Obtaining a Cluster’s Logical Block Address

Reading from the FAT

Writing to the FAT

Finding a File’s Next Cluster

Performing Sequential Reads

Finding an Empty Cluster

9 Directories

The Contents of an Entry

File Entries

Directory Entries

The Volume Label Entry

Subdirectory Entries

Handling Long File Names

LFN Entries

The Checksum

Creating a Short File Name

Using Directories

Storing an Entry

Reading an Entry

Getting the Main Entry

Updating an Entry

Updating the Time and Date

10 File Operations

Cluster Operations

Erasing a Cluster

Reserving an Available Cluster

Allocating a File’s First Cluster

Allocating Additional Clusters

Managing Files

Obtaining File Information

Finding a File

Creating a Directory Entry

Finding an Available Entry

Creating a File

Deleting a File

Opening a File

Reading from a File

Tasks

Performing a Read Operation

Writing to a File

Tasks

Performing a Write Operation

Closing a File

11 Embedded Hosts

Inside an Embedded Host

OTG Devices and Conventional Hosts

General Host Functions

Mass Storage Functions

Handling Non-compliant Devices

Host Options

Cypress EZ-HOST

Host Software

A Mass-storage Host Module

Index