A string descriptor contains descriptive text. Support for most string descriptors is optional, but every mass-storage device that uses the bulk-only transport protocol must have a string descriptor that contains a serial number. The serial number must have at least 12 characters and must contain only characters in the range 0–9 (0030h–0039h) and A–F (0041h–0046h). Note that lower-case text, hyphens, and many other characters are not allowed. The last 12 characters must be different from the last 12 characters of the serial number of any device with the same values in the idVendor and idProduct fields in the device descriptor. The serial number enables a host to retain properties such as the drive letter and access policies after a user moves a device to another port or attaches multiple devices with the same Vendor ID and Product ID.
The device descriptor’s iSerialNumber field contains an index to the string descriptor containing the serial number.
Table 3-5 shows the fields in a string descriptor. Here are more details about the fields and how they’re used in a mass-storage device:
bLength. The number of bytes in the descriptor.
bDescriptorType. The constant STRING (03h).
wLANGID[0...n] or bString. When a host requests a String descriptor, the low byte of the wValue field in the Setup stage is an index value. If the index value is zero, the host is requesting language IDs. If the index value is greater than zero, the host is requesting the string descriptor with that index.
String descriptor zero contains one or more 16-bit language ID codes that indicate the languages that the strings are available in. The code for U.S. English is 0409h. This is likely to be the only code supported by an operating system. The wLANGID value must be valid for any of the other strings to be valid. Devices that return no string descriptors must not return an array of language IDs. The USB-IF’s web site has a list of defined USB language IDs.
For index values of 1 and higher, the bString field contains a Unicode string. With a few exceptions, ANSI character codes 00h through 7Fh correspond to Unicode values 0000h through 007Fh. For example, a product string for a product called “Gizmo” would contain five 16-bit Unicode values that represent the characters in the product name:
0047 0069 007A 006D 006F
In the string descriptor, each Unicode character transmits LSB first:
47 00 69 00 7A 00 6D 00 6F 00
The strings are not null-terminated. The bLength field for a string descriptor that contains a string equals (2 * number of characters in string) + 2.