R329开发板的初步认知——硬件
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在上周的报告(</font><font face="Calibri">https://bbs.eeworld.com.cn/thread-1179439-1-1.html</font><font face="宋体">)报告中,已经将板卡连接到网络,并进行了简单的性能测试,在本周,进一步熟悉本板卡。</font></span></span></span></span></p><p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在传统的教材中,系统硬件运算器、控制器、存储器、输入设备和输出设备五大功能部分组成,现在一个</font><font face="Calibri">CPU</font><font face="宋体">就能够实现运算和控制功能,存储由外部的</font><font face="Calibri">TF</font><font face="宋体">卡和板载的</font><font face="Calibri">DRAM</font><font face="宋体">构成,输入输出则通过网络、</font><font face="Calibri">GPIO</font><font face="宋体">、按键、</font><font face="Calibri">SPI</font><font face="宋体">屏、扬声器、摄像头等实现。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">基于</font><font face="Calibri">Linux</font><font face="宋体">万物即文件的思路,我们查看</font><font face="Calibri">/dev</font><font face="宋体">:</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在这里,除了</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">aipu</font><font face="宋体">外,其它的都看起来</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">比较眼熟,比如</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">tty</font><font face="宋体">、</font><font face="Calibri">fb0</font><font face="宋体">、</font><font face="Calibri">video</font><font face="宋体">等等。</font></span></span></span></span></p>
<ol>
<li style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">终端</font></span></span></span></span></li>
</ol>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">tty</font><font face="宋体">表示各种类型的终端设备,可以使用命令“</font><font face="Calibri">ps -ax</font><font face="宋体">”查看进程与哪个控制终端相连,缺省</font><font face="Calibri">tty</font><font face="宋体">是当前使用的终端,可以看到本系统中,使用了</font><font face="Calibri">ttys0</font><font face="宋体">和</font><font face="Calibri">tty1</font><font face="宋体">。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">使用</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">tty</font><font face="宋体">命令,可以看到本串口(</font><font face="Calibri">usb</font><font face="宋体">)所用的</font><font face="Calibri">tty</font><font face="宋体">为</font><font face="Calibri">ttys0</font><font face="宋体">。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">推测执行了</font><font face="Calibri">/sbin/agetty</font><font face="宋体">的</font><font face="Calibri">tty1</font><font face="宋体">是控制</font><font face="Calibri">240*240</font><font face="宋体">显示屏输出。尝试在串口输入“</font><font face="Calibri">echo test>/dev/tty1</font><font face="宋体">”,果然可以在显示屏上打印出名为</font></span></span><span style="font-size:10.5000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">test</font></span></span><span style="font-size:10.5000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">的字符串。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">系统缺省开启了</font><font face="Calibri">sshd</font><font face="宋体">功能,尝试在电脑中开启一个</font><font face="Calibri">ssh</font><font face="宋体">终端登录,并使用</font><font face="Calibri">tty</font><font face="宋体">命令,可以看到它是</font><font face="Calibri">/dev/pts/0</font><font face="宋体">,同时</font><font face="Calibri">ps -ax</font><font face="宋体">中的信息也增加了对应终端。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<ol start="2">
<li style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">Framebuffer</font></span></span></span></span></li>
</ol>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">Fb</font><font face="宋体">是</font><font face="Calibri">framebuffer</font><font face="宋体">的缩写,一般来说可以将缓存直接写入</font><font face="Calibri">fb0</font><font face="宋体">,使其在屏幕上显示,在这里的显示屏应该指的是</font><font face="Calibri">240*240</font><font face="宋体">的屏,为了验证猜测,使用</font><font face="Calibri">fbset</font><font face="宋体">查看:</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">与猜测的结果相符合。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">进一步验证:</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">输入命令</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">cp /dev/fb0 tmp</font><font face="宋体">,把当前屏幕内容拷贝到名为</font><font face="Calibri">tmp</font><font face="宋体">的文件中。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">再随便向</font><font face="Calibri">tty1</font><font face="宋体">写一点什么,比如</font><font face="Calibri">ifconfig > /dev/tty1</font><font face="宋体">。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">再把</font><font face="Calibri">tmp</font><font face="宋体">文件打印到</font><font face="Calibri">fb0</font><font face="宋体">中,</font><font face="Calibri">cat tmp > /dev/fb0</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">tmp</font><font face="宋体">文件大小</font><font face="Calibri">115,200 </font><font face="宋体">字节(</font><font face="Calibri">240*240*2</font><font face="宋体">),因为一个像素只占</font><font face="Calibri">2</font><font face="宋体">字节,所以推测</font><font face="Calibri">buffer</font><font face="宋体">是只支持</font><font face="Calibri">RGB565</font><font face="宋体">或者</font><font face="Calibri">RGB555</font><font face="宋体">(事实上我也尝试过向</font><font face="Calibri">fb0</font><font face="宋体">写入</font><font face="Calibri">RGB888</font><font face="宋体">文件,会提示大了)。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">(上传自己编写一个转换图片和</font><font face="Calibri">fb</font><font face="宋体">的小程序)</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以看到,从</font><font face="Calibri">framebuffer</font><font face="宋体">转成的</font><font face="Calibri">RGB88</font><font face="宋体">图片颜色似乎不太对。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">为祖国庆生,传一张图片吧。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<ol start="3">
<li style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">摄像头</font></span></span></span></span></li>
</ol>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">系统中有</font><font face="Calibri">video0</font><font face="宋体">和</font><font face="Calibri">video1</font><font face="宋体">,不确定哪个是板上的摄像头,可以尝试使用</font><font face="Calibri">cv2</font><font face="宋体">读取信息。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以看到</font><font face="Calibri">video0</font><font face="宋体">是实际存在的,而</font><font face="Calibri">video1</font><font face="宋体">无法打开。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">查看一下摄像头的相关信息,我们知道在</font><font face="Calibri">cv2</font><font face="宋体">中</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以通过</font><font face="Calibri">print(stream0.get(i))</font><font face="宋体">来获取摄像头相关属性,例如:</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以看到这个摄像头缺省是</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">640*480</font><font face="宋体">,</font><font face="Calibri">25</font><font face="宋体">帧,当前亮度、色调、图像增益都为</font><font face="Calibri">0</font><font face="宋体">,对比度</font><font face="Calibri">40</font><font face="宋体">,饱和度</font><font face="Calibri">96</font><font face="宋体">,曝光</font><font face="Calibri">157</font><font face="宋体">,清晰度</font><font face="Calibri">3.0</font><font face="宋体">,色温</font><font face="Calibri">4600</font><font face="宋体">。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">尝试拍一张照片</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">摄像头拍出的图片效果:</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">手机拍摄的同样图片效果:</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">差别似乎还是有点大啊。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">下面是使用</font><font face="Calibri">ffmpeg</font><font face="宋体">将摄像头内容推送到</font><font face="Calibri">/dev/fb0</font><font face="宋体">上的命令。</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">ffmpeg -i /dev/video0 -vframes 1 -s 240*240 -pix_fmt rgb565le -vf transpose=2,transpose=2 -f fbdev /dev/fb0</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<ol start="4">
<li style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">TF</font><font face="宋体">卡(</font><font face="Calibri">/dev/mmcblk0</font><font face="宋体">)</font></span></span></span></span></li>
</ol>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">TF</font><font face="宋体">卡没什么好说的,就是比较普通的闪迪</font><font face="Calibri">8G</font><font face="宋体">(</font><font face="Calibri">C4</font><font face="宋体">)</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以用自带命令测试一下读写速度。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以看到这块</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">tf</font><font face="宋体">卡,写文件速度</font><font face="Calibri">7.3MB/s</font><font face="宋体">,读文件速度</font><font face="Calibri">22.1MB/s</font><font face="宋体">。和</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">hdparm</font><font face="宋体">测试结果基本类似。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p>基于Linux的R329开发板和传统的显示思路区别还是很大的</p>
<p>最后tf卡到达写文件速度7.3MB/s,读文件速度22.1MB/s,够快</p>
<p>忘记传附件了,这是用python写的,可以把图片和fb相互转换,代码简单,基本不需要注释</p>
<p></p>
<p>R329感觉挺好玩的,后悔当初没申请了!</p>
页:
[1]