petalinux 2018.2 添加u盘

我安装好petalinux 后,发现不能识别usb 盘。我花了好些时间寻找答案。下面是我在xilinx 论坛上提问的2个链接。

我是提问中得到别人的帮助,然后得到答案的,所以给出这2个链接。

https://forums.xilinx.com/t5/嵌入式软件开发/petalinux-中怎么加入u盘/td-p/902100

https://forums.xilinx.com/t5/Embedded-Linux/how-to-install-and-test-usb-disk-on-petalinux/td-p/896545

为了能读取u盘,需要修改文件system-user.dtsi,其地址是:工程目录/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

我是这么查找的:find . -name system-user.dtsi

为了看find 的使用,这个链接不错,应该也是一个不错的linux 命令学习网站:

https://www.runoob.com/linux/linux-comm-find.html

修改文件system-user.dtsi的内容如下:

/include/ "system-conf.dtsi"
/ {
};
/{
usb_phy0: usb_phy@0 {
compatible = "usb-nop-xceiv";
#phy-cells = <0>;
};
};

&usb0 {
dr_mode = "host";
usb-phy = <&usb_phy0>;
};

usb 设置或者petalinux-config 配置请参考以下链接:

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842272/Zynq+Linux+USB+Device+Driver

这个设置 usb 的几种方式: as a host, a device, or On-the-Go ,我这只看host 部分。

开始usb 不出来的时候,我也鼓捣这些设置,但发现我系统本来就是host 的设置,最近做的系统,根本就不修改。

所以就只要对这个文件修改,在petalinux-build 之前操作,u盘就能出来。

检验方法:

lsusb 是一个列表usb 设备的命令,如果上述设置好了的petalinux 系统,没插u盘是这样显示的: 

root@cnc9616:~# lsusb
Bus 001 Device 001: ID 1d6b:0002

当我插上u盘,是这样显示的(自动显示的):

root@cnc9616:~# usb 1-1: new high-speed USB device number 2 using ci_hdrc
usb-storage 1-1:1.0: USB Mass Storage device detected
scsi host0: usb-storage 1-1:1.0
scsi 0:0:0:0: Direct-Access     Lexar    USB Flash Drive  1100 PQ: 0 ANSI: 6
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 250068992 512-byte logical blocks: (128 GB/119 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda: sda1 sda2 < sda5 >
sd 0:0:0:0: [sda] Attached SCSI removable disk

我的u盘是128G的,下面是安装显示目录的操作:

root@cnc9616:~# mkdir /mnt/usb
root@cnc9616:~# ls /mnt
usb
root@cnc9616:~# mount /dev/sda1 /mnt/usb
root@cnc9616:~# cd /mnt/usb
root@cnc9616:/mnt/usb# ls
994.jpg                    backupdl                   include                    lwip.zip                   rtc4VC
AC7010_CD                  bmp                        ip_repo                    mp3                        updclient.cpp
ConsoleApplication1.cpp    cnc (2).zip                jc_LaserPoint.zip          msvcp100.dll               vcredist_x86.exe
DMC1000.DLL                correXion5                 lib                        opencv_world300.dll
LaserPoint.exe             download                   liwenResume2018Nov.pdf     p6208
PCI-Dask.dll               enc_LaserPoint.exe         liwenResume2018a.pdf       qspi.zip
System Volume Information  enc_LaserPointLJFen.zip    liwenResumeA.docx          rtc4

再来查看usb 设备,是这样的:
root@cnc9616:/mnt/usb# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 05dc:a838

修改设备表的内容,我还是不很熟悉,但按上面的操作就可以有u盘了。

介绍到此,希望对你有所帮助。

猜你喜欢

转载自blog.csdn.net/leon_zeng0/article/details/92408493