Updated USB MSC Function

Belcarra’s USB Device stack includes a Mass Storage (MSC) function. This allows an embedded device using the USB Framework to emulate a Mass Storage device either as a standalone function or as part of a composite configuration.

The Belcarra MSC solution was updated to increase performance and extend its feature set:
  • More efficient use of the Block IO system for higher throughput
  • Support for mulitple LUN’s (storage volumes)
  • Management (API) allowing things like detecting individual LUN changes
  • Virtual CDROM support (map an ISO image)
  • Read-only volume support -- (Management API allows dynamic change)

Extensive testing has been done to ensure reliability and improve performance using the industry standard
tools; the USB IF Mass Storage command verifier tool, Microsoft WLK and CrystalDiskMark tool.

Management API

The MSC system allows 4 LUN’s (storage units). There are management operations for individual storage units and for the system as whole.

For each LUN, a storage volume is mounted, optionally with the read-only flag set. This associates a LUN with back store. This can happen before or after a USB connection is established with a host.

The following operations are supported
  • determine (without blocking) whether a USB connection is established
  • wait (block) until a USB connection is established
  • wait (block) until a user either ejects a LUN or removes the cable. Afterwards, status queries can determine what has happened. This allows individual LUN’s to be temporarily closed while the others remain active. 
  • enable r/w on a read-only LUN (disabling a r/w LUN is unsafe
Virtual CDROM

For auto-installation of software (especially drivers), a virtual CDROM is useful. This differs from a read-only LUN in small details.

The CDROM device type is detected by a SCSI command after enumeration. The data transport is exactly like a virtual hard disk, but the data should be in ISO9660 format.

The CD image is placed in an ordinary file. The losetup command creates a virtual (read-only) device (dev/loop0) from the image, and this device is mounted to MSC
Note: a virtual CDROM must be the only LUN. This is no problem with Belcarra USB using one instance of MSC with writable back-store and a second instance for a virtual CDROM.
During Enumeration, device returns cdrom type to host to indicate it is a cdrom. then losetup a cd Image file to a loop device /dev/loop0, next mount the loop device to msc. At this point, host can see the content of cd image.


Used in a standalone or composite configuration the MSC function provides a reliable way to provide a virtual mass storage device as part of your embedded device. It is designed to minimize resource usage while still providing for good throughput.