Basic knowledge of USB Mass storage bulk Storage

Source: Internet
Author: User

Http://www.crifan.com/files/doc/docbook/usb_disk_driver/release/htmls/ch02_msc_basic.html

Directory

2.1. USB Mass Storage related protocols
2.1.1. Introduction to USB Mass Storage related protocols
2.1.1.1. USB MSC control/bulk/interrupt (CBI) Transport
2.1.1.2. USB MSC Bulk-only (BBB) Transport
2.1.1.2.1. Why USB MSc in Bulk-onl Y transport is called the BBB
2.1.1.2.2. Why we already have the CBI and get a BBB again
2.1.1.3. USB MSC UFI Command specification
2.1.1.4. USB MSC bootability specification
2.1.1.5. USB MSC Compliance Test specification
2.1.1.6. USB lockable Storage Devices Feature specification
2.1.1.7. USB MSC USB Attached SCSI Protocol (UASP)
2.1.1.7.1. already has a SCSI protocol, for Why do I have to get another uasp
2.1.2. Summary of the relationship between the various protocols of USB MSC
2.1.3. The corresponding relationship between the USB stick and the Class,subclass and protocol
2.1.3.1. Binterfaceclass=0x08=mass Storage
2.1.3.2. BINTERFACESUBCLASS=0X06=SCSI Transparent
2.1.3.3. Binterfaceprotocol=0x50=bulk only Transport
2.2. USB Mass Storage related software implementation

Summary

"Todo" backlog: Linux USB MASS Storage driver flowchart

USB Mass Storage The corresponding hierarchy and what to implement:

Figure 2.1. USB Mass Storage Framework

The relationship between the PC and the USB stick, as well as the physical composition, can be expressed by:

Figure 2.2. PC and USB flash drive

More in-depth analysis, for the internal structure of the ordinary U disk, is a USB physical interface, plus the corresponding control chip ( microcontroller (including NAND flash Controller) + USB device Controller ) and a NAND flash chip:

Figure 2.3. Chip internal structure of PC and U disk

The physical relationship between the PC and the USB stick, with the PS2251-50 USB 2.0 Flash controller as an example, the corresponding logical relationship is:

Figure 2.4. Internal logic block diagram for PC and U disk

about the capacity of U disk, and then explain one more: the size of the general U disk, is corresponding to the NAND flash chip capacity, such as 2GB,4GB,8GB. Of course, such as a 8GB u disk, the interior can also be used in two 4GB NAND flash chip to form.

The abstract logical relationship between a PC and a USB stick can be expressed as:

Figure 2.5. PC and USB MSC devices

Medium, Storage Media, is the NAND flash chip in our example. the control chip in the example is a collection of microcontroller with embedded USB device controller and media controller.

While the USB MSC(Mass Storage Class) Device, from the application domain, can be divided into the following categories:

Figure 2.6. Categories of USB MSC

As in the above example, the usual USB stick, belongs to the FlashDrive, that is, the physical storage of data media with Flash Memory, such as the NAND flash chip in the example, corresponding, Media Controller, the controller of NAND Flash, is responsible for reading and writing data from NAND flash chips.

Firmware (firmware) or hardware (hardware) in a USB MSC device, you must implement these features:

    1. Detects and responds to common USB request and events on the USB bus.
    2. Detects and responds to USB Mass Storage Request for information or actions from USB devices.
    3. Detection and response, SCSI Commandobtained from USB transfer. These industry-standard commands are used to obtain status information, to control device operations , to Read (read block) to the storage media block, and to write (write block) data .

In addition, if the device wants to create/read/write to the storage media, File/folder, then the file system is involved, and the corresponding file system is implemented. Common file systems in embedded systems are FAT16 or FAT32.

2.1. USB Mass Storage related protocols

In addition to its own USB protocol, Mass storage as one of the USB, USB Mass storage own the relevant protocol, the corresponding protocol can go to the official website to download:

http://www.usb.org/developers/devclass_docs/

There are a bunch of protocols about mass storage Related:

    • Mass Storage Class Specification Overview 1.4
    • Mass Storage Bulk Only 1.0
    • Mass Storage Control/bulk/interrupt (CBI) Specification 1.1
    • Mass Storage UFI Command Specification 1.0
    • Mass Storage bootability Specification 1.0
    • Lockable Mass Storage Specification 1.0 and Adopters agreement-lockable Mass Storage IP Disclosure
    • USB attached SCSI Protocol (UASP) v1.0 and adopters agreement

To tell the truth, I see, so many agreements, do not know donkey can read and really understand. However, waiting to understand the relationship between these agreements, you will find that the need for special attention and research of the agreement, not many, at least many agreements can not be too concerned about.

2.1.1. Introduction to USB Mass Storage related protocols

At least a general understanding of the overall system is needed in order to continue the further development of the next step. So, our goal, first is to understand what is the relationship between so many agreements, as well as the specific write USB drive, to see which protocols.

From the terms of the stack of protocols above, we can see that the first:Mass Storage Class Specification Overview 1.4 is an overview of so many protocols, which describes the relationship of each protocol .

The following is the main content of the excerpt, explained as follows:

Some of the protocols related to USB Mass Storage are defined by an organization called USB Mass Storage Class Working Group (CWG), as described above, including some of the following protocols:

    • USB Mass Storage Class control/bulk/interrupt (CBI) Transport
    • USB Mass Storage Class bulk-only (BBB) Transport
    • USB Mass Storage Class Universal floppy Interface (UFI) Command specification
    • USB Mass Storage Class bootability specification
    • USB Mass Storage Class Compliance Test specification
    • USB lockable Storage Devices Feature specification (LSD FS)
    • USB Mass Storage Class USB attached SCSI Protocol (UASP)

For these protocols, let's briefly explain and analyze:

2.1.1.1. USB MSC control/bulk/interrupt (CBI) Transport

We are concerned about the U disk, is the so-called MSC equipment, high-capacity storage devices.

The function of the USB flash drive is data storage. and the corresponding data transmission, with the USB bulk Transfer. The Control transfer is used to send class-specific information and clear Stall. The other aspect of the exchange of information is with the BULK-ONLY protocol.

For the CBI, a substitute for bulk-only can also be used for information exchange, but only for Full-speed floppy disks (floppy drive), and the CBI is not recommended for other new MSC devices .

"Summary" USB MSC control/bulk/interrupt (CBI) is mainly used for floppy equipment , for our concern of the U disk, not to use, do not need to care too much, you can ignore it.

2.1.1.2. USB MSC bulk-only (BBB) Transport

As mentioned above, the bulk-only is the USB device side, here the USB drive and the host side, that is, the ordinary PC, the exchange of information between the protocol.

Bulk only Transport, also referred to as BOT.

2.1.1.2.1. Why bulk-only Transport in USB MSC is called BBB

The bulk-only in USB MSc is often called BBB, which is relative to the CBI described above.

It seems that the CBI of USB MSC is shorthand for Control/bulk/interrupt, but its specific meaning is:

    1. Control

      The control endpoint is used to pass the command block to the device, in addition to the standard USB request, via the class-specific request, that is, the control endpoint transmits the command block

    2. Bulk

      The Bulk in and Bulk out endpoints are used for the transmission of data between hosts and devices (device). That is, bulk is used to transfer data

    3. Interrupt

      The interrupt endpoint is used (device to host) to notify the command to complete. That is, interrupt is used to transmit status information

Therefore, the control/bulk/interrupt of the above USB MSC is simply referred to as the CBI.

And the CBI uses three different endpoints to transmit three types of information, but the difference is that bulk-only transmits all of this information using the Bulk endpoint.

That is, using the Bulk endpoint to transmit command blocks, data, state , and so on, is similar to Control/bulk/interrupt is referred to as the CBI, and Bulk/bulk/bulk is abbreviated as BBB.

The "summary"USB MSC Transfer Protocol is divided into CBI and bot, and bot is also called BBB.

2.1.1.2.2. Why has the CBI, and then a BBB

Since, for a USB MSC device, the communication between the USB device and the USB host has already defined a CBI specification, why do you define a new Bulk-only (BBB)?

My understanding is that it is because, at the beginning of the definition of USB protocol, when the market floppy disk still used a lot of. Therefore, according to the characteristics of floppy device, we define multiple endpoints to transmit different information, that is, control endpoint command block, bulk data transmission, interrupt state information,

and later the development of the computer industry, floppy class settings rarely used, stored data, most of the beginning with flash memory, plus through reasonable planning, you can use the same endpoint, that is, the bulk endpoint, transmission of the above three kinds of information, that is, command block, data, state, so, The only physical implementation of a bulk endpoint, saving the other two endpoints: control endpoint and interrupt endpoint, achieve the physical realization of convenient and save resources, and achieve the same information transmission purposes.

This part understands, waits for further research.

The "summary" USB MSC bulk-only (BBB) protocol is an object that we want to focus on. Because of the direct information interaction between our USB drive and USB host (PC side), this protocol is used primarily.

2.1.1.3. USB MSC UFI Command specification

UFI, that is universal floppy Interface, so look at the name to know, is about the floppy disk. This USB MSC UFI specification defines the UFI command set, which is designed to be used for floppy disks. This collection of UFI commands is based on the collection of SCSI-2 and sff-8070i commands.

"Summary" After reading the above explanation, we understand that we are concerned about the U disk, USB Flash memory type, not floppy disk type, so, here can also not care, temporarily ignore it.

2.1.1.4. USB MSC bootability Specification

Many of the current computer launches are initiated from the MSC mass storage device, such as hard drives . Therefore, this specification is designed so that the operating system can be started from a USB MSC device. The specific content of this specification is mainly defined by the definition of some commands and related data. That is, if you want to enable the operating system to boot from your MSC device, then you will have to implement the corresponding CDB (command descriptor Block, instruction description converts sequential blocks) or data.

"Summary" We are mainly concerned about how the U disk and host data interaction, and do not care whether it can be started from the USB flash drive, so it can not be too concerned about, temporarily ignored.

2.1.1.5. USB MSC Compliance Test specification 

"Summary" does not need to explain, look at the name to know, is a specification of compatibility testing , and we are concerned about the USB drive and host data interaction, the relationship is not small, temporarily ignored.

2.1.1.6. USB lockable Storage Devices Feature specification

"Lockable Storage Devices Feature Specification", referred to as LSD FS. "Lockable" means that it can be locked, that is, locked to prevent other people from accessing or writing, that becomes read-only, and does not allow others to access it. To be blunt is the specification for the security control of USB storage devices .

There is no standard specification for how to control access to USB storage devices, so there is an access control protocol defined here. This protocol enables host hosts or device devices to lock locks or unlock unlock corresponding storage devices .

"Summary" and security storage and permission control of the protocol, we are also here to temporarily do not care, can be ignored.

2.1.1.7. USB MSC USB attached SCSI Protocol (UASP)

"Attached", as the name implies, is attached to one of the above, which is attached to the SCSI protocol, which is the supplemental part of the SCSI protocol. The UASP specification defines how UAS's transmission standards are implemented in USB 2.0 and USB 3.0, and gives some examples and recommended practices.

2.1.1.7.1. There is already a SCSI protocol, why do you want to get another uasp

Now that the corresponding SCSI protocol is already in use, it is used to send the corresponding command to achieve the corresponding function. As a U disk and other applications, the direct implementation of the corresponding protocol, in line with the corresponding specifications, is not also possible to achieve the corresponding function, why also to make another ssci of the subsidiary agreement uasp?

That's because the original BOT (Bulk only Transport), although the protocol is simple to implement, is suitable for use in mass storage devices, but it is like a single thread and cannot perform multiple transmissions concurrently. That is, for a bot, each data transfer by host (transaction) must wait for the device to complete, and then the device returns the corresponding completed status information before it can start the next data transfer . In this case, for the entire data transmission process, it creates a very large (about 20%) waste (overhead).

And for the USB 3.0来 said, the speed from the USB 2.0 480mb/s into 5.0GB/S, and if continue with the bot, then the relatively low CPU performance utilization, USB transmission speed is not too high, for example, there are studies show that 2.4 GHz Core duo™ CPU, The utilization rate is approximately 12%,cpu transfer speed of only about 250mb/s, while the theoretical speed of USB 3.0 is 5.0gb/s=640mb/s, that is, less than half of the theoretical maximum speed.

As a result, this uasp has been supplemented with the SCSI protocol to improve USB 2.0 USB bus utilization, and to take full advantage of the full duplex capability of USB 3.0, which allows the transfer speed to reach approximately 400mb/s. The implementation of this new protocol uasp also requires the corresponding new host-side software, the new device-side firmware (Firmware).

For backward compatibility of devices, the device supports both bot and UAS. This uasp specification defines how the corresponding UAS protocol is implemented on USB 2.0 and USB 3.0.

When both the host and device implement this UAS protocol, host will access the device via the host's SCSI software stack, and the USB interface will be functionally turned into another SCSI in the host stack Host Adapter. The device needs to implement the SAM4 architecture model so that host can query the commands in the (Queue) device as well as the corresponding performance improvements.

"Summary" in order to overcome the shortcomings of the old bot protocol bus utilization is not high , so define a new UAS protocol, namely UASP, to improve the efficiency of USB transmission, improve USB speed . Of course, we are here in order to achieve the function of the USB stick, of course, the higher the performance of the better, so, this agreement is also we should study.

2.1.2. Summary of the relationship between the various protocols of USB MSC

To illustrate the relationship between the various protocols of USB Mass storage, we will first give these protocols a number:

USB Mass Storage Class control/bulk/interrupt (CBI) Transport

USB Mass Storage Class bulk-only (BBB) Transport

USB Mass Storage Class Universal floppy Interface (UFI) Command specification

USB Mass Storage Class bootability specification

USB Mass Storage Class Compliance Test specification

USB lockable Storage Devices Feature specification (LSD FS)

USB Mass Storage Class USB attached SCSI Protocol (UASP)

The direct use of graphs represents the relationship between the various protocols of USB MSC, which is more intuitive:

Figure 2.7. USB Storage Class Protocol Relation


For example, the function of our USB drive is mainly to read and write data, and there are two main kinds of communication between device and host:

    1. CBI: Mainly used for floppy equipment, so new devices are seldom used in this Protocol
    2. Bot:bulk-only Transport, also known as BBB (Bulk/bulk/bulk),

And for BOT/BBB, for it to improve the USB bus utilization, improve the USB speed, is the corresponding uasp protocol, so called uasp as the enhanced version of the bot protocol.

Talk about the protocol, and then look at the end of the USB device.

USB device side, according to the internal data storage of different media types, there are two kinds of:

    1. One is the floppy device, the application is Ufi Command Set;
    2. And the other, is our common flash Memory, corresponding to the SCSI Command Set.

The SCSI protocol itself is there, so it is not part of the USB MSC protocol category, that is, SCSI is just a protocol related to USB MSC.

Similarly, for USB device itself, if you need some other features, such as bootable , compatibility, lockable, etc., then the corresponding specification is

USB Mass Storage Class bootability specification

USB Mass Storage Class Compliance Test specification

USB lockable Storage Devices Feature specification (LSD FS)

"Summary" To this point, the relationship between the various protocols and specifications, it is easy to understand. Of all the protocols above, of which we are concerned, only three specifications, as in the previous diagram, have been identified with asterisks:

    1. The most concern is the bot, which is the protocol for data communication between host and device.

      ★★★② USB Mass Storage Class bulk-only (BBB) Transport

    2. Second, the protocol that needs to be concerned with the communication between USB device internal and data storage media

      scsi-small computer System Interface

    3. Finally, if you want to achieve better performance, you need to be concerned about the upgraded version of bot

      ★⑦ USB Mass Storage Class USB attached SCSI Protocol (UASP)

2.1.3. The corresponding relationship between the USB stick and the Class,subclass and protocol

The corresponding, understand USB know that each device descriptor, there are corresponding to the following fields:

    • Binterfaceclass
    • Binterfacesubclass
    • Binterfaceprotocol

corresponding to the USB class,subclass,protocol.

And for us here the U-disk:

2.1.3.1.Binterfaceclass=0x08=mass Storage

Class is the USB Mass Storage class,

2.1.3.2. BINTERFACESUBCLASS=0X06=SCSI Transparent

Subclass, the following list is supported:

Figure 2.8. Subclass Codes Mapped to Command Block specifications

2.1.3.3. Binterfaceprotocol=0x50=bulk only Transport

Protocol, the following list is supported:

Figure 2.9. Mass Storage Transport Protocol


In terms of the supported protocols defined in these specifications above, the few that are added to the color box, which we have explained earlier, require the protocols we care about and study, namely SCSI,BBB and UAS.

Basic knowledge of USB Mass storage bulk Storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.