NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

StarterWare MMCSD Driver

From Texas Instruments Wiki
Jump to: navigation, search

TIBanner.png

Features supported[edit]

  • Support for SD v2.0 standard
  • Support for Standard Capacity and High capacity cards
  • Support for Standard Speed and High Speed cards
  • DMA mode of operation
  • FAT file system support based on FatFs project

Features not supported[edit]

  • No support for MMC standard
  • No support for SDIO

StarterWare MMC/SD Support[edit]

MMC/SD controller, which supports SD and MMC bus protocols for data read/write form/to MMC/SD cards. StarterWare contains software support for MMC/SD controller by providing:

  • MMC/SD controller Device Abstraction Layer
  • MMC/SD protocol abstraction layer
  • MMC/SD controller abstraction layer
  • Application with filesystem enabled
  • Bootloading support via SD cards


MMCSDFrameWork.JPG

MMC/SD controller Device Abstraction Layer[edit]

The MMC/SD controller device abstration layer provides register layer access for the HS MMC/SD controller on the SoC. This layer only contains APIs for register level access.

MMC/SD Abstraction Layer[edit]

Overview[edit]

The MMC/SD Abstraction Layer contains two parts.

  • MMC/SD controller abstraction

The MMC/SD controller abstraction layer provides a method for abstracting the controller specifics from the application and also increase reusability and quick start for the application. Thus, the application need not worry about every step to initialize the controller, need not worry about mapping the MMC/SD commands to be sent to the controller. The controller abstraction layer takes care of the controller specifics

  • MMC/SD protocol abstraction

The MMC/SD protocol abstraction layer provides a method for abstracting the MMC/SD protocol specifics from the application and also increase reusability and quick start for the application. Thus, the application need not worry about each command to be set to the card. The MMC/SD protocol abstraction layer provides APIs that can be used to form and send commands, initialize cards and so on. The MMC/SD protocol abstraction layer then interacts with the MMC/SD controller abstraction layer which maps the MMC/SD commands to controller specifics and sends the command via the controller.


Design[edit]

The MMC/SD abstraction layer is designed two facilitate mainly

  • Abstract the user/application from MMC/SD protocol, to quickstart application development
  • Easy Integration with the lower level controller specifics and support multiple MMC/SD controllers
  • A simple stack like approach for easy enhancements/improvements

Two files make up the abstraction layer

  • mmcsd_proto.c - contains abstraction layer/APIs for the MMC/SD protocol. This layer implements the card identification and initalization sequence, commands for single/multi block read and write, card reset, and so on.
  • hs_mmcsdlib.c - contains abstraction layer/APIs for the HSMMC/SD controller on the SoC. This layer implements a mapping from the MMC/SD protocol to suit the controller register layer. This involves converting command structures to controller register layer format, controller initialization sequence and so on

The MMC/SD abstraction layer contains the following main data objects.

  • mmcsdCardInfo - This holds the card specific details derived from the card specific registers. These details are used to appropriately send commands to the card. For example, from the OCR register details information regading card capacity (standard/high) is derived. This helps in forming the offset address of the memory location to be read/written from/to the card. Bus widths and transfer speeds supported by the card can be used to setup the bus for transfer. This structure also, contains reference pointer to the controller object to which the card is plugged.
  • mmcsdCtrlInfo - This holds the controller specific details that are populated by the user about the underlying controller. Details like the memory base address of the controller, input clock configured and the output clock desired, interrupt mask required to enable/disable default interrupts. It also contains the controller specific method hooks for various operations like, controller initialization, controller data transfer/DMA preparation, card insertion status, command transfer, data transfer, bus widths supported, voltage ranges supported and so on.
  • mmcsdCmd - This holds the command details that are to be sent over the bus. This structure is always populated at the MMC/SD protocol abstraction phase and used by the controller abstraction phase for mapping it to the controller specific register layer details.

Though the abstraction layer is intended to increase reusability of code acrros platforms, owing to the principles of StarterWare, the application still have a major role to play. For example, Interrupt handling is still a part of the application. Also, neither the DAL nor the abstraction layers are concerned/impose any restriction of the mode of data transfer (DMA/Polled), type of DMA of used, interrupt enabling/disabling etc. Thus the application/user - the sole owner and cognizant of these details/methods, is required to provide these details/implemenent these methods. These are provided as part of the callback functions in the controller information.


File system support[edit]

Integration[edit]

A basic FAT file system support is provided based on the FatFs project. The FatFs support library is placed in third_party/fatfs/. fatfs support has two parts.

  1. The core FAT filesystem intrinsics, that is implementation of filesystem calls and filesystem identification/initialization. (found in third_party/fatfs/src/ff.c)
  2. The storage media and SoC specific helper methods that are called by the core layer. (found in third_party/fatfs/port/)

To integrate file system support one will have to provide the port or the media specific helper methods. These, helper methods are prototyped by the fatfs and needs to be defined for any new media support. MMC/SD support is integrated into fatfs as such. The methods currently supported are: disk_initialize - to support initialization of the media during auto-mount disk_read - to read from the media disk_write - to write to the media These methods further call the MMC/SD abstraction layer APIs for required operations.

Multiple media support[edit]

fatfs provides options for multiple media types to be integrated within the system. User perhaps requires USB and MMC media to support the filesystem based access. In such a scenario, the disk_xxx methods need to leverage the drive number (enumerated apriori), parameter. This helps in initializing, reading, writing and IOCTL operations etc specifically for each type of the media.

Programming Sequence[edit]

Following are the steps need to follow to use the MMCSDLIB services in the application.

  1. Instantiate the mmcsdCardInfo and mmcsdCtrlInfo objects.
  2. Initialize the members of mmcsdCardInfo and mmcsdCtrlInfo.
  3. Check for the presence of the card using MMCSDCardPresent().
  4. if card is preasent in the slot, then proceed for the next step, else return error.
  5. Initialize the contrller using MMCSDCtrlInit().
  6. Enable the interrupt(like command completion, command timeout, data timeout and transfer completion) using HSMMCSDIntrEnable()
  7. Execute the shell commands like ls, chdir, cs, pwd, cat etc, which internally calls the MMCSDLIB functions MMCSDCardInit(), MMCSDBusWidthSet(), MMCSDTranSpeedSet() (as part of disk_initialize()), MMCSDReadCmdSend() as part of disk_read(), MMCSDWriteCmdSend() as part of disk_write().
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article StarterWare MMCSD Driver here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article StarterWare MMCSD Driver here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article StarterWare MMCSD Driver here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article StarterWare MMCSD Driver here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article StarterWare MMCSD Driver here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article StarterWare MMCSD Driver here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article StarterWare MMCSD Driver here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article StarterWare MMCSD Driver here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article StarterWare MMCSD Driver here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity