Linux MMC子系统 - 1.eMMC简介
 2023.10.21    |      Linux MMC子系统    |     AilsonJack    |     暂无评论    |     65 views
By: AilsonJack
Date: 2023-10-21
个人博客: http://www.only2fire.com/
<section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;"><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">前言</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">下面首先简单的介绍了MMC,SD和SDIO,对这些名词有个概念即可。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">从本文开始会重点讲讲eMMC相关的内容(<code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgb(239, 112, 96);">Linux MMC子系统</code>系列文章介绍的eMMC协议为:<strong style="font-weight: bold; color: black;">eMMC 5.1协议</strong>),对eMMC相关的知识有了一定的了解之后,后续文章也会对Linux的MMC子系统做一个介绍,包括MMC子系统的初始化过程,MMC host驱动与host设备是如何匹配的,MMC host驱动的基本框架,MMC驱动和MMC卡设备是如何关联起来的,MMC子系统是如何实现块设备驱动的等等。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">对于MMC卡,SD卡或者SDIO接口的设备,<code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgb(239, 112, 96);">Linux MMC子系统</code>同样适用。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">好了,废话不多说,下面开始本文的内容吧。</p><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">MMC SD SDIO介绍</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="prefix" style="display: none;"></span><span class="content">MMC</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">多媒体卡(MMC)全称Multi Media Card,是由西门子公司和SanDisk公司于1997年推出的多媒体记忆卡标准。MMC卡尺寸为32mm x 24mm x 1.4mm,它将存储单元和控制器一同做到了卡上,这种携带方便、可靠性高、重量轻的数据载体一经推出,市场占有率不断上升,广泛应用于移动电话,数码相机,MP3等产品。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">MMC卡具有MMC和SPI两种工作模式,MMC模式是默认工作模式,具有MMC的全部特性。而SPI模式则是MMC协议的一个子集,主要用于低速系统。</p><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="prefix" style="display: none;"></span><span class="content">SD</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">SD卡(Secure Digital Memory Card)是一种基于半导体快闪存记忆器的新一代记忆存储设备。SD卡是由松下、东芝和SanDisk公司于1999年8月共同开发的新一代记忆卡标准,已完全兼容MMC标准。SD卡比MMC卡多了一个进行数据著作权保护的暗号认证功能。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">SD卡尺寸为32mm x 24mm x 2.1mm,长宽和MMC卡一样,只是比MMC卡厚了0.7mm,以容纳更大容量的存储单元。SD卡与MMC卡保持向上兼容,也就是说,MMC卡可以被新的设有SD卡插槽的设备存取,但是SD卡却不可以被设有MMC插槽的设备存取。</p><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="prefix" style="display: none;"></span><span class="content">SDIO</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">SDIO全称为Secure Digital Input and Output,中文名称为:安全数字输入输出接口。SDIO是在SD标准上定义的一种外设接口,它使用SD的I/O接口来连接外围设备,并通过SD上的I/O数据接口与这些外围设备传输数据。现在已经有很多手持设备支持SDIO接口,而且许多SDIO外设也被开发出来,目前常见的SDIO外设有:WIFI Card、GPS Card、 Bluetooth Card等等。</p><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">eMMC介绍</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC卡全称为Embedded Multi Media Card,是MMC协会所制定的内嵌式存储器标准规格。通俗点讲,eMMC就是一个类似于SD卡一样的存储芯片。eMMC主要应用于智能手机和平板电脑等产品。eMMC在封装中集成了一个控制器,提供标准接口来管理闪存,使得产品开发过程中不再需要考虑NAND&nbsp;Flash兼容性问题和管理问题,让产品开发人员能够专注于产品开发,缩短产品推向市场的时间。</p><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">eMMC整体结构</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC的整体结构如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/104819347271937.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/104819347271937.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC主要由设备控制器和存储阵列组成。设备控制器主要提供主机接口和存储管理功能。</p><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="prefix" style="display: none;"></span><span class="content">eMMC主机接口</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">HOST和eMMC之间的接口连接如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/110110977020602.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/110110977020602.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC与HOST之间的通信涉及的信号线描述如下:</p><ul data-tool="mdnice编辑器" style="list-style-type: disc;" class=" list-paddingleft-2"><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">CLK:时钟线上的每个时钟周期,意味着命令线上传输了1bit命令,或者数据线上完成了1bit或者2bit的数据传输。时钟频率的范围为:0~最大时钟频率。</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">CMD:该信号线主要用于传输HOST到eMMC的command和eMMC到HOST的response。</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">DAT0~DAT7:用于传输数据的8bit数据线。在上电或者复位以后,仅仅只有DAT0数据线可以用于数据传输。可以通过eMMC主机控制器来配置eMMC的数据总线位宽,eMMC支持的数据线宽度有:1bit(DAT0),4bit(DAT0~DAT3),8bit(DAT0~DAT7)。</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">Data Strobe:该信号是从eMMC设备输出给Host的时钟信号,频率和CLK信号相同,用于Host进行接收数据的同步。该信号只在HS400模式下使用,启用后可以提高数据传输的稳定性,省去总线tuning过程。</section></li></ul><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">HOST和eMMC之间的通信都是以HOST发送一个Command给eMMC开始的,eMMC对于收到的不同Command会做出不同的response,当然了eMMC对于收到的部分Command可以不做response。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">聊了这么久的eMMC,到底eMMC长什么样,大多数的eMMC芯片一般是黑色的外观,来欣赏下某厂商的eMMC芯片外观图:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/104818080701321.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/104818080701321.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">大多数的eMMC芯片一般采用BGA封装,下图是某厂商的BGA封装的eMMC芯片引脚图:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/104819209496699.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/104819209496699.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC接口各个引脚的输入输出类型以及相关描述可以参考下图进行理解:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/104820263770611.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/104820263770611.png&#39;)"/></p><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="content">eMMC存储阵列</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC的存储阵列是由非易失性的存储器组成,目前,绝大多数eMMC芯片内部的存储器都是由Nand Flash组成的。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在智能手机或者其他嵌入式设备中,可以使用eMMC的存储阵列来存放操作系统,应用数据等信息。</p><h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;"><span class="prefix" style="display: none;"></span><span class="content">eMMC存储管理</span><span class="suffix" style="display: none;"></span></h3><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC芯片内部的设备控制器具有存储管理功能,主要用于对Nand Flash的管理,包括:擦写均衡,坏块管理,ECC校验等。相比于直接将NAND Flash连接到Host端,采用eMMC芯片屏蔽了NAND Flash的物理特性,可以减少Host端软件的复杂度,让Host端专注于上层业务,省去对NAND Flash进行特殊的处理。同时,eMMC通过使用Cache、Memory Array等技术,在读写性能上也比NAND Flash要好很多。</p><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">eMMC寻址</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">以前实现的eMMC协议(比如eMMC 4.1协议)采用的是32位域的字节寻址。这种寻址机制限制了eMMC的最大容量为2GB。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">为了支持更大容量的eMMC,后续的eMMC协议(比如eMMC 5.1协议)增加了sector寻址方式(1 sector=512B)。容量大于2GB的eMMC,都是采用sector寻址的方式。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">为了确定eMMC的寻址模式,主机可以读取eMMC的OCR寄存器,通过OCR寄存器的bit[30:29]可以知道eMMC的寻址模式。</p><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; border-bottom: 2px solid rgb(239, 112, 96); font-size: 1.3em;"><span class="prefix" style="display: none;"></span><span class="content" style="display: inline-block; font-weight: bold; background: rgb(239, 112, 96); color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;">eMMC速率模式</span><span class="suffix"></span><span style="display: inline-block; vertical-align: bottom; border-bottom: 36px solid #efebe9; border-right: 20px solid transparent;"> </span></h2><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">随着eMMC协议的不断更新,eMMC总线的速率越来越高。为了兼容旧版本的eMMC,所有eMMC在上电启动或者Reset后,都会先进入兼容速率模式(Backwards Compatibility with legacy MMC card)。在完成对eMMC的初始化后,Host可以通过特定的流程,让eMMC进入其他高速率模式,目前支持以下几种速率模式。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.21/104820338690429.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.21/104820338690429.png&#39;)"/></p><blockquote class="multiquote-1" data-tool="mdnice编辑器" style="border: none; display: block; font-size: 0.9em; overflow: auto; overflow-scrolling: touch; border-left: 3px solid rgba(0, 0, 0, 0.4); color: #6a737d; padding-top: 10px; padding-bottom: 10px; padding-left: 20px; padding-right: 10px; margin-bottom: 20px; margin-top: 20px; border-left-color: rgb(239, 112, 96); background: #fff9f9;"><p style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;">Extended CSD寄存器的HS_TIMING[185],可以配置总线速率模式。</p><p style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;">Extended CSD寄存器的BUS_WIDTH[183],可以配置配置总线宽度和Data Strobe。</p></blockquote><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在一个时钟周期内,DAT0~DAT7信号线上传输1个比特时,就是SDR(Single Data Rate)模式。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在一个时钟周期内,DAT0~DAT7信号线上传输2个比特时,就是DDR(Double Data Rate)模式。</p></section>
欢迎关注博主的公众号呀,精彩内容随时掌握:
热情邀请仔细浏览下博客中的广告,万一有对自己有用或感兴趣的呢。◕ᴗ◕。。
如果这篇文章对你有帮助,记得点赞和关注博主就行了^_^,当然了能够赞赏博主,那就非常感谢啦!
注: 转载请注明出处,谢谢!^_^
转载请注明来源: 本文链接:  By: AilsonJack
Linux MMC子系统 - 1.eMMC简介  |  说好一起走
暂无评论,要不要来个沙发
发表评论

 
Copyright © 2015~2023  说好一起走   保留所有权利   |  百度统计  蜀ICP备15004292号