Using the MSC Demo Application

The MSC demo consists of two parts:

  • Any file explorer application (Windows, Linux, Mac) from a USB host. For instance, in Windows, mass-storage devices appear as drives in My Computer. From Windows Explorer, users can copy, move, and delete files in the devices.
  • The USB Device application on the target board which responds to the request of the host.

µC/USB Device allows the explorer application to access a MSC device such as a NAND/NOR Flash memory, RAM disk, Compact Flash, Secure Digital etc. Once the device is configured for MSC and is connected to the PC host, the operating system will try to load the necessary drivers to manage the communication with the MSC device. For example, Windows loads the built-in drivers disk.sys and PartMgr.sys. You will be able to interact with the device through the explorer application to validate the device stack with MSC.

Note that the demo application provided by Micrium is only an example and is intended to be used as a starting point to develop your own application.

MSC Device Application

On the target side, the user configures the application through the app_usbd_cfg.h file. Table - Application Preprocessor Constants lists a few preprocessor constants that must be defined.

Table - Application Preprocessor Constants
Preprocessor ConstantsDescriptionDefault Value
APP_CFG_USBD_ENEnables µC/USB Device in the application.DEF_ENABLED
APP_CFG_USBD_MSC_ENEnables MSC in the application.DEF_ENABLED


If RAMDisk storage is used, ensure that the associated storage layer files are included in the project and configure the following constants located in app_usbd_cfg.h and listed in Table - RAM Disk Preprocessor Constants.

Table - RAM Disk Preprocessor Constants
Preprocessor ConstantsDescriptionDefault Value
USBD_RAMDISK_CFG_NBR_UNITSNumber of RAMDISK units.1
USBD_RAMDISK_CFG_BLK_SIZERAMDISK block size.512
USBD_RAMDISK_CFG_NBR_BLKSRAMDISK number of blocks.4096
USBD_RAMDISK_CFG_BASE_ADDRRAMDISK base address in memory. This constant is used to define the data area of the RAMDISK. If it is defined with a value different from 0, RAMDISK’s data area will be set from this base address directly. If it is equal to 0, RAMDISK’s data area will be represented as a table from the program’s data area.0


If µC/FS storage is used, ensure that the associated µC/FS storage layer files are included in the project and configure the following constants listed in Table - uC/FS Preprocessor Constants:

Table - uC/FS Preprocessor Constants
Preprocessor ConstantDescriptionDefault Value
APP_CFG_FS_ENEnables µC/FS in the applicationDEF_ENABLED
APP_CFG_FS_DEV_CNTFile system device count.1
APP_CFG_FS_VOL_CNTFile system volume count.1
APP_CFG_FS_FILE_CNTFile system file count.2
APP_CFG_FS_DIR_CNTFile system directory count.1
APP_CFG_FS_BUF_CNTFile system buffer count.(2 * APP_CFG_FS_VOL_CNT)
APP_CFG_FS_DEV_DRV_CNTFile system device driver count.1
APP_CFG_FS_WORKING_DIR_CNTFile system working directory count.0
APP_CFG_FS_MAX_SEC_SIZEFile system max sector size.512
APP_CFG_FS_RAM_NBR_SECFile system number of RAM sectors.8192
APP_CFG_FS_RAM_SEC_SIZEFile system RAM sector size.512
APP_CFG_FS_NBR_TESTFile system number of tests.10
APP_CFG_FS_IDE_ENEnables IDE device in file system.DEF_DISABLED
APP_CFG_FS_MSC_ENEnables MSC device in file system.DEF_DISABLED
APP_CFG_FS_NOR_ENEnables NOR device in file system.DEF_DISABLED
APP_CFG_FS_RAM_ENEnables RAM device in file system.DEF_ENABLED
APP_CFG_FS_SD_ENEnables SD device in file system.DEF_DISABLED
APP_CFG_FS_SD_CARD_ENEnables SD card device in file system.DEF_ENABLED


MSC Host Application

To test the µC/USB-Device stack with MSC, the user can use for instance the Windows Explorer as a USB Host application on a Windows PC.

When the device configured for the MSC demo is connected to the PC, Windows loads the appropriate drivers as shown in Figure - MSC Device Driver Detection on Windows Host.

Figure - MSC Device Driver Detection on Windows Host

MSC Device Driver Detection on Windows Host


Open a Windows Explorer and a removable disk appears as shown in Figure - MSC Device on Windows 7 Explorer. If the MSC demo is modified to configure a mass storage device composed of multiple logical units as shown in Listing - MSC Initialization, Windows Explorer will show a removable disk icon per logical unit.

Figure - MSC Device on Windows 7 Explorer

MSC Device on Windows 7 Explorer


When you open the removable disk, if it is the first time the MSC device is connected to the PC and is not formatted, Windows will ask to format it to handle files on the mass storage. When formatting, choose the File System you want. In embedded systems, the most widespread file system is the FAT.

If the mass storage device is a volatile memory such as a SDRAM, every time the target board is switched off, the data of the memory is lost, and so is the file system data information. As a result, the next time the target is switched on, the SDRAM is blank and reconnecting the mass storage to the PC, you will have to format again the mass storage device.

Once the device is correctly formatted, you are ready to test the MSC demo. Below are a few examples of what you can do:

  • You can create one or more text files.
  • You can write data in these files.
  • You can open them to read the content of the files.
  • You can copy/paste data.
  • You can delete one or more files.

All of these actions will generate SCSI commands to write and read the mass storage device.

The MSC class supports the removable storage eject option offered by any major operating systems. Figure - Windows Removable Storage Eject Option Example shows an example of Eject option available in Windows Explorer. When you right-click on the removable disk, you can choose the Eject option. Eject option will send to the mass storage device some special SCSI commands. The mass storage device will stop the access to the storage. Hence, Windows will modify the removable disk icon by removing the size information. If you double-click on the icon after the eject operation, Windows will display a message saying that no disk is inserted. After an eject operation, you cannot reactivate the removable media. The only way is to disconnect the device and reconnect it so that Windows will re-enumerate it and refresh the Windows explorer's content.

Figure - Windows Removable Storage Eject Option Example

Windows Removable Storage Eject Option Example