Host Options

25 Mar

Host Options
PCs and other desktop computers are USB hosts that have drivers for communicating with mass-storage devices. Several vendors offer USB host-controller chips for use in embedded systems. Just about any of these chips is suitable for use in a mass-storage host. Many can function as a conventional host or as an OTG device. To speed up project developing, look for a development kit with mass-storage support or use an embedded operating system that has a mass-storage driver included or available from a third party.

Cypress EZ-HOST
Cypress Semiconductor offers the CY4640 Mass Storage Reference Design Kit for the CY7C67300 EZ-Host microcontroller.

The chip has two host/device SIEs and four USB transceivers that allow the device to have any of these configurations:

1 to 4 hosts
1 or 2 devices
1 host and 1 device
1 OTG device and one device-only function
1 OTG device and up to two additional hosts

In a mass-storage host application, the chip can be configured to function as a mass-storage host, as an OTG device that can function as a mass-storage host and device, or as a mass-storage host and device at the same time.

The development board also has an IDE interface that connects to a daughter board that can hold a small hard drive. With a drive attached, the development board can function as a USB drive.

The kit includes a GNU C compiler, assembler, linker, debugger, a development environment, and utilities. Example firmware supports FAT file systems and USB host communications with mass-storage devices.

Host Software
Several sources offer software for use in embedded systems functioning as mass-storage hosts. Windows CE 5.0 includes a USB host mass-storage driver. Linux includes mass-storage drivers and is suitable for some embedded applications. Other sources offer USB host stacks for use with a variety of embedded-system operating systems, host controllers, and CPU architectures. Sources for host stacks with mass-storage support include Accelerated Technology, Intoto, Jungo Ltd., Micro Digital, On Time Software, and SoftConnex.

A Mass-storage Host Module
Another approach to designing an embedded host is the USBwizTM chip from GHI Electronics. This is the same company that offers the uALFAT chip described in Chapter 8. The USBwiz is a Philips LPC2138 ARM processor programmed to support FAT file systems and several USB device classes, including mass storage. The chip interfaces to a Philips ISP1160 USB host controller chip.


Figure 11-3: The USBwiz-OEM board enables just about any microcontroller to access USB drives and flash-memory cards.

The USBwiz-OEM (Figure 11-3) is a circuit board that contains a USBwiz, an ISP1160, a MultiMediaCard/SD-card connector, and dual USB connectors for attaching devices. The USBwiz uses a +3.3V supply. The USBwiz- OEM board requires a +5V supply and has an on-board 3.3V regulator.

Microcontrollers can communicate with the USBwiz using an asynchronous serial interface, SPI, or an I2C bus. The USBwiz responds to commands sent in text mode, with commands and values sent as ANSI text, or in framed mode, with commands and values sent as binary values. In text mode, this command reads E8h bytes from a file opened with handle 0:

RF #0 E8

This command prepares the USBwiz to receive 10h bytes to be written to a file opened with handle 0Bh:

WF #B 10

On receiving the command above, the USBwiz returns a prompt character (“). The microcontroller writes the 16 bytes to the USBwiz, and the USBwiz returns a prompt character (“) to indicate that the data was received. Framed mode also supports reading and writing to sectors in the storage media. File commands enable opening, closing, reading, writing to, and deleting a file. Directory commands enable creating, changing, listing, and erasing a directory.

The USBwiz can interface directly to MultiMediaCard/SD Cards, and the host controller can communicate with USB drives. The USBwiz assigns drive letter A: to a connected MultiMediaCard/SD Card and drive letters B: to K: in sequence to a USB drive’s logical units.

A quick way to experiment with the USBwiz-OEM is to attach a flash drive, connect the board’s serial port to a PC, and use a terminal program such as Windows’ Hyperterminal to send commands and receive responses. To connect to a PC, connect the board’s asynchronous serial-port pins to the corresponding pins on a Maxim MAX3232 or similar RS-232 transceiver. If your PC doesn’t have an RS-232 port, connect the transceiver’s RS-232 pins to corresponding pins on an RS-232/USB converter. Or use an FTDI Chip to interface the USBwiz to a PC’s USB port.

271
Index
A
absolute time in Pre-Groove (ATIP),
reading, 159
Accelerated Technology, 38, 267
Accept Device Specific Command (ADSC)
request, 46
ACK code, 33
addressing methods, 10
allocating clusters, 226–227
ATA/ATAPI, controllers supporting, 38
ATA (Parallel AT Attachment) interface,
13
ATAPI (ATA with Packet Interface)
interface, 13
ATIP (absolute time in Pre-Groove),
reading, 159
attributes, directories, 202–204
Autorun/Autoplay support, 77
B
backup boot sector, 184
bAlternateSettings field, 51
bcdDevice field, 48
bcdUSB field, 47
bConfigurationValue field, 49
bDescriptorType field
configuration descriptors, 49
device descriptors, 47
endpoint descriptors, 53
interface descriptors, 51
string descriptors, 55
bDeviceClass field, 47
bDeviceProtocol field, 47
bDeviceSubclass field, 47
bEndpointAddress field, 53
bInterfaceClass field, 51
bInterfaceNumber field, 51
bInterfaceProtocol field, 52–53
bInterfaceSubClass field, 51–52
bInterval field, 53–54
BIOS parameter block (BPB)
FAT16, 177–179
FAT32, 181–184
bLength field
configuration descriptors, 49
device descriptors, 47
endpoint descriptors, 53
interface descriptors, 51
string descriptors, 55
block descriptors, SCSI commands, 143
block commands, SCSI, 148–158
block storage devices, definition, 5
bmAttributes field
configuration descriptors, 50
endpoint descriptors, 53
bMaxPacketSize0 field, 47
bMaxPower field, 50
bNumConfiguration field, 49
bNumEndpoints field, 51
bNumInterfaces field, 49
Bootability document, 45–46
boot code, FAT16 file system, 179
boot directory region, FAT16 file system,
180
Index
272
boot sector
FAT16, 176, 178–179
FAT32, 181–184
boot signature, 172–173, 179
BPB (BIOS parameter block)
FAT16, 177–179
FAT32, 181–184
bString field, 55
Bulk-Only Mass Storage Reset, 46, 61, 163
Bulk-Only Transport document, 45–46
bulk transfers, 32
bus current requirements, 50
bus speeds, 31
bus voltage detection, 29
byte order, 168
C
cable plugs, USB, 28
cache, synchronizing, 154
caching mode page, 143, 144
Cache_File_Entry function, 212–217
capacity of media, determining, 152–154
CBI (Control/Bulk/Interrupt) Transport
document, 45–46
CBW (command block wrapper), 56–60
CDB (command descriptor block), 58,
131–132
CD/DVDs
absolute time in Pre-Groove (ATIP),
reading, 159
as mass-storage devices, 8
controllers, 38
program memory area (PMA), reading,
159
table of contents (TOC), reading, 159
CF. See CompactFlash.
CF+ cards, 24
checksum field, 209–210
chip-select input, MultiMediaCard, 80
class, mass storage. See mass-storage class.
classes, MultiMediaCard commands, 99–
101
clock line, MultiMediaCard, 80
closing files, 257–258
Cluster2Sector function, 192
cluster chains, 188–190
clusters
allocating,, 226–227
definition, 167
empty, finding, 198–199
erasing, 224
file allocation table (FAT), 188–190
finding, 195–196
reserving, 225
sizes, 185–186
CMD_PACKET union, 112
command block wrapper (CBW), 56–60
command descriptor block (CDB), 58,
131–132
command response. See SCSI commands.
commands. See MultiMediaCard
commands; requests; SCSI
commands.
command status wrapper (CSW), 60–62
Command Verifier software (USBCV)),
133
CompactFlash
description, 22–23
formats, 24
illustration, 23
interfacing, 23
licensing fees, 24
as mass-storage devices, 22–24
packages, 23
PCMCIA mode, 23
power levels, 23
protocols, 24
True IDE Mode, 23
configuration descriptor, 49–50
Index
273
compliance testing, 133
configuration descriptor, 49–50
configuring an SPI port, 83–85, 88–89
Control/Bulk/Interrupt (CBI) Transport
document, 45–46
controllers
ATA/ATAPI support, 38
for CD/DVDs, 38
choosing, 37–38
CY7C68300B EZUSB AT2LP bridge,
38
firmware options, 38
flash memory support, 37–38
for hard drives, 38
ISP1583 Hi-Speed Universal Serial
Bus peripheral, 38
low-level protocols, 27
PIC18F4550, 39–43
PICmicro, 39–43
serial interface engine (SIE), 27
TUSB6250 USB 2.0 to ATA/ATAPI
Bridge Controller, 38
USB97C202 ATA/ATAPI chip, 38
USB2228 flash memory chip, 37
control requests, 46
control transfers, 32
copy protection, 11
CreateFileEntry function, 238–239
CreateFirstCluster function, 226
CSDRead function, 116–118
CS pin function, 80, 82
CSW (command status wrapper), 60–62
current requirements. See power.
CY7C68300B EZUSB AT2LP bridge, 38
CY4640 Mass Storage Reference Design
Kit, 266–267
cylinders, hard drives, 8–9
Cypress Semiconductor, 38, 266–267
D
data clusters. See clusters.
data_error tokens, 98–99
DataIn pin function, 80, 82
data lines, SPI, 80
DataOut pin function, 80, 82
data packets, 32–33
data reliability, flash memory, 15
data_response tokens, 98–99
data toggle, 33–34
data tokens, 98
data transfers, flash-memory cards
default states, 86
reading a byte, 91–92
registers, 87–88
SPI on PIC18F4550, 86–88
writing a byte, 89–91
date and time fields, directories, 204–205,
220–222
decoding SCSI commands, 160–161
Delayms function, 125–126
delay timer, MultiMediaCard commands,
125–126
descriptors
definition, 34
embedded host problems, 263
fields
bAlternateSettings, 51
bcdDevice, 48
bcdUSB, 47
bConfigurationValue, 49
bDescriptorType
configuration descriptors, 49
device descriptors, 47
endpoint descriptors, 53
interface descriptors, 51
string descriptors, 55
bDeviceClass, 47
bDeviceProtocol, 47
Index
274
bDeviceSubclass, 47
bEndpointAddress, 53
bInterfaceClass, 51
bInterfaceNumber, 51
bInterfaceProtocol, 52–53
bInterfaceSubClass, 51–52
bInterval, 53–54
bLength
configuration descriptors, 49
device descriptors, 47
endpoint descriptors, 53
interface descriptors, 51
string descriptors, 55
bmAttributes
configuration descriptors, 50
endpoint descriptors, 53
bMaxPacketSize0, 47
bMaxPower, 50
bNumConfiguration, 49
bNumEndpoints, 51
bNumInterfaces, 49
bString, 55
configuration descriptors, 49–50
device descriptors, 47–49
endpoint descriptors, 53–54
iConfiguration, 50
idProduct, 48
idVendor, 48
iInterface, 53
iManufacturer, 48
interface descriptors, 51–53
iProduct, 49
iSerialNumber, 49
string descriptors, 54–55
wLANGID[0...n], 55
wMaxPacketSize, 53
wTotalLength, 49
mass-storage class
configuration, 49–50
device, 47–49
endpoint, 53–54
example, 35–36
interface, 51–53
string, 54–55
types of, 46–47
DetectSDCard function, 108
device descriptors field, 47–49
devices, storage. See also devices, USB;
media; specific device types.
block storage, definition, 5
capacity, determining, 152–154
classes, specifying, 47
definition, 1
format capacity, determining, 159
formatting storage, 148–149
hardware requirements, 4–5
implementing, 30–31
logical units, requesting number of,
146
media change detection, 162–163
media types, 3
power status, changing, 154
protocols, 47
reading from, 149–151
ready status, testing, 147–148
requesting information about, 139–
142
required functions, 5
responsibilities, 29–31
sectors, testing, 155
self test, 147
sense data, requesting, 146–147
stream, definition, 5
structure of. See media structure.
UNIT ATTENTION condition, 161–
162
uses for, 1–4
writing to, 155–158
devices, USB
bus voltage detection, 29
Index
275
connecting to hosts, 27
descriptors, mass-storage class, 47–49
endpoint zero, maximum packet size,
47
error checking, 30
On-The-Go (OTG), 27, 31
power from hosts, 28
power management, 30
serial number, 49
vendor ID, 48
directories
attributes, 202–204
checksum field, 209–210
date and time fields, 204–205, 220–
222
directory entries, 205–206
DOS 8.3 file names, 201–202. See also
long file names.
dot and dotdot entries, 205–206
file entries, 202–205
file-name field, 202
first-cluster entry, 205
long file names, 207–211. See also
DOS 8.3 file names.
main entry, 203, 217–219
reading an entry, 212–217
short file names. See DOS 8.3 file
names.
storing an entry, 211–212
subdirectory entries, 207
updating an entry, 219–220
volume label entry, 206–207
directory entries, 205–206
DiskOnKey. See flash drives.
DISK structure, 190
DOS 8.3 file names, 201–202, 210–211.
See also long file names.
dot and dotdot entries, 205–206
drive mechanisms, 8–9
drivers, mass storage device, 38
drivers, mass storage host
embedded, 267
Linux, 77
Windows, 76
duplicate data protection, 33–34
DVDs. See CD/DVDs.
E
ECC (error correcting code), 15
electrical power. See power.
embedded hosts. See also hosts.
commands, 262–263
control transfer problems, 264
conventional hosts versus OTG
devices, 260
CY4640 Mass Storage Reference
Design Kit, 266–267
descriptor problems, 263
device problems, handling, 264–265
enumerating devices, 260–261
EZ-HOST, 266–267
hardware requirements, 5–6
mass-storage functions, 261–263
mass-storage host chip, 267–269
noncompliant devices, 263–266
On-The-Go (OTG) devices, 260
required functions, 6
software for, 267
USBwiz, 267–269
endian, little, 47, 168
endpoint descriptors, 53–54
endpoints
buffer descriptors, PICMicro, 40–43
communications, bulk
preparing to send data, 64–66
receiving data, 67
sending data, 63–64
sending the CSW, 67–68
transfer management, 69–72
Index
276
description, 31–32
endpoint zero, maximum packet size,
47
number of, 51
PIC18F4550 microcontroller, 39–43
enumeration, 28, 260–261
EraseCluster function, 224
erasing
clusters, 224
flash memory, 11, 14
hard drives, 11
mass-storage devices, 11
error checking, 29–30
error codes, 33, 113
error correcting code (ECC), 15
executable code section, MBR, 169
extended partitions, 170–172
EZ-HOST, 266–267
F
FAT12 file system, 167, 185–186. See also
file systems.
FAT16 file system. See also FAT32; file
systems.
BIOS parameter block (BPB), 177–
179
boot code, 179
boot directory region, 180
boot sector, 176, 178–179
boot signature, 179
file allocation table region, 179–180
file and directory data region, 180
formatting, 175–176
media structure, 167
reserved region, 176
FAT32 file system. See also FAT16; file
systems.
backup boot sector, 184
BIOS parameter block (BPB), 181–
184
boot sector, 181–184
file allocation table region, 184–185
file and directory data region, 185
FSInfo structure, 184
reserved region, 181–184
FAT32 File System Specification, 168
FAT_erase_cluster_chain function, 240–
241
FATfindEmptyCluster function, 198–199
FATread function, 192–193
FATReadQueued function, 197–198
FATwrite function, 194–195
fclose function, 257–258
FDMP (flexible disk mode page), 144
fees. See licensing.
FILEallocate_new_cluster function, 227
file allocation table region
FAT16, 179–180
FAT32, 184–185
file and directory data region
FAT16, 180
FAT32, 185
file-backed USB storage gadget (FSG)
driver, 38
FILECreateHeadCluster function, 225
file entries, directories, 202–205
FILEerase function, 241–243
FILEfind function, 231–233
FILEget_next_cluster function, 195–196
file information, file allocation table (FAT),
191
file-name field, directories, 202
FILEopen function, 243–246, 250–257
files
accessing from USB devices, 25
closing, 257–258
clusters
allocating, 226–227
Index
277
erasing, 224
reserving, 225
creating, 238–239
creating directory entries, 234–235
deleting, 239–243
finding, 231–233
finding available entries, 235–238
getting information about, 228–231
opening, 243–246
reading from, 246–250
writing to, 250–257
file systems. See also FAT16; FAT32.
cluster chains, 188–190
cluster sizes, 185–186
file allocation table (FAT)
data clusters, 188–190
description, 188–190
DISK structure, 190
file information, 191
FILE structure, 191
finding empty clusters, 198–199
finding next file cluster, 195–196
logical block address (LBA),
getting, 192
reading from, 192–193, 197–198
sequential reads, 197–198
volume information, 190
writing to, 194–195
hardware solution, 186–187
media structure, 167
selecting, 185–187
Fill_File_Object function, 228–231
FindEmptyEntries function, 235–238
firmware-controlled ports, SPI, 86
first-cluster entry, directories, 205
fixed-format sense data, 137
flash drives
AutoPlay and, 77
caching, 146
description, 3–10
enumerating, 260–261
power, 30
removable media and, 12, 139
SCSI commands, 132, 141, 261–263
USBwiz and, 269
flash memory
accessing, 9
considerations for using, 15–16
controllers supporting, 37–38
data reliability, 15
definition, 13
disadvantages of, 14
erasing, 11, 14
error correcting code (ECC), 15
extending life of, 14–15
Multi-level Cell (MLC), 14
NAND flash, 14
New SLC, 14
NOR flash, 14
Old Single-level Cell (SLC), 14
options for, 15–16
read/write page size, 11
technology, 14
verifying read data, 15
wear leveling, 14–15
flash-memory cards
chip-select input, 80
clock lines, 80
configuring, 83–85, 88–89
configuring the SPI port, 88–89
data lines, 80
data transfer
default states, 86
reading a byte, 91–92
registers, 87–88
SPI on PIC18F4550, 86–88
writing a byte, 89–91
definition, 5
example circuit, 80–83
firmware-controlled ports, 86
Index
278
host programming, 83–86
interface, 79–83
as mass-storage devices, 7–8
Serial Peripheral Interface (SPI), 79–83
signals and power, 80
types, 5
flexible disk mode page (FDMP), 144
floppy drives
bInterfaceSubClass code, 52
FAT12 and, 167
interrupt transfers and, 32
specifications, 46, 53, 132
format command, Windows, 176
formatting
device storage, 148–149
FAT16 file system, 175–176
media, 166–168
FORMAT UNIT command, 148–149
fread function, 247–250
Freescale Semiconductor, 79
FSG (file-backed USB storage gadget)
driver, 38
FSInfo structure, FAT32 file system, 184
functions
Cache_File_Entry, 212–217
Cluster2Sector, 192
CreateFileEntry, 238–239
CreateFirstCluster, 226
CSDRead, 116–118
Delayms, 125–126
DetectSDCard, 108
DOS 8.3 file names, 210–211
EraseCluster, 224
FAT_erase_cluster_chain, 240–241
FATfindEmptyCluster, 198–199
FATread, 192–193. See also
FATReadQueued function.
FATReadQueued, 197–198. See also
FATread function.
FATwrite, 194–195
fclose, 257–258
FILEallocate_new_cluster, 227
FILECreateHeadCluster, 225
FILEerase, 241–243
FILEfind, 231–233
FILEget_next_cluster, 195–196
FILEopen, 243–246, 250–257
Fill_File_Object, 228–231
FindEmptyEntries, 235–238
fread, 247–250
fwrite, 251–257
IncrementTimeStamp, 220–222
IsMeaningfulCBW, 59–60
IsValidCBW, 59
IsWriteProtected, 125
LFNChecksum, 209–210
LoadDirAttrib, 217–219
MediaInitialize, 126–129
memcopypgm2ram, 142
MSDCommandHandler, 160–161
MSDDataIn, 64–66
MSDDataOut, 67
MSDInquiryHandler, 142
MSDModeSenseHandler, 145
MSDReadHandler, 149–153
MSDRequestSenseHandler, 147
MSDTestUnitReadyHandler, 148
MSDWriteHandler, 155–158
OpenSPI, 126–129
PopulateEntries, 234–235
PrepareCSWData, 62
ProcessIO, 69–72
RAMread, 192–193, 247–250
RAMwrite, 194–195
ReadMedia, 91
ReadSPI, 91
ResetSenseData, 138
SectorRead, 118–120
SectorWrite, 120–123
SendCSW, 67–68
Index
279
SendData, 63–64
SendSDCCmd, 113–118, 121–123
SocketInitialize, 108
USBDriverService, 63
Write_File_Entry, 219–220
WriteSPI, 90
fwrite function, 251–257
G
Get Max LUN request, 46
GHI Electronics, 267
Global Engineering documents, 132
H
handshake packets, 32–33
hard drives
ATA with Packet Interface (ATAPI)
interface, 13
capacity, 8–9
controllers, 38
cost effectiveness, 8
cylinders, 8–9
definition, 5
drive mechanisms, 8–9
erasing data, 11
heads, 8–9
interfaces, 13
as mass-storage devices, 8
Parallel AT Attachment (ATA)
interface, 13
physical description, 8–9
platters, 8–9
sectors, 8–9
technology, 13
hard reset, 163
hardware interface, mass-storage, 12
hardware requirements, devices, 4–5
heads, hard drive, 8–9
Hirose connectors, 107
hosts
bus traffic management, 29
connecting to, 27
data exchange, 30
definition, 3, 26
device detection. See enumeration.
device power, 28
and devices, 26–27
embedded. See embedded hosts.
enumeration, 28
error checking, 29
flash-memory cards, accessing, 83–86
master, 3
media change detection, 162–163
MultiMediaCard-bus, 18
multiple, 3–4
responsibilities, 27–29
SPI interface, 18
UNIT ATTENTION condition, 161–
162
I
iConfiguration field, 50
IDE (Integrated Drive Electronics)
interface. See Parallel AT
Attachment (ATA) interface.
idProduct field, 48
idVendor field, 48
iInterface field, 53
iManufacturer field, 48
INCITS Technical Committee, 132
IncrementTimeStamp function, 220–222
index, MultiMediaCard command, 94
informational exception control mode
page, 144
INQUIRY command, 139–142, 262, 265
interface descriptor, 51–53
interrupt transfers, 32
Intoto, 267
Index
280
I/O cards, 16
iProduct field, 49
iSerialNumber field, 49
IsMeaningfulCBW function, 59–60
isochronous transfers, 32
ISP1583 Hi-Speed Universal Serial Bus
peripheral, 38
IsValidCBW function, 59
IsWriteProtected function, 125
J
JumpDrive. See flash drives.
Jungo Ltd., 38, 267
L
LFNChecksum function, 209–210
licensing
CompactFlash, 24
media, 167
MultiMediaCard, 20
Secure Digital (SD) memory card, 22
Linux drivers, 77
little endian, 47, 168
LoadDirAttrib function, 217–219
logical block address (LBA)
converting to byte addresses, 101
description, 10
mass-storage, 46
logical-unit reset, 163
logical units, requesting number of, 146
long file names, 207–211. See also DOS 8.3
file names.
M
macros, PICmicro
mMSDRxIsBusy, 42–43
mMSDTxIsBusy, 42–43
mUSBBufferReady, 42–43
main entry, directories, 203, 217–219
mass-storage class. See also USB (Universal
Serial Bus).
Accept Device Specific Command
(ADSC) request, 46
Autorun support, 77
Bulk Only Mass Storage Reset
requests, 46
commands. See SCSI commands.
control requests, 46
descriptors. See descriptors,
mass-storage class.
Get Max LUN request, 46
Linux drivers, 77
logical block address (LBA), 46
requests, 46
requirements, 34–37, 45–46
specifications, 45–46
Windows drivers, 76–77
mass-storage devices. See devices., storage.
mass-storage hosts. See embedded hosts;
hosts.
master boot record (MBR) sector
boot signature, 172–173
definition, 166–167
detecting, 168
executable code, 169
extended partitions, 170–172
partition table, 169–170
Master In, Slave Out (MISO) pin function,
80, 82
Master Out, Slave In (MOSI) pin function,
80, 82
Master Synchronous Serial Port (MSSP),
86–88
Matsushita Electric Industrial Co., Ltd., 20
MCCI, 38
media. See also devices, specific media types.
addressing methods, 10
change detection, 162–163
changes, informing host of, 162–163
Index
281
copy protection, 11
current technologies, 7
erasing data, 11
formatting, 166–168
hardware interfaces, 12
licensing, 167
logical block address (LBA), 10
parameters, requesting ane selecting,
143–145
prevent/allow user removal, 145–146
removable media and devices, 12
security, 11
selecting, 7–24
table of, 3
write protection, 10
MediaInitialize function, 126–129
media structure
byte order, 168
data clusters, definition, 167
FAT volumes, 167
file systems, 167
formatted media, 166–168
master boot record (MBR) sector
boot signature, 172–173
definition, 166–167
detecting, 168
executable code, 169
extended partitions, 170–172
partition table, 169–170
sectors, definition, 166
memcopypgm2ram function, 142
Microchip Technology, 39, 91
Micro Digital, 38, 267
Microsoft
RMB recommendation, 139
FAT licensing, 167
FAT specification, 168
formatting recommendations, 186
NTFS, 167
mini-A cable plugs, 28
mini-B cable plugs, 28
MISO (Master In, Slave Out) pin function,
80, 82
MLC (Multi-level Cell), 14
MMC. See SCSI commands, multimedia
commands.
MMCA (MultiMediaCard Association),
17
MMCmicro, 17–18
MMCmobile, 17–18
MMCplus, 17–18
mMSDRxIsBusy macro, 42–43
mMSDTxIsBusy macro, 42–43
mode pages, 143–144
MODE SELECT command, 143
MODE SENSE command, 143–145, 263,
265
MOSI (Master Out, Slave In) pin function,
80, 82
Motorola, 79
MSDCommandHandler function, 160–
161
MSDDataIn function, 64–66
MSDDataOut function, 67
MSDInquiryHandler function, 142
MSDModeSenseHandler function, 145
MSDReadHandler function, 149–153
MSDRequestSenseHandler function, 147
MSDTestUnitReadyHandler function,
148
MSDWriteHandler function, 155–158
MSSP (Master Synchronous Serial Port),
86–91
Multi-level Cell (MLC), 14
MultiMediaCard Association (MMCA),
17
MultiMediaCard commands
arguments, 94
block read and write, 102
card information, 124–125
Index
282
classes, 99–101
command and response structures, 112
CSD register, reading, 116–118
delay timer, 125–126
detecting a card, 107–108
error codes, 113
format, 94
index, 94
initializing communication, 123–129
no data transfer, 105
reading data from, 105–106, 118–120
registers, 101
selecting a card, 107–108
sending commands, 101–107, 109–
118
timing, 102–105
used by mass-storage devices, 100–101
writing data from, 106–107, 120–123
MultiMediaCards
classes of, 16
components, 16
form factors, 17–18
hosts, 18
illustration, 17
interfacing with, 17–19
I/O cards, 16
licensing fees, 20
MMCmicro, 17–18
MMCmobile, 17–18
MMCplus, 17–18
MultiMediaCard bus interface, 17–19
packages, 17–18
PIC18F4550 microcontroller host,
81–83
pin functions, 80, 82
tokens
data_error, 98–99
data_response, 98–99
data, 98
Read-only Memory (ROM) class, 16
Read/Write (RW) class, 16
response types
R1b, 96
R1, 94–95
R2, 96–97
versus SD card, 20
specifications, 17
SPI interface, 17–19
timing requirements, 83–85
multimedia SCSI commands, 159
mUSBBufferReady macro, 42–43
N
NAK code, 33, 53–54
NAND flash, 14
New SLC, 14
NOR flash, 14
NTFS, 167
Nucleus real-time operating system, 38
O
Old Single-level Cell (SLC), 14
On-The-Go (OTG) devices, 27, 31, 260
On Time Software, 267
opening files, 243–246
OpenSPI function, 126–129
P
packet ID (PID), 32–33
packets, USB
ACK code, 33
data, 32–33
error codes, 33
handshake, 32–33
maximum size, 53
NAK code, 33
packet ID (PID), 32–33
STALL code, 33, 72–73
token, 32–33
Index
283
page code, 143–144
Parallel AT Attachment (ATA) interface,
13
partition table, 169–170
PCMCIA mode, 23
PDT (peripheral device type), 51, 139–141
pen drives. See flash drives.
peripheral device type (PDT), 51, 139–141
Peripheral Interrupt Enable Register 1
(PIE1), 87
Peripheral Interrupt Request (Flag)
Register 1 (PIR1), 87
Phillips, 38, 159, 267
PIC18F4550 microcontroller
architecture, 39
components, 85
definition, 39
firmware support, 39
Master Synchronous Serial Port
(MSSP), 86–88
as MultiMediaCard host, 81–83
sending/retrieving data, 86–91
USB controller, 39–43
PICmicro microcontrollers, 39–43
PID (packet ID), 32–33
PIE1 (Peripheral Interrupt Enable Register
1), 87
PIR1 (Peripheral Interrupt Request (Flag)
Register 1), 87
platters, hard drives, 8–9
PMA (program memory area), reading, 159
PopulateEntries function, 234–235
port reset, 62, 163
power
bus current requirements, 50
CompactFlash, 23
device bus current requirements, 50
MultiMediaCard, 19, 80
from hosts, 28
managing, 30
SD Card, 21
status, changing, 154
power-on reset, 163
PrepareCSWData function, 62
PREVENT ALLOW MEDIUM
REMOVAL command, 145–146,
265
primary commands, SCSI, 139–148
ProcessIO function, 69–72
product description, 48–49
program memory area (PMA), reading, 159
Q
QIC-157, 52
R
R1b response, 96
R1 response, 94–95
R2 response, 96–97
RAMread function, 192–193, 247–250
RAMwrite function, 194–195
RBC. See Reduced Block Command set.
READ CAPACITY command, 152–154,
262, 266
READ command, 149–151, 262, 265
READ FORMAT CAPACITIES
command, 159, 262
reading
bytes from flash-memory cards, 91–92
CSD register, MultiMediaCard, 116–
118
devices, 149–151
directory entries, 212–217
file allocation table (FAT), 192–193,
197–198
files, 246–250
from media, MultiMediaCard, 105–
106
sectors, MultiMediaCard, 118–120
Index
284
ReadMedia function, 91
Read-only Memory (ROM) class, 16
ReadSPI function, 91
READ TOC/PMA/ATIP command, 159
Read/Write (RW) class, 16
read/write page size, flash memory, 11
READY command, 263
ready status, testing, 147–148
Reduced Block Command set
bInterfaceSubclass, 52
driver, 139
peripheral device type, 141
registers
MultiMediaCard, 101
PIC18F4550, 40–43
release number, 48
removable media and devices, 12
removable media bit (RMB), 139
REPORT LUNS command, 146
requests, 46
REQUEST SENSE command, 146–147,
266
RequestSenseResponse union, 137
reserved region
FAT16, 176
FAT32, 181–184
reserving clusters, 225
reset behavior, SCSI commands, 163
reset recovery, 61–62
ResetSenseData function, 138
response data, copying, 142
response types, MultiMediaCard protocols,
94–97
RMB (removable media bit), 139
ROM (Read-only Memory) class, 16
RW (Read/Write) class, 16
S
SanDisk Corporation, 20
SBC. See SCSI commands, block
commands.
SPC. See SCSI commands, primary
commands.
SCK pin function, 80, 82
SCLK pin function, 80, 82
SCSI commands
block commands, 148–158
block descriptors, 143
command block wrapper (CBW), 56–
60
command set, selecting, 132–135
command status wrapper (CSW), 60–
62
communication on bulk endpoints
preparing to send data, 64–66
receiving data, 67
sending data, 63–64
sending the CSW, 67–68
transfer management, 69–72
decoding, 160–161
embedded hosts, 262–263
examples, 73–76
fixed-format sense data, 137
FORMAT UNIT, 148–149
INQUIRY, 139–142, 262, 265
mandatory, 134
media changes, informing host of,
162–163
mode pages, 143
MODE SELECT, 143
MODE SENSE, 143–145, 263, 265
multimedia commands, 159
optional, 134
port reset, 62
port resets, 163
PREVENT ALLOW MEDIUM
REMOVAL, 145–146, 265
primary commands, 139–148
Index
285
problems with, 264–265
READ, 149–151, 262, 265
READ CAPACITY, 152–154, 262,
266
READ FORMAT CAPACITIES, 159,
262
READ TOC/PMA/ATIP, 159
READY), 263
REPORT LUNS, 146
REQUEST SENSE, 146–147, 266
reset behavior, 163
reset recovery, 61–62
SEND DIAGNOSTIC, 147
sense data, 135–137
setting defaults, 138
specifications, 131–132, 133
STALL, 33, 72–73
START STOP UNIT, 154, 266
status information. See command
status wrapper (CSW).
SYNCHRONIZE CACHE, 154
TEST UNIT READY, 147–148, 263
transparent command set, 51, 52
UNIT ATTENTION condition, 161–
162
unsupported, response to, 135
VERIFY, 155
WRITE, 155–158, 266
SCSI transparent command set, 51, 52
SDC_RESPONSE union, 112
SDI pin function, 80, 82
SDO pin function, 80, 82
SectorRead function, 118–120
sectors. See also logical block address (LBA).
definition, 166
hard drives, 8–9
testing, 155
SectorWrite function, 120–123
Secure Digital (SD) memory card, 20–22
form factors, 20–21
illustration, 21
interfacing, 21
licensing fees, 22
versus MultiMediaCard, 20
packages, 20–21
protocols, 21–22
write protection switch, 21
security, selecting media types, 11
self test, 147
SendCSW function, 67–68
SendData function, 63–64
SEND DIAGNOSTIC command, 147
SendSDCCmd function, 113–118, 121–
123
sense data, 135–137, 146–147
sequential reads, file allocation table (FAT),
197–198
serial interface engine (SIE), 27
serial numbers, 49
Serial Peripheral Interface (SPI), 79–83
Serial Receive/Transmit Buffer Register
(SSPBUF), 87
series-A cable plugs, 28
series-B cable plugs, 28
SFF-8020i, 52, 132
SFF-8070i, 52, 132
short file names. See DOS 8.3 file names.
signals and power, flash-memory cards, 80
Slave Select pin function, 80, 82
SLC (Old Single-level Cell), 14
SMSC (Standard Microsystems
Corporation), 37
smxUSBD USB device stack, 38
SocketInitialize function, 108
SoftConnex, 267
Specification Overview document, 45–46
specifications
Bootability document, 45–46
Bulk-Only Transport document, 45–
46
Index
286
CompactFlash, 24
Control/Bulk/Interrupt (CBI)
Transport document, 45–46
FAT32 File System Specification, 168
Global Engineering documents, 132
mass-storage class, 45–46
MultiMediaCard, 17
SCSI commands, 131–132, 133
SD Card, 22
SFF-8020i, 52, 132
SFF-8070i, 52, 132
Specification Overview 45–46
UFI Command Specification, 46
USB (Universal Serial Bus), 26
USB Mass Storage Compliance Test
Specification, 133
SPI (Serial Peripheral Interface), 17–19,
79–83
SSPBUF (Serial Receive/Transmit Buffer
Register), 87
SSPCON1 (MSSP Control Register), 87,
89–91
/SS pin function, 80, 82
SSPSR (MSSP Shift Register), 87
SSPSTAT (MSSP Status Register), 87, 88–
89
STALL code, 33, 72–73
Standard Microsystems Corporation
(SMSC), 37
START STOP UNIT command, 154, 266
storage devices. See devices.
storage media. See media.
stream devices, definition, 5
string descriptors, 54–55
subdirectory entries, 207
submode pages, 143–144
SYNCHRONIZE CACHE command,
154
T
table of contents (TOC), reading, 159
tape drives, 52
testing devices, 147
TEST UNIT READY command, 147–
148, 263
Texas Instruments, 38
ThumbDrives. See flash drives.
timing, MultiMediaCard commands, 102–
105
toggle, data, 33–34
token formats, 98–99
token packets, 32–33
Toshiba Corporation, 20
transparent command set, SCSI, 51, 52
transactions, USB, 32–33
transfer types, USB
bulk, 32
control, 32
interrupt, 32
isochronous, 32
True IDE Mode, 23
TUSB6250 USB 2.0 to ATA/ATAPI
Bridge Controller, 38
U
uALFAT, 186–187
UFDs (USB flash drives). See flash drives.
UFI Command Specification, 46
UNIT ATTENTION condition, 161–162
USB (Universal Serial Bus). See also
mass-storage class.
buffers. See endpoints.
bulk transfers, 32
bus speeds, 31
compliance tests, 133
connectors, 28
control transfers, 32
data packets, 32–33
Index
287
data toggle, 33–34
data transfers, 32
descriptors, 34
endpoints
buffer descriptors, 40–43
description, 31–32
PIC18F4550 microcontroller, 39–
43
handshake packets, 32–33
interrupt handling, 63
interrupt transfers, 32
isochronous transfers, 32
mass-storage requirements, 34, 37
mini-A cable plugs, 28
mini-B cable plugs, 28
packet ID (PID), 32–33
packets, 32–33
series-A cable plugs, 28
series-B cable plugs, 28
specification, 26
token packets, 32–33
transactions, 32–33
version, 47
USB97C202 ATA/ATAPI chip, 38
USB2228 flash memory chip, 37
USB controllers. See controllers.
USBCV (USB Command Verifier
software), 133
USB DataPump firmware, 38
USB devices. See devices.
USBDriverService function, 63
USB flash drives (UFDs), see flash drives
USB hosts. See hosts.
USB Implementers Forum (USB-IF), 26,
133
USB keys. See flash drives.
USB Mass Storage Compliance Test
Specification, 133
USBwiz, 267–269
V
vendor ID, 48
VERIFY command, 155
volume information, file allocation table
(FAT), 190
volume label entries, 206–207
W
wear leveling, flash memory, 14–15
Windows drivers, 76–77
wiring (cables), 28
wLANGID[0...n] field, 55
wMaxPacketSize field, 53
WRITE command, 155–158, 266
Write_File_Entry function, 219–220
write protection
detecting, 125
selecting media types, 10
switch, Secure Digital (SD) memory
card, 21
WriteSPI function, 90
writing
data from storage, MultiMediaCard
commands, 106–107
to devices, 155–158
to file allocation table (FAT), 194–195
to files, 250–257
sectors, MultiMediaCard commands,
120–123
wTotalLength field, 49

Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.