File System Component
Version 6.16.6
MDK Middleware for Devices with Flash File System
|
The Memory Card (MC) Control Layer is used when connecting to external memory cards or eMMC devices. It supports data transfer via MCI or SPI, but the data rates are much better using MCI.
In general, the following devices are supported by the File System Component:
Memory Card | Specification |
---|---|
Standard Capacity SD Memory Card (SDSC) | Up to and including 2 GB |
High Capacity SD Memory Card (SDHC) | More than 2GB and up to and including 32GB |
Extended Capacity SD Memory Card (SDXC) | More than 32GB and up to and including 2TB |
MultiMediaCard (MMC) | Up to specification version 4.2 |
Embedded MultiMediaCard (eMMC) | From specification 4.3 |
MC Control Layer uses when memory device is connected via MCI. Depending on the , File System Component can take advantage of certain features. The following table briefly describes how enabled capabilities affect the functionality of the MC Control Layer:
Capability | Functionality |
---|---|
cd_state | Enables device presence detection by pooling the Card Detect (CD) switch state |
cd_event | Enables device presence detection using MCI driver events |
wp_state | Enables write protection detection by pooling Write Protect (WP) switch state |
vdd | Power consumption can be controlled by turning VDD (VCC) power supply on or off |
vccq | Power consumption can be controlled by turning VCCQ power supply on or off |
data_width_4 | Data transfer rate can be increased by using 4-bit data bus |
data_width_8 | Data transfer rate can be increased by using 8-bit data bus |
high_speed | Data transfer rate can be increased by using MCI bus frequencies up to 52MHz |
rst_n | eMMC device can be reset from software using RST_n pin |
With appropriately designed hardware and support from the corresponding MCI driver, MC Control Layer can control memory device power supply voltage:
Depending on the memory device type, appropriate data bus width will be selected:
The MC Control Layer is able to automatically switch to high speed mode for SD cards supporting SD specification version 1.10 or higher (3.3V signaling, bus clock frequency up to 50MHz) and MMC/eMMC devices supporting MMCA specification version 4.2 or higher (3.3V signaling, bus clock frequency up to 52MHz). In order to do so, the high speed mode needs to be supported by the corresponding .
The password protection feature enables the host to lock a card while providing a password, which later will be used for unlocking the card. The password is stored to device internal non-volatile registers and can consist of up to 16 bytes, where each byte can be arbitrary 8-bit value.
Password can be managed by using the function fs_ioc_device_ctrl, with control code fsDevCtrlCodeLockUnlock and structure fsLockUnlock as control code argument. When executing management operation, members of the fsLockUnlock structure must be set as follows:
Setting the password:
When operation executes successfully, new password is stored into device registers.
Reset the password:
When operation executes successfully, password is cleared from device registers.
Lock the card:
When operation executes successfully, data access protection is activated. All read/write accesses are rejected.
Unlock the card:
When operation executes successfully, data access protection is deactivated. All read/write accesses are allowed.
Forcing erase:
When operation executes successfully, all the card data content is erased along with the current password.
To successfully mount locked memory card and gain read/write data access, password management information must be provided from the user application:
User application should only implement callback function fs_mc_lock_unlock when support for memory card password management is required. This function will be called only when mounting a memory card with active password protection.
Many industrial grade eMMC and SD memory devices support health status monitoring system known as S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology). Health Status monitor data is used to anticipate and detect imminent memory failures.
eMMC and SD memory devices use common command (CMD56) to access vendor specific information about memory health status. In order to retrieve relevant information, function fs_ioc_device_ctrl can be used together with control code fsDevCtrlCodeHealthStatus and structure fsHealthStatus as control code argument.
Health status access command behavior is vendor specific but in general the following rules apply:
When function fs_ioc_device_ctrl is called, general command (CMD56) is executed and variable fsHealthStatus::arg is used as command argument. The transfered data gets copied into or from the buffer specified by fsHealthStatus::buf.
File System Component tends to reduce overall power consumption as much as possible, therefore the MC Control Layer will automatically:
eMMC devices (MMCA specification version 4.3 and higher) support CMD5 (Sleep state). To switch between Sleep state and Standby state, use the function fs_ioc_device_ctrl. While in the Sleep state, VCC power supply may be switched off to further minimize the power consumption.
SD memory cards (up to SD specification version 4.10) and MMC devices (up to MMCA specification version 4.2) also support Serial Peripheral Interface (SPI) bus mode as alternative way of communication. When SPI mode is used, MC Control Layer will use to use the underlying hardware.
The advantage of using the memory card in SPI mode is in simplified hardware requirements, but at the cost of performance loss and limited command set. Since SPI consists of only SCLK, MOSI, MISO and nSS communication lines, File System Component provides following callback routines for interfacing Card Detect (CD) and Write Protect (WP) switches:
Callback functions fs_mc_read_cd and fs_mc_read_wp are optional. If they are not implemented by user application, File System Component will assume that memory device in SPI mode is always present and without write protection.
Since software controlled Slave Select line is not always available an alternative way is provided in such case:
User application should only implement callback function fs_mc_spi_control_ss when SPI driver does not provide software controlled Slave Select line.
Reliable communication at high frequencies is a common problem when using SPI bus, since maximum bus frequency can be limited by PCB design. To overcome this problem, FileSystem component implements simple bus frequency adaptation algorithm in order to determine the maximum bus frequency at which it is still possible to communicate with the memory card.
FileSystem component will always attempt to set the highest bus frequency supported by the memory card (usually 25MHz) but if after that the memory card is not accessible anymore I will lower the bus frequency. The adaptation is performed only during memory card initialization procedure.