① linux下USB设备热插拔怎么检测
1.插上宏凳USB设备。
2.用芦源root帐号执行 fdisk -l
3.命令行会显示USB设备清单,如果是U盘,注意看看容量一陪绝态下就看出来了。
② linux下的USB驱动:如何识别手机打开USB存储设备开关请牛人出马呀~
1、打开终端;
2、输入su root,按回车,然后输入密码,按回车,获得root权限;
3、输入fdisk -l,按回正伍段车,系统会列出连接到电脑的橘谈磁盘清单,包括路径、大小、已挂载磁盘的挂载路径等。在里面找到你手机卡的路径,如/dev/sdb。
4、创建一个文件夹举誉,如mkdir /dev/usb;
5、挂载磁盘,mount -t vfat /dev/sdb /dev/usb。
③ 如何在Linux系统下检测U盘是否已连接
如果没有umount就非法拔出U盘,程序是不知道的,fopen,fwrite等函数都依然返回正确,知启枯道操作系统要把写介质的时候,才会提示I/O错误。可是很多数据都会因为这个不及时的错误报告而丢失。
事实上,USB驱动程序在U盘插入和亏旁衫拔出时,都对系统配置文件做了修改。例如U盘驱动程序会销腔在插入或拔出时往 /proc/scsi/usb-storage-0/0 里面记上 Attached:Yes or No。通过查看这个文件就不难检测U盘是否插入或拔出了。
但是值得注意的是,U盘是否插入的状态与是否挂载(mount)无关。
④ Linux下如何测试及使用USB转串口线
1、将设备u口插入pc 2、输入#lsmod 先看看能否检测到这个设备,就看有没有pl2303字眼可以了。如果有,则不需要再装驱动。另外如果有的话最好再用dmesg | grep usb查找如果看到: “drivers/usb/serial/usb-serial.c: USB Serial support registered for Generic” 就说明设备已被识别,然后往下看 drivers/usb/serial/usb-serial.c: USB Serial support registered for PL-2303 usb 2-2: PL-2303 converter now attached to ttyUSB0 (or usb/tts/0 for devfs)如果没有则需要驱动程序,一般硬件厂商都会提供,如果真的没有的话就只有到网上下载了,一般2.6内核以上的都支持。 安装完毕后再输入这个命令瞧瞧,是否安装成功。说明我的usb转串口芯片是PL-2303,对应系统设备是 dev/usb/ttUSB0,最后只需在minicom配置文件里将端口改成/dev/usb/ttyUSB0就可以使用了:) 3、检测步骤,检测步骤如下,只是需要主意的是设置串口设备的时候可能不是ttyS2了,有可能是ttyUSB0或者ttyUSB1等之类的,我这里就是ttyUSB0(我用的是Fedora Core 8)。 因此,最好请您先看一下/dev下面的文件。 USB转串口安装 型号PL2303h 1、插入USB转串口到主机, 2、启动 Linux,打开终端,检查是否存在设备/dev/ttyUSB0,如果没有就建立一个: mknod /dev/ttyUSB0 c 188 0 如果有多个USB口,可以类推,建立/dev/ttyUSB[1-n],注意从设备号要累加, 如:mknod /dev/ttyUSB[1-n] c 188 [1-n] 3、输入命令:#setserial /dev/ttyS0 -aP (COM-1) 显示内容:/dev/ttyS0, Line 0, UART: 16550A, Port: 0x3f8, irq: 4 Baud_base: 115200, clos_delay: 50, divisor: 0 closing_wait: 3000, closing_wait2: infinite Flags: spd_normal skip_test 4、输入命令:#setserial /dev/ttyS2 -a (COM-3) 显示内容:/dev/ttyS2, Line 2, UART: unknown, Port: 0x3e8, irq: 4 Baud_base: 115200, clos_delay: 50, divisor: 0 closing_wait: 3000, closing_wait2: infinite Flags: spd_normal skip_test 第3、4步操作的目的主要是对主机自带串口及PCI扩展串口的区带指别。区别在裤歼于4显示的内容中UART:未知unknow。不过若您检测这一步的时候 UART为16550A而不是unknow,证明你的系统已经认识了扩展的串口,不需要进一步设置,直接跳入第8步测试就可以了。 5、设置好了后是不是需要测试一下是否能够通讯呢?最好的办法是两台pc相连。如果pc为windows操作系统就用超级终端,是linux呢就用minicom吧 6、装有linux的机器,首先需要设置一下监听的串口参数,输入命令 #minicom -s 进入界面后有个框弹出来,如果你学过英文的话,就会知道选择哪个的。应该是第三个吧,串口参数设置。 将第一行更改为 /dev/ttyUSB0 波特率也更改您所需要的。 更改完后保存,蠢纯配保存的那个菜单应该是 save ... df1 最后exit 7.重启minicom, 复位目标板,看是否有打印信息?如果没有请确认:a)USB/串口线没问题,b)确认你使用的USB口是第一个(一个个的试吧,一般电脑不会标示出来) 在另外一台机器发送数据,这台机器minicom界面就能够收到信息了。另外不要把两个COM顺序弄翻了,如果弄错了哪个是COM3 COM4测试可就不灵便咯。
⑤ linux怎么检测不到USB设备
方毁瞎法一拍旅:在/etc/init.d/rcS中添加mount -t usbfs none /proc/bus/usb. 方法二:在shell中输入mount -t usbfs /proc/bus/usb /proc/bus/usb. 前提是在编译内袭余凳核时选中usb device filesystem。
⑥ linux 如何判断usb驱动是2.0
看设备信息。
lsusb 可以看到系统中的usb设备信息。
lsusb -v 具体输出。里面的bcdUSB是usb的版本号。
0x0110是usb1.1
0x0200是usb2.0
在初始化过程瞎穗中,除了F2812自身初始化外,还要完成对ISP1581各个端点使用的传输类型、传输包大小和中断类型及方式等设备任务。F2812对 ISP1581的操作是通过写/读寄存器来实现的。初始化结束后,通过设置ISP1581方式寄存器中的软件连接位(SOFTCT)可使外设连接到USB 总线上。《Linux就该这么学》一起学更多linux知识。
主机检测到有设备连接后会进行总线复位。在此期间,ISP1581将发送高速(HS)模式检测信号来判断主控制器支持的是USB2.0还是 USB1.1规范,若接收到一个高速(HS)握手信号,则表明键腊有一个HS主磨亮卜机与总线相连,此此ISP1581将转换到高速(HS)状态,否则仍工作在全速(FS)状态。
⑦ linux操作系统怎么识别USB接口设备
linux系统会自动识别USB接口为串口磁盘sda(通常为sda1,可通过fdisk
-l命令查询),挂载版就可用权。
例:新建挂载目录mkdir
/mnt/usb,挂载mount
/dev/sda1
/mnt/usb,用完卸载挂起点unmount
/dev/sda1
/mnt/usb。
⑧ 嵌入式linux驱动识别设备的过程
驱动程序识别设备时,有以下两种方法:
(1)驱动程序本身带有设备的信息,比如开始地址、中断号等:加载驱动程序时,就可以根据这些信息来识别设备。
(2)驱动程序本身没有设备的信息,但是内核中已经(或以后)根据其他方式确定了很多设备的信息;加载驱动程序时,将驱动程序与这些设备逐个比较,确定两者是否匹配(match)。如果驱动程序与某个设备匹配,就可以通过该驱动程序操作这个设备了。内核常使用第二种方法来识别设备,这可以将各种设备集中在-一个文件中管理,当开发板的配置改变时,便于修改代码。在内核文件include/linux/platform _device.h 中,定义了两个数据结构来表示这些设备和驱动程序: platform_ device 结构用来描述设备的名称、ID、所占用的资源(比如内存地址/大小、中断号)等; platform_ driver 结构用来描述各种操作函数, 比如枚举函数、移除设备函数、驱动的名称等。内核启动后,首先构造链表将描述设备的platform_device结构组织起来,得到一一个设备的列尘搜表:当加载某个驱动程序的platform_ driver 结构时清兄局,使用一.些匹配函数来答让检查驱动程序能否支持这些设备,常用的检查方法很简单:比较驱动程序和设备的名称。
⑨ linux下怎么查找usb对应的设备,比如鼠标....
1、首先Linux 系统使用 /dev 目录下特定的设备文件来标识插入的设备。会发现该目录下的某些文件,包括 /dev/sda 或者 /dev/hda 表示第一个主设备,每个分区使用一个数字来表示,比如 /dev/sda1 或 /dev/hda1 表示主设备的第一个分区等。
⑩ 怎么查看linux usb设备驱动
下面的信息都是在VMware中运行Ubuntu12-04系统上执行的。同样该命令也支持在嵌入式系统中进行USB调试。
一、cat设备节点获取信息
在一些嵌入式开发中需要调试USB功能,经常会cat /sys 下的相关设备节点来查看某些信息,比如说我们可以看到 /sys/bus/usb/devices 目录有多个子目录。进入到某个子目录可以看到usb设备更加详细的信息(可以理解为设备描述符)。
1、usb设备在总线上的信息
// usb设备在总线上的信息
root@ubuntu:/sys/kernel/debug# cd /sys/bus/usb/devices
root@ubuntu:/sys/bus/usb/devices# ll
total 0
drwxr-xr-x 2 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
lrwxrwxrwx 1 root root 0 Nov 26 21:21 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-0:1.0/
lrwxrwxrwx 1 root root 0 Dec 15 23:10 1-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/
lrwxrwxrwx 1 root root 0 Dec 15 23:18 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-0:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/
其中 usbx/第x个总线,x-y:a.b/的目录格式,x表示总线号,y表示端口,a表示配置,b表示接口。
具体解释可以参照如下:
The names that begin with "usb" refer to USB controllers. More accurately, they refer to the "root hub" associated with each controller. The number is the USB bus number. In the example there is only one controller, so its bus is number 1. Hence the name "usb1".
"1-0:1.0" is a special case. It refers to the root hub's interface. This acts just like the interface in an actual hub an almost every respect; see below.
All the other entries refer to genuine USB devices and their interfaces. The devices are named by a scheme like this:
bus-port.port.port ...
In other words, the name starts with the bus number followed by a '-'. Then comes the sequence of port numbers for each of the intermediate hubs along the path to the device.
For example, "1-1" is a device plugged into bus 1, port 1. It happens to be a hub, and "1-1.3" is the device plugged into port 3 of that hub. That device is another hub, and "1-1.3.1" is the device plugged into its port 1.
The interfaces are indicated by suffixes having this form:
:config.interface
That is, a ':' followed by the configuration number followed by '.' followed by the interface number. In the above example, each of the devices is using configuration 1 and this configuration has only a single interface, number 0. So the interfaces show up as;
1-1:1.0 1-1.3:1.0 1-1.3.1:1.0
A hub will never have more than a single interface; that's part of the USB spec. But other devices can and do have multiple interfaces (and sometimes multiple configurations). Each interface gets its own entry in sysfs and can have its own driver.
2、特定设备的详细信息
进入到某个目录中去,可以看到该设备的详细信息,可用cat命令获取信息。
// usb设备的详细信息
root@ubuntu:/sys/bus/usb/devices/usb1# ll
total 0
drwxr-xr-x 6 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
drwxr-xr-x 10 root root 0 Nov 26 21:21 1-0:1.0/
drwxr-xr-x 5 root root 0 Dec 15 23:10 1-1/
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized_default
-rw-r--r-- 1 root root 4096 Dec 15 23:40 avoid_reset_quirk
-r--r--r-- 1 root root 4096 Nov 26 21:21 bcdDevice
-rw-r--r-- 1 root root 4096 Nov 26 21:21 bConfigurationValue
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceClass
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceProtocol
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceSubClass
-r--r--r-- 1 root root 4096 Dec 15 23:40 bmAttributes
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPower
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumConfigurations
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumInterfaces
-r--r--r-- 1 root root 4096 Nov 26 21:21 busnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 configuration
-r--r--r-- 1 root root 65553 Nov 26 21:21 descriptors
-r--r--r-- 1 root root 4096 Dec 15 23:40 dev
-r--r--r-- 1 root root 4096 Nov 26 21:21 devnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 devpath
lrwxrwxrwx 1 root root 0 Nov 27 20:06 driver -> ../../../../../bus/usb/drivers/usb/
drwxr-xr-x 3 root root 0 Dec 15 23:40 ep_00/
-r--r--r-- 1 root root 4096 Nov 26 21:21 idProct
-r--r--r-- 1 root root 4096 Nov 26 21:21 idVendor
-r--r--r-- 1 root root 4096 Dec 15 23:40 ltm_capable
-r--r--r-- 1 root root 4096 Nov 26 21:21 manufacturer
-r--r--r-- 1 root root 4096 Dec 15 23:40 maxchild
drwxr-xr-x 2 root root 0 Nov 26 21:21 power/
-r--r--r-- 1 root root 4096 Nov 26 21:21 proct
-r--r--r-- 1 root root 4096 Dec 15 23:40 quirks
-r--r--r-- 1 root root 4096 Nov 26 21:21 removable
--w------- 1 root root 4096 Dec 15 23:40 remove
-r--r--r-- 1 root root 4096 Nov 26 21:21 serial
-r--r--r-- 1 root root 4096 Nov 26 21:21 speed
lrwxrwxrwx 1 root root 0 Nov 26 21:21 subsystem -> ../../../../../bus/usb/
-rw-r--r-- 1 root root 4096 Nov 26 21:21 uevent
-r--r--r-- 1 root root 4096 Dec 15 23:40 urbnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 version
二、使用debugfs
1、挂载 debugfs 到 /sys/kernel/debug 路径下
root@ubuntu:mount -t debugfs none /sys/kernel/debug
2、执行上述步骤之后,在 /sys/kernel/debug 就会生成如下的文件
root@ubuntu:/sys/bus/usb/devices# cd /sys/kernel/debug/
root@ubuntu:/sys/kernel/debug# ll
total 0
drwx------ 22 root root 0 Nov 26 21:21 ./
drwxr-xr-x 7 root root 0 Nov 26 21:21 ../
drwxr-xr-x 2 root root 0 Nov 26 21:21 acpi/
drwxr-xr-x 32 root root 0 Dec 4 16:30 bdi/
drwxr-xr-x 2 root root 0 Nov 26 21:21 bluetooth/
drwxr-xr-x 2 root root 0 Nov 26 21:21 cleancache/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dma_buf/
drwxr-xr-x 4 root root 0 Nov 26 21:21 dri/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dynamic_debug/
drwxr-xr-x 2 root root 0 Nov 26 21:21 extfrag/
drwxr-xr-x 2 root root 0 Nov 26 21:21 frontswap/
-r--r--r-- 1 root root 0 Nov 26 21:21 gpio
drwxr-xr-x 3 root root 0 Nov 26 21:21 hid/
drwxr-xr-x 2 root root 0 Nov 26 21:21 kprobes/
drwxr-xr-x 3 root root 0 Nov 26 21:21 kvm-guest/
drwxr-xr-x 2 root root 0 Nov 26 21:21 mce/
drwxr-xr-x 2 root root 0 Nov 26 21:21 pinctrl/
-r--r--r-- 1 root root 0 Nov 26 21:21 pwm
drwxr-xr-x 2 root root 0 Nov 26 21:21 regmap/
drwxr-xr-x 3 root root 0 Nov 26 21:21 regulator/
-rw-r--r-- 1 root root 0 Nov 26 21:21 sched_features
-r--r--r-- 1 root root 0 Nov 26 21:21 sleep_time
-r--r--r-- 1 root root 0 Nov 26 21:21 suspend_stats
drwxr-xr-x 7 root root 0 Nov 26 21:21 tracing/
drwxr-xr-x 3 root root 0 Nov 26 21:21 usb/
drwxr-xr-x 2 root root 0 Nov 26 21:21 virtio-ports/
-r--r--r-- 1 root root 0 Nov 26 21:21 vmmemctl
-r--r--r-- 1 root root 0 Nov 26 21:21 wakeup_sources
drwxr-xr-x 2 root root 0 Nov 26 21:21 x86/
3、cat 设备节点
执行下述命令之后会以特定格式打印目前USB总线上所有USB设备的信息如下:
root@ubuntu:/sys/kernel/debug# cat usb/devices
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 17/900 us ( 2%), #Int= 1, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic uhci_hcd
S: Proct=UHCI Host Controller
S: SerialNumber=0000:02:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0003 Rev= 1.03
S: Manufacturer=VMware
S: Proct=VMware Virtual USB Mouse
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1ms
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0002 Rev= 1.00
S: Proct=VMware Virtual USB Hub
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
B: Alloc= 0/800 us ( 0%), #Int= 1, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic ehci_hcd
S: Proct=EHCI Host Controller
S: SerialNumber=0000:02:03.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
P: Vendor=0bda ProdID=0129 Rev=39.60
S: Manufacturer=Generic
S: Proct=USB2.0-CRW
S: SerialNumber=20100201396000000
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=83(I) Atr=03(Int.) MxPS= 3 Ivl=64ms
至于信息的详细解析可以参照 Linux源代码中 Documentation/usb/proc_usb_info.txt 文件。现摘录其中对该格式的详细解释:
| | |__Proct ID code
| |__Vendor ID code
|__Device info tag #2
String descriptor info:
S: Manufacturer=ssss
| |__Manufacturer of this device as read from the device.
| For USB host controller drivers (virtual root hubs) this may
| be omitted, or (for newer drivers) will identify the kernel
| version and the driver which provi