Saturday, March 25, 2017

Interfacing eMMC

The eMMC is a cheap storage stolution that is very common in embedded systems. It is made of NAND flash memory and a controller.
An eMMC can be used as boot memory when the on-chip ROM code is not sufficient (typically with platforms like linux, windows CE). This is how I had to use it lately, on the popular BeagleBone Black. I struggled a little bit because of the complexity of the protocol (see JEDEC) and because of the differences with the SD card that can also be used as a boot device on the BBB.

SD/SDIO/MMC ...

The first confusing thing comes from the abbreviations related to this type of memory.

  • SD : "Secure Digital", is a non volatile memory developed by the SD Card Association (SDA)
  • SDIO : "Secure Digital Input/Output" is an extension of the SD specification to support IO devices on the SD card slot (GPS, modem, ...)
  • MMC : "MultiMediaCard" is a memory card that can be used by a system that supports SD cards. EMMC is a variant of MMC with a different form factor. Instead of a removable card, it is a soldered chip on the electronic board.

What about SDHC ?

"Secure Digital High Capacity" identifies cards with 4 to 32 Gb storage space.

And UHS ?

"Ultra High Speed" bus. Different classes exist to specify the bus speed characteritics. These classes have nothing to do with the command classes that are used in the protocol.

Connectivity

The communication between host and SD uses 1 command line, [1-8] data lines and 1 clock line. The command line is basically used to read/write the registers of the card controller or to start/stop a read/write operation on the card memory. Data lines are used to read/transmit data following a read/write command.

Protocol

  • Host sends a command serially on command line
  • Card gives a response on the command line
  • Data is transferred on data lines if necessary
  • Card holds the data 0 line low to indicates that it is busy processing the received data
  • If data has been transferred, a CRC status is sent back by the card at the end of transmission on data 0 line

There are 2 types of data transfer:
  • Sequential (only with single data line)
  • Block-oriented

The sequential transfer consists in sending data continuously on data line until a stop command is sent on command line.

The block-oriented transfer data block plus CRC on data lines. The transfer is stopped when a stop command is sent on the command line or when all block have been sent if CMD23 has been used before the start of transmission.


 Data format

A command is a 48 bits frame.


The format of a response frame depends on the command. There are 6 types of responses (R1, R2, ..., R6).


Finally, the data transmission scheme depends on the number of data lines.

Card registers

The following registers can be accessed by the host:

  • OCR : Operating Conditions Register. Defines the voltage profile of the card and provides some status bits.
  • CID : Card Identification Register. Contains manufacturer information as well as a unique identification number (assigned by JEDEC)
  • CSD : Card Specific Data Register. Defines the data format, timings, etc. Some of these values can be modified by issuing a CMD27. There is an extended version of this register for high capacity (SDHC) cards.
  • RCA : Relative Card Address Registers. It carries the card address that is published during identification. 
  • DSR : Driver Stage Register. It can be optionnally used to improve the bus performances.
  • SCR : SD Card Configuration Register. It gives information about the special features implemented into a specific card.

Commands

The JEDEC defines a set of commands that are identified with a number (CMD0, CMD1, ...). Each of these commands achieves a specific action : CMD0 (GO_IDLE_STATE) resets the card to the Idle state. Although this set of command is available for SD and MMC, their usage differs depending on the type of card. For instance, CMD6 (SWITCH) is not used in a similar way. The full list of commands is available in JEDEC document, here are some of them (specified for the eMMC).

What is R1b type of response ?

R1b has exactly the same format as R1. "b" stands for busy and it indicates that a busy signal can be sent on data 0 line, as explained above. This busy signal is however optional.

Booting from eMMC

Depending on the operations done at boot on the SD interface, the card will switch to differents states.

Commonly, boot option 1 is used.
At the end of this diagram, with or without boot enabled, the card enters Standby state.The diagram below show how to switch to Transfer state (or back to Standby state from another state).

Sources:

  • TI AM335x reference manual
  • TN2918 of Micron

Cem SOYDING

Author & Editor

Senior software engineer with 12 years of experience in both embedded systems and C# .NET

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

 
biz.