Wiki

This version is outdated by a newer approved version.DiffThis version (17 Jul 2020 05:28) is a draft.
Approvals: 0/1

This is an old revision of the document!


Mobile Storage Interface for MMC/SD

The ADSP-SC5xx processors provide a mobile storage interface (MSI). MSI is a fast, synchronous controller that uses various protocols to communicate with MMC, SD, and SDIO cards to address the growing storage need in embedded systems, handheld and consumer electronics applications requiring low power. The MSI is compatible with the following protocols.

  • MMC (Multimedia Card) bus protocol
  • SD (Secure Digital) bus protocol
  • SDIO (Secure Digital Input Output) bus protocol

All of these storage solutions use similar interface protocols. The main difference between MMC and SD support is the initialization sequence. The main difference between SD and SDIO support is the use of interrupt and read wait signals for SDIO.

Hardware Setup

An ADSP-SC5xx EZ-Board:

  • ADSP-SC589 Ezkit v1.1 and above, or,
  • ADSP-SC573 Ezkit v1.2 (BOM 1.8) and above or,
  • ADSP-SC589 MINI v1.3 and above
  • SC584 processor does not include MMC/SD controller

The SD/MMC card slot is J18 on the SC589/SC573 EZKIT board and is J6 on the SC589 MINI board. This slot accepts full-size SD and MMC cards, or microSD cards with an adapter.


Software Configuration

Package Configuration

Add Bonnie++ package in the filesystem. Bonnie++ is a program for testing filesystem throughput, see www.coker.com.au/bonnie++ for details.

vim build/conf/local.conf
IMAGE_INSTALL_append = " bonnie++"


Configure Linux Kernel

Run “bitbake linux-adi -c menuconfig” to configure the linux kernel.

Enable MSI Support

Device Drivers
	MMC/SD/SDIO card support  --->
 		<*> Synopsys DesignWare Memory Card Interface
 		-*-   Synopsys Designware MCI Support as platform device
		<*>   ADI specific extensions for Synopsys DW Memory Card Interface  

File System Support

If you want to mount an SD card in a particular format, you should compile the Linux kernel with the corresponding file-system first.

Example1:FAT32 SD card, corresponding filesystem is VFAT.  Configuration is shown below:

File systems --->
	DOS/FAT/NT Filesystems  --->
        	[*] VFAT (Windows-95) fs support
		(437) Default codepage for FAT
		(iso8859-1) Default iocharset for FAT

Example2: ext2 SD card, corresponding filesystem is ext2.  Configuration is shown below:

File systems --->
	<*> Second extended fs support
	[*]   Ext2 extended attributes
	[*]     Ext2 POSIX Access Control Lists
	[*]     Ext2 Security Labels 

Build and Load Linux Kernel

Run “bitbake linux-adi -C compile” to compile the linux kernel to generate the zImage and dtb file.

A kernel image and dtb file can now be built and loaded onto the target board.  See SC5xx ezkit Linux quick start guide for details.


Usage of MSI

The most typical use of an SD Card in embedded applications is as a removable storage device (disk) that can be easily taken from the embedded target board. In such contexts, the SD Card installed to the embedded target board is typically already formatted with an MS-DOS file system. The Linux kernel must be specially configured to allow mounting the MS-DOS file system. See part 2 in section 2.1 for details. The mount utility is also needed. Typically,  mount will already be enabled in your busybox configuration.

Insert a pre-formatted card with an MS-DOS (FAT) file system to the SD Card slot on the ADSP-SC5xx

When you boot the zImage on the ADSP-SC5xx, there should be messages similar to the ones shown below. In the below example, Linux has detected an SD Card with a single partition on it:

mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 25000000Hz, actual 25000000HZ div = 1)
mmc0: new SD card at address b368
mmcblk0: mmc0:b368 FFFFF 1.85 GiB   

Mount the MS-DOS file system on the SD Card

This is done as follows:

# mount -t vfat -o sync /dev/mmcblk0p1 /mnt 

Check that the file system has indeed been mounted

Refer to the last line in the below output:

# mount 
rootfs on / type rootfs (rw) 
devtmpfs on /dev type devtmpfs (rw,relatime,size=42740k,nr_inodes=10685,mode=755) 
proc on /proc type proc (rw,relatime) 
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620) 
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777) 
tmpfs on /tmp type tmpfs (rw,relatime,mode=777) 
sysfs on /sys type sysfs (rw,relatime) 
debugfs on /sys/kernel/debug type 
debugfs (rw,relatime) 
/dev/mmcblk0p1 on /mnt type vfat (rw,sync,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)  

Write something to the SD Card

In the below example, we store the current date and time to a log file, although in real-life applications you will probably want to do something more meaningful:

# date > /mnt/log.file 

Verify the written content by reading the log file back

# cat /mnt/log.file
Wed Aug 12 10:29:00 UTC 2015 

Unmount the file system and then extract the card from the SD card slot

Now you can remove the card the from the embedded target board.

# umount /mnt
mmc0: card b368 removed


Test MSI Performance with Bonnie++

1) Test Case 1: Bonnie++ on Ext2

Input the following command on the target board console

root:/> mkfs.ext2 /dev/mmcblk0p1
root:/> mount /dev/mmcblk0p1 /mnt/
root:/> bonnie++ -u root -d /mnt/ 

Result

Using uid:0, gid:0. 
Writing with putc()...done 
Writing intelligently...done 
Rewriting...done Reading with getc()...done 
Reading intelligently...done 
start 'em...done...done...done... 
Create files in sequential order...done. 
Stat files in sequential order...done. 
Delete files in sequential order...done. 
Create files in random order...done. 
Stat files in random order...done. 
Delete files in random order...done. 
Version 1.03e       ------Sequential Output------ --Sequential Input- --Random-                     
		    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- 
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP 
buildroot      300M  2568  70  2780   2  4212   6  3734  97 18000  11  1169  16
                     ------Sequential Create------ --------Random Create--------
                     -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
               files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                  16   958  98 +++++ +++ +++++ +++  1032  98 +++++ +++  2449  99 buildroot,300M,2568,70,2780,2,4212,6,3734,97,18000,11,1169.2,16,16,958,98,+++++,+++,+++++,+++,1032,98,+++++,+++,2449,99  

2) Test Case 2: Bonnie++ on FAT32

Input the following command on the target board console

root:/> mkfs.vfat -F 32 /dev/mmcblk0p1
root:/> mount /dev/mmcblk0p1 /mnt/
root:/> bonnie++ -u root -d /mnt/ 

Result

Using uid:0, gid:0. Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done
Stat files in sequential order...done. 
Delete files in sequential order...done. 
Create files in random order...done. 
Stat files in random order...done. 
Delete files in random order...done.
Version 1.03e       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
buildroot      300M  2414  64  5529   8  4502   8  3715  96 17941  12  92.0   1 
                    ------Sequential Create------ --------Random Create-------- 
                   -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- 
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP 
                 16    12  99 29536 100   156  99    18  99 +++++ +++    41  97 
buildroot,300M,2414,64,5529,8,4502,8,3715,96,17941,12,92.0,1,16,12,99,29536,100,156,99,18,99,+++++,+++,41,97
resources/tools-software/linuxdsp/docs/linux-kernel-and-drivers/mmc/mmc.1594956523.txt.gz · Last modified: 17 Jul 2020 05:28 by Sunny Feng