Atmel SAM series Multimedia Card Interface (MCI) driver — Using MMC/SD cards with block drivers and filesystems


The MultiMedia Card Interface (MCI) driver in the SAM MCI device driver package allows use of MultiMedia Cards (MMC cards) and Secure Digital (SD) flash storage cards within eCos, exported as block devices. This makes them suitable for use as the underlying devices for filesystems such as FAT.

This driver can support boards based on either the SAM9 or SAMA5 processors, where underlying platform HAL support exists.


This driver provides the necessary support for the generic MMC bus layer within the CYGPKG_DEVS_DISK_MMC package to export a disk block device. The disk block device is only available if the generic disk I/O layer found in the package CYGPKG_IO_DISK is included in the configuration.

The block device may then be used as the device layer for a filesystem such as FAT. Example devices are "/dev/mmc0/1" to refer to the first partition on the card, or "/dev/mmc0/0" to address the whole device including potentially the partition table at the start.

Typically, platform HALs provide an option to permit enabling or disabling MCI support.

If the driver is enabled, there are three CDL configuration options:

This indicates that the driver should operate in interrupt-driven mode if possible. This is enabled by default if the eCos kernel is enabled. Note though that if the driver finds that global interrupts are off when running, then it will fall back to polled mode even if this option is enabled. This allows for use of the MCI driver in an initialisation context.
The SAM MCI peripheral allows the MCI clock to be divided down if told to enter power saving mode. This option specifies the divider to use. The driver itself does not implement any power saving - it is up to the application to enable power saving in the MCI control register if it is required.
Some SAM processors have two or even three MCI interfaces. This option selects which of these will be used by the MMC driver. The default for the SAM9263 is to select interface 1, since the PIO lines for interface 0 are shared with SPI0, which will usually be occupied by a dataflash device or card. On the SAM9G45 the pins are not shared, so we select MCI0 by default. The SAMA5D3 permits three MCI devices, and these can be selected here.

Usage notes

MMC/SD cards may only be used in a MMC/SD card slot, and not a dataflash slot. The driver will detect the appropriate card sizes. Hotswapping of cards is supported by the driver, and in the case of eCosPro, the FAT filesystem. Although any cards removed before explicit unmounting or a sync() call to flush filesystem buffers will likely result in a corrupted filesystem on the removed card.

The MMC/SD bus layer will parse partition tables, although it can be configured to allow handling of cards with no partition table.

This driver implements multi-sector I/O operations. If you are using the FAT filesystem, see the generic MMC/SD driver documentation which describes how to exploit this feature when using FAT.