Linux MMC子系统 - 2.eMMC 5.1总线协议浅析
 2023.10.27    |      Linux MMC子系统    |     AilsonJack    |     暂无评论    |     64 views
By: AilsonJack
Date: 2023-10-27
个人博客: 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;">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总线中,可以有一个Host,多个eMMC设备。总线上的所有通信都是以Host发送一个Command给eMMC开始的,eMMC对于收到的不同Command会做出不同的response,当然了eMMC对于收到的部分Command可以不做response。Host一次只能与一个eMMC设备通信。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在上电启动后,Host会为所有eMMC设备依次分配相对地址(RCA,Relative card Address)。当Host需要和某一个eMMC设备通信时,会先通过RCA选中该eMMC设备,只有被选中的eMMC设备才会响应Host的Command。</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;">在系统上电复位后,Host必须使用eMMC总线协议指定的message来初始化eMMC设备。每个message都由下面的一个标记表示:</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;">command:命令,一个命令是一个开始操作的标记。命令是由Host发给eMMC设备的。一个命令在CMD线上被串行传输。</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;">response:响应,响应是由eMMC设备发送给Host,用于eMMC设备对先前收到命令的回复。一个响应在CMD线上被串行传输。</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:数据,数据可以从Host传输给eMMC设备,也可以从eMMC设备传输给Host。数据在数据线上被传输。用于传输数据的数据线可以是1个(DAT0),4个(DAT0-DAT3)或者8个(DAT0-DAT7)。</section></li></ul><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">对于每一个数据线来说,在一个时钟周期可以传输1位数据,也就是SDR模式(single data rate)。当然了,在一个时钟周期可以传输2位数据,也就是DDR模式(dual data rate)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;"><strong style="font-weight: bold; color: black;">eMMC的读和写命令是按照block为单位进行的。读和写可以是单块或者多块。读和写数据时,数据block后面会跟CRC。</strong></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><figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><figcaption style="margin-top: 5px; text-align: center; color: #888; font-size: 14px;"><img src="/uploads/AilsonJack/2023.10.27/212936964727317.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212936964727317.png&#39;)"/></figcaption></figure><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Read Single Block的命令(CMD17),那么eMMC设备只会发送一个Block的数据(一个Block数据的字节数可以由Host通过CMD16命令设定或者为eMMC设备的默认值)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Read Multiple Block的命令(CMD18),并且在发送CMD18之前,先发送一个SET BLOCK COUNT命令(CMD23)来设置需要读取的数据块数量,那么eMMC设备在传输完指定数量的数据块之后,会自动结束数据传输,不需要Host主动发送Stop Command(CMD12)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Read Multiple Block的命令(CMD18),并且在发送CMD18之前,Host没有发送设置读取数据块数量的命令,那么eMMC设备会持续发送数据,直到Host主动发送Stop Command(CMD12)。</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.27/212936233691541.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212936233691541.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Write Single Block的命令(CMD24),那么eMMC设备只会将后续第一个Block的数据写入的存储器中(一个Block数据的字节数可以由Host通过CMD16命令设定或者为eMMC设备的默认值)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Write Multiple Block的命令(CMD25),并且在发送CMD25之前,先发送一个SET BLOCK COUNT命令(CMD23)来设置需要写入的数据块数量,那么eMMC设备在接收完指定数量的数据块之后,会自动结束数据传输,不需要Host主动发送Stop Command(CMD12)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">如果Host发送的是Write Multiple Block的命令(CMD25),并且在发送CMD25之前,Host没有发送设置写入数据块数量的命令,那么eMMC设备会持续地将接收到的数据写入到存储器中,直到Host主动发送Stop Command(CMD12)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC设备在接收到一个Block的数据后,会进行CRC校验,然后将校验结果通过CRC Token发送给Host。发送完CRC Token后,如果CRC校验成功,eMMC设备会将数据写入到内部存储器,此时DAT0信号会拉低,作为Busy信号。Host会持续检测DAT0信号,直到为高电平时,才会接着发送下一个Block的数据。如果CRC校验失败,那么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设备的通信中,有部分命令是不需要进行数据传输的,还有部分命令不需要eMMC设备回复Response,示意图如下所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212937156287953.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212937156287953.png&#39;)"/></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="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><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协议定义了4种类型的命令,包括:bc、bcr、ac和adtc,这些命令类型的说明如下:</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;">bc:broadcast commands(bc),bc是广播命令,主机发送bc命令给eMMC设备后,eMMC设备不需要回复响应(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;">bcr:broadcast commands with response(bcr),bcr是需要eMMC设备回复响应的广播命令。</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;">ac:addressed(point-to-point) commands(ac),ac是数据线(DAT lines)无数据传输的(no data transfer)点对点(point-to-point)命令。</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;">adtc:addressed(point-to-point) data transfer commands(adtc),adtc是数据线有数据传输的点对点命令。</section></li></ul><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">所有的命令(command)和响应(response)都是在CMD线上进行传输的。发送命令或响应时先发送起始位(Start bit),最后发送结束位(End bit)。</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的Command格式如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212937079214318.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212937079214318.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的Command由48 bits组成,所有的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);">01</code>开始,以<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);">1</code>结尾。所有的eMMC命令都是在CMD线上进行传输的,发送命令时先发送命令的起始位(Start bit),最后发送命令的结束位(End bit)。eMMC命令各个位的说明如下图所示:</p><figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212938865920505.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212938865920505.png&#39;)"/></p><br/></figure><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;">Start Bit:起始位,固定为0,在没有命令传输的情况下,CMD线上的信号保持高电平,当Host将Start Bit发送到总线上时,eMMC设备可以很方便检测到命令的Start Bit(CMD线上的信号由高电平变为低电平),并开始接收Command。</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;">Transmission Bit:传输位,固定为1,该位指示CMD线上数据的传输方向,该位为1,表示CMD线上数据的传输方向为从Host到eMMC设备。</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;">Command Index和Argument:命令索引和命令参数,Command Index和Argument是命令的具体内容,不同的命令Command Index不同,不同的命令Argument也不相同。</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;">CRC:CRC校验值,包含Start Bit、Transmission Bit、Command Index和Argument内容的CRC校验值。</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;">End Bit:结束位,固定为1。</section></li></ul><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的命令被划分成多种不同的类别。每一种命令类别支持一个设备功能的子集。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">Class 0是所有eMMC设备都必须支持的命令类别。其他的命令类别根据具体的设备类型可以是必须支持的,也可以是可选的。</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.27/212938763246845.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212938763246845.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">Host可以通过读取CSD寄存器的CCC [95:84]位域,来了解当前eMMC设备对命令类别的支持情况,对应的位域值为1,就表示该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响应有两种长度的数据包,分别为48 Bits和136 Bits,eMMC响应的格式如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212938453390599.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212938453390599.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的响应由48 bits或者136 bits组成,所有的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);">00</code>开始,以<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);">1</code>结尾。所有的eMMC响应都是在CMD线上进行传输的,eMMC设备发送响应时先发送响应的起始位(Start bit),最后发送响应的结束位(End bit)。</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;">Start Bit:起始位,固定为0,在没有响应传输的情况下,CMD线上的信号保持高电平,当eMMC设备将Start Bit发送到总线上时,Host可以很方便检测到响应的Start Bit(CMD线上的信号由高电平变为低电平),并开始接收响应。</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;">Transmission Bit:传输位,固定为0,该位指示CMD线上数据的传输方向,该位为0,表示CMD线上数据的传输方向为从eMMC设备到Host。</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;">Content:响应的具体内容,不同的响应Content不同。</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;">CRC:CRC校验值,包含Start Bit、Transmission Bit和Content内容的CRC校验值。</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;">End Bit:结束位,固定为1。</section></li></ul><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">eMMC有5种类型的响应,包括:R1,R2,R3,R4和R5。</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">R1</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;">R1响应的数据长度为48 bits,其中[45:40]数据位域表示的是该响应对应命令的编号。[39:8]是一个32位大小的位域,主要用于反应设备的状态信息,具体的设备状态信息内容可以参考eMMC 5.1 spec的<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);">6.13 Device status</code>章节。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212939630108346.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212939630108346.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">R1b和R1完全相同,只是R1b会在数据线DAT0上传输一个可选的busy信号。基于eMMC设备在接收命令之前的状态,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">R2</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;">R2响应的数据长度为136 bits。[127:1]是一个127位大小的位域,该位域将CID寄存器的值作为CMD2和CMD10的响应内容。[127:1]位域也可以将CSD寄存器的值作为CMD9的响应内容。CID和CSD寄存器的[127:1]位作为R2响应内容被传输,CID和CSD寄存器的保留位[0]由于该位的值总是1,因此保留位[0]被R2响应的End bit替换。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212939987926227.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212939987926227.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">R3</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;">R3响应的数据长度为48 bits。[39:8]是一个32位大小的位域,该位域将OCR寄存器的值作为CMD1的响应内容。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/212940998704921.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/212940998704921.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">R4</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;">R4响应的数据长度为48 bits。[39:8]是参数域,该位域包含寻址设备的RCA,要进行读写操作的寄存器地址以及寄存器内容。如果操作成功,参数域中的状态位将被置1。R4响应只作为对CMD39的响应。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221711476155863.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221711476155863.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">R5</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;">R5响应的数据长度为48 bits。如果该响应由Host产生,那么RCA[31:16]位域的值应该为0。R5响应只作为对CMD40的响应。</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221712162413557.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221712162413557.png&#39;)"/></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="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数据块由Start bit、Data、CRC和End bit组成。下面对不同总线宽度和数据速率(Date Rate)下,各个数据块的格式进行一个简单的说明。</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">1位总线宽度 SDR模式</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221712923180080.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221712923180080.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">CRC为Data的16 bitCRC校验值,不包含起始位。</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">4位总线宽度 SDR模式</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221712421262062.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221712421262062.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">各个数据线上的CRC为对应数据线的Data的16 bit CRC校验值。</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">8位总线宽度 SDR模式</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221713841778385.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221713841778385.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">各个数据线上的CRC为对应数据线的Data的16 bit CRC校验值。</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">4位总线宽度 DDR模式</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221713622073930.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221713622073930.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">DDR模式下,在时钟的上升沿和下降沿数据线都会传输数据。在时钟的上升沿传输数据的奇数字节(字节1,3,5 ...),在时钟的下降沿传输数据的偶数字节(字节2,4,6 ...)。 在DDR模式下,每个数据线上有两个相互交织的CRC16,时钟上升沿的CRC比特组成odd CRC16,时钟下降沿的CRC比特组成even CRC16。odd CRC16用于校验该数据线上所有上升沿比特组成的数据,even CRC16用于校验该数据线上所有下降沿比特组成的数据。</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">8位总线宽度 DDR模式</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221714601859037.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221714601859037.png&#39;)"/></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="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 CRC status token</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;">在Host向eMMC设备写数据过程中,eMMC设备接收到Host发送的一个数据块之后,会进行CRC校验,如果校验成功,eMMC设备会在对应的数据线上向Host回复一个Positive CRC status token(&quot;010&quot;),如果校验失败,eMMC设备会在对应的数据线上向Host回复一个Negative CRC status token(&quot;101&quot;)。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在Host从eMMC设备读取数据的过程中,Host接收到eMMC设备发送的一个数据块之后,也会进行CRC校验,但是不论校验成功还是校验失败,Host都不会向eMMC设备回复CRC status token。</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">Positive CRC status token</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221714236526811.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221714236526811.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">Negative CRC status token</span><span class="suffix" style="display: none;"></span></h3><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221715386382717.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221715386382717.png&#39;)"/></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="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 5.1协议定义了7个寄存器:OCR,CID,CSD,EXT_CSD,RCA,DSR和QSR,下面简单的列举常用的6个寄存器。</p><section class="table-container" data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border: 0; border-top: 1px solid #ccc; background-color: white;" class="firstRow"><th style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; font-weight: bold; background-color: #f0f0f0; min-width: 85px;">名称</th><th style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; font-weight: bold; background-color: #f0f0f0; min-width: 85px;">宽度(字节)</th><th style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; font-weight: bold; background-color: #f0f0f0; min-width: 85px;">说明</th><th style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; font-weight: bold; background-color: #f0f0f0; min-width: 85px;">实现</th></tr></thead><tbody style="border: 0;"><tr style="border: 0; border-top: 1px solid #ccc; background-color: white;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">OCR</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">4</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">操作条件寄存器(Operation conditions register)。通过广播命令获取寄存器信息,包含设备的供电类型和寻址模式。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">必须</td></tr><tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">CID</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">16</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">卡识别寄存器(Card IDentification)。包含识别设备的唯一码。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">必须</td></tr><tr style="border: 0; border-top: 1px solid #ccc; background-color: white;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">CSD</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">16</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">卡特定数据寄存器(Card Specific Data)。包含卡操作状态的具体信息。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">必须</td></tr><tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">Extended CSD</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">512</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">扩展卡特定数据寄存器(Extended &nbsp;Card Specific Data)。包含设备的容量和当前模式信息。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">必须</td></tr><tr style="border: 0; border-top: 1px solid #ccc; background-color: white;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">RCA</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">2</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">相对地址寄存器(Relative card address)。在初始化过程中,由主机控制器动态分配的地址。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">必须</td></tr><tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;"><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">DSR</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">2</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">驱动等级寄存器(Driver Stage Register)。配置设备的输出驱动。</td><td style="font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;">可选</td></tr></tbody></table></section><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;">在SDR模式下,Host通过发送CMD19和CMD14可以进行eMMC总线测试过程(Bus testing procedure),测试eMMC接口的硬件引脚连接性。在DDR模式下,不支持总线测试,CMD19和CMD14被认为是非法命令。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">在SDR模式下进行eMMC总线测试时,首先Host发送CMD19给eMMC设备,接着Host在每根数据线上发送特定格式的数据给eMMC。然后,Host发送CMD14给eMMC设备,请求eMMC设备回复翻转的数据。Host可以通过对接收到的翻转数据进行比较,就能知道eMMC接口的引脚引脚连接情况。</p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">1bit总线宽度时,eMMC总线测试的数据格式如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221715536742723.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221715536742723.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">4bit总线宽度时,eMMC总线测试的数据格式如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221716066898897.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221716066898897.png&#39;)"/></p><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;">8bit总线宽度时,eMMC总线测试的数据格式如下图所示:</p><p id="_img_parent_tmp" style="text-align:center"><img src="/uploads/AilsonJack/2023.10.27/221716246742028.png" onclick="preview_image(&#39;/uploads/AilsonJack/2023.10.27/221716246742028.png&#39;)"/></p></section>
欢迎关注博主的公众号呀,精彩内容随时掌握:
热情邀请仔细浏览下博客中的广告,万一有对自己有用或感兴趣的呢。◕ᴗ◕。。
如果这篇文章对你有帮助,记得点赞和关注博主就行了^_^,当然了能够赞赏博主,那就非常感谢啦!
注: 转载请注明出处,谢谢!^_^
暂无评论,要不要来个沙发
发表评论

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