USB相关的sysfs文件
主要来自driver/usb/core/sysfs.c:
1.bConfigurationValue
RW,W时调用了usb_set_configuration()实时设置配置。根据USB规范(例如第9.1.1.5节),configuration values必须是非零值,值为零表示设备处于未配置状态。但是,某些设备错误地使用0作为其配
置值之一。 为帮助管理此类设备,此函数将接受@configuration = -1,表示设备应处于未配置状态。
未授权的设备(dev->authorized == 0)将仅被设置为未配置模式。
# echo 0 > bConfigurationValue 此时U盘的设备文件消失
# echo 1 > bConfigurationValue 此时从新进行类似的U盘插入识别过程
配置这个文件就可以实现U盘的模拟插拔!!
/sys/devices/platform/soc/ee080100.usb/usb1/1-1/bConfigurationValue
配置这个文件就可以实现Android Carlife的模拟插拔!!
/sys/devices/platform/soc/ee080100.usb/usb1/(1-1/)bConfigurationValue
2.# cat ./1-1/power/connected_duration
记录了从USB设备连接上后到现在持续的事件
3.# cat ./1-1/power/active_duration
active状态持续的时间
4.# cat ./1-1/power/level
RW,设置autosuspend模式是on还是auto
5.authorized
RW,同样能起到模拟U盘插拔的效果
Move the USB device to a very basic state where interfaces are disabled and the device is in fact unconfigured and unusable.
6.remove
W,安全的移除设备。
# echo 1 > remove
UDEV [4921.100082] remove /devices/platform/soc/ee080100.usb/usb1/1-0:1.0 (usb)
移除了root-hub,然后USB接口就不识别了,不接恢复,目前只能掉电。移除U盘U盘就需要重新插拔才能识别。
7.modalias
R,此文件只有接口有
usb1/1-1# cat ./1-1:1.0/modalias
eg:U盘:usb:v0951p1666d0001dc00dsc00dp00ic08isc06ip50in00
拆分如下:v0951 p1666 d0001 dc00 dsc00 dp00 ic08 isc06 ip50 in00
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf; struct usb_device *udev; struct usb_host_interface *alt; intf = to_usb_interface(dev); udev = interface_to_usbdev(intf); alt = ACCESS_ONCE(intf->cur_altsetting); return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02Xin%02X\n", le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idProduct), le16_to_cpu(udev->descriptor.bcdDevice), udev->descriptor.bDeviceClass, udev->descriptor.bDeviceSubClass, udev->descriptor.bDeviceProtocol, alt->desc.bInterfaceClass, alt->desc.bInterfaceSubClass, alt->desc.bInterfaceProtocol, alt->desc.bInterfaceNumber); } New USB device found, idVendor=0951, idProduct=1666
posted on 2018-10-04 21:37 Hello-World3 阅读(672) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!