From SEGGER Wiki
Jump to: navigation, search

The Mass Storage Device class (MSD) (also called Mass Storage Class (MSC)) is a USB class protocol which can be used to transfer files to and from storage devices.

As the USB mass storage device class is well standardized, every major operating system such as Microsoft Windows (after Windows 2000), Apple OS X, Linux and many more support it. So therefore an installation of a custom host USB driver is not necessary.

MSD allows SCSI commands to be transmitted to the device via USB. The SCSI commands allow sector-wise access to a storage medium. The storage medium can be a simple RAM-disk, NOR, NAND flash, SD card and so on. Sector-wise access means that the protocol itself does not necessarily know anything about the type of file system used or about any files or folder on the storage.

The protocol simple allows sectors to be read and written. This mechanic results in a light-weight protocol with very little overhead, but without knowing the underlying filesystem it can provide little in terms of file integrity. When a MSD stick is pulled from the host in the middle of a transaction it is possible for a file to end up half written, which at best results in a corrupt file and at worst in a corrupt file system.

The MSD protocol is entirely host-driven, this means that the host always assumes that it has complete control over the storage medium. If an application wants to add new files to the storage medium while the storage medium is connected to the host via MSD this becomes impossible.

Despite it's disadvantages MSD is a solid protocol and virtually any USB host has support for MSD. If the application has to guarantee file integrity even during unexpected removal or needs to add new files to the storage while the device is connected to the host MTP is a good alternative.

Accessing MSD

MSD volume open in Nautilus on Ubuntu 19.04: