qq7643066 发表于 2022-6-11 14:44

嵌入式RK3399/RK3568 PCIE接口的M2固态硬盘调式

<p>一、硬件平台<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
RK3399+NVME固态硬盘<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
<ignore_js_op style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial"></ignore_js_op><br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
二、软件调式过程<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
1、在dev/block下有识别到nvme<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
<ignore_js_op style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial"></ignore_js_op><br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
2、格式化 挂载之后 下df-h 看到已经识别到硬盘容量<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
格式化命令:mkdosfs /dev/block/nvme0n1p1<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
挂载命令:busybox mount /dev/block/nvme0n1p1 /data/nvme<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
<ignore_js_op style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial"></ignore_js_op><br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
加log分析</p>

<div align="left">void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {<br style="overflow-wrap:break-word; word-break:break-all" />
std::lock_guard&lt;std::mutex&gt; lock(mLock);</div>

<p>if (mDebug) {<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOG(VERBOSE) &lt;&lt; &quot;----------------&quot;;<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOG(VERBOSE) &lt;&lt; &quot;handleBlockEvent with action &quot; &lt;&lt; (int) evt-&gt;getAction();<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;evt-&gt;dump();<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
&nbsp; &nbsp; }std::string eventPath(evt-&gt;findParam(&quot;DEVPATH&quot;)?evt-&gt;findParam(&quot;DEVPATH&quot;):&quot;&quot;);<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
&nbsp; &nbsp; std::string devType(evt-&gt;findParam(&quot;DEVTYPE&quot;)?evt-&gt;findParam(&quot;DEVTYPE&quot;):&quot;&quot;);</p>

<div align="left">+ LOG &lt;&lt; &quot;handleBlockEvent with eventPath &quot; &lt;&lt; eventPath;</div>

<p>if (devType != &quot;disk&quot;) return;<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei&quot;, Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
加入补丁</p>

<div align="left">1. if (isVirtioBlkDevice(majorId)) {<br style="overflow-wrap:break-word; word-break:break-all" />
LOG &lt;&lt; &quot;Recognized experimental block major ID &quot; &lt;&lt; majorId<br style="overflow-wrap:break-word; word-break:break-all" />
&lt;&lt; &quot; as virtio-blk (emulator&#39;s virtual SD card device)&quot;;<br style="overflow-wrap:break-word; word-break:break-all" />
mLabel = &quot;Virtual&quot;;<br style="overflow-wrap:break-word; word-break:break-all" />
break;<br style="overflow-wrap:break-word; word-break:break-all" />
}<br style="overflow-wrap:break-word; word-break:break-all" />
if(majorId==259) {<br style="overflow-wrap:break-word; word-break:break-all" />
LOG &lt;&lt; &quot;majorID==259 major11 type &quot; &lt;&lt; majorId;<br style="overflow-wrap:break-word; word-break:break-all" />
mLabel = &quot;Pcie&quot;;<br style="overflow-wrap:break-word; word-break:break-all" />
break;<br style="overflow-wrap:break-word; word-break:break-all" />
}<br style="overflow-wrap:break-word; word-break:break-all" />
LOG &lt;&lt; &quot;Unsupported block major11 type &quot; &lt;&lt; majorId;<br style="overflow-wrap:break-word; word-break:break-all" />
return -ENOTSUP;</div>

<div align="left">2: if (isVirtioBlkDevice(majorId)) {<br style="overflow-wrap:break-word; word-break:break-all" />
// drivers/block/virtio_blk.c has &quot;#define PART_BITS 4&quot;, so max is<br style="overflow-wrap:break-word; word-break:break-all" />
// 2^4 - 1 = 15<br style="overflow-wrap:break-word; word-break:break-all" />
return 15;<br style="overflow-wrap:break-word; word-break:break-all" />
}<br style="overflow-wrap:break-word; word-break:break-all" />
if(majorId==259) {<br style="overflow-wrap:break-word; word-break:break-all" />
LOG &lt;&lt; &quot;majorID==259 major22 type &quot; &lt;&lt; majorId;<br style="overflow-wrap:break-word; word-break:break-all" />
return 15;<br style="overflow-wrap:break-word; word-break:break-all" />
}</div>

<p>&nbsp;</p>

<div align="left">结果可以识别到了 识别成USB移动设备</div>

<p>&nbsp;</p>

<div align="left"><ignore_js_op style="overflow-wrap:break-word; word-break:break-all"></ignore_js_op></div>

damiaa 发表于 2022-6-14 09:30

<p>有意思</p>

芯片老兵 发表于 2022-6-15 10:49

<p>这个硬盘调试高手来弄很容易啊,怎么看起来和U盘的测试原理差不多。</p>

freebsder 发表于 2022-6-16 18:41

<p>可能要加udev rules吧</p>
页: [1]
查看完整版本: 嵌入式RK3399/RK3568 PCIE接口的M2固态硬盘调式