嵌入式RK3399/RK3568 PCIE接口的M2固态硬盘调式
<p>一、硬件平台<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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<std::mutex> lock(mLock);</div>
<p>if (mDebug) {<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
LOG(VERBOSE) << "----------------";<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
LOG(VERBOSE) << "handleBlockEvent with action " << (int) evt->getAction();<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
evt->dump();<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
}std::string eventPath(evt->findParam("DEVPATH")?evt->findParam("DEVPATH"):"");<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", Simsun; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-style:initial; text-decoration-color:initial" />
std::string devType(evt->findParam("DEVTYPE")?evt->findParam("DEVTYPE"):"");</p>
<div align="left">+ LOG << "handleBlockEvent with eventPath " << eventPath;</div>
<p>if (devType != "disk") return;<br style="overflow-wrap:break-word; word-break:break-all; color:#444444;Microsoft Yahei", 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 << "Recognized experimental block major ID " << majorId<br style="overflow-wrap:break-word; word-break:break-all" />
<< " as virtio-blk (emulator's virtual SD card device)";<br style="overflow-wrap:break-word; word-break:break-all" />
mLabel = "Virtual";<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 << "majorID==259 major11 type " << majorId;<br style="overflow-wrap:break-word; word-break:break-all" />
mLabel = "Pcie";<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 << "Unsupported block major11 type " << 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 "#define PART_BITS 4", 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 << "majorID==259 major22 type " << 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> </p>
<div align="left">结果可以识别到了 识别成USB移动设备</div>
<p> </p>
<div align="left"><ignore_js_op style="overflow-wrap:break-word; word-break:break-all"></ignore_js_op></div>
<p>有意思</p>
<p>这个硬盘调试高手来弄很容易啊,怎么看起来和U盘的测试原理差不多。</p>
<p>可能要加udev rules吧</p>
页:
[1]