当前位置:网站首页>USB driver -debug
USB driver -debug
2022-06-26 03:21:00 【Be good to me】
1. debugfs
If the system is not automatically mounted debugfs , You need to mount manually with the following command :
mount -t debugfs none /sys/kernel/debug/ ## Default mount
mount -t debugfs kernel_debug /data/ ## Custom mount
During system startup , initialization usb modular :
// \linux-5.10\drivers\usb\core\usb.c
static int __init usb_init(void)
{
usb_debugfs_init(); //debugfs initialization , namely /sys/kernel/debug/(mount -t debugfs none /sys/kernel/debug/)
retval = bus_register(&usb_bus_type); // register usb Bus
retval = usb_register(&usbfs_driver); // register usb_driver: usbfs
retval = usb_devio_init(); //usbfs initialization , namely /sys/kernel/debug/usb/
retval = usb_hub_init(); // initialization usb_driver: hub
retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE); //generic drive
}
usb_register(&usbfs_driver)、usb_devio_init() All are usbfs Related initialization .
usbfs It provides us with direct access in user space usb Interface of hardware equipment , But it needs strong support from the kernel ,usbfs_driver(\drivers\usb\core\devio.c) Is used to complete this glorious task .
1.1 trace
Linux The system comes with a kind of trace, be located /sys/kernel/tracing/ or /sys/kernel/debug/tracing/, Print :
trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status);
(1)dwc3 trace
echo 1 > /sys/kernel/tracing/instances/usb/events/dwc3/enable # open dwc3 Of tracing
cat /sys/kernel/tracing/instances/usb/trace > /data/out.txt # preservation trace
Note: To reduce the number of log events we can disable logging for dwc3_readl/writel.
echo 0 > /sys/kernel/debug/tracing/instances/usb/events/dwc3/dwc3_readl/enable
echo 0 > /sys/kernel/debug/tracing/instances/usb/events/dwc3/dwc3_writel/enable
(2)xhci trace
echo 1 > /sys/kernel/tracing/instances/usb/events/xhci-hcd/enable
cat /sys/kernel/tracing/instances/usb/trace_pipe > /data/trace_pipe.txt &
(3)trace Main switch :
echo 1 > /sys/kernel/tracing/tracing_on # Open all trace
cat /sys/kernel/tracing/trace_pipe
1.2 ipc_logging
Qualcomm A kind of self added log, For tracking mdwc3 act .
cat /d/ipc_logging/4e00000.dwc3/log
or
cat /sys/kernel/debug/ipc_logging/4e00000.dwc3/log
1.3 strace
strace ./yavta -f YUYV -s 1280x720 -t 1/60 -c100 /dev/video0 > logcat.log
1.4 Switch usb Pattern
echo none > /sys/bus/platform/devices/6a00000.ssusb/mode # To break off USB
echo peripheral > /sys/bus/platform/devices/6a00000.ssusb/mode #device mode
echo host > /sys/bus/platform/devices/6a00000.ssusb/mode #host mode
2. procfs
(1) see IO Memory allocation
cat /proc/iomem # see IO Memory allocation
sm6150:/ # cat /proc/iomem
00100000-002effff : cc_base
007c4000-007c4fff : hc_mem
007c8000-007cffff : /soc/[email protected]
00884000-00887fff : /soc/[email protected] #i2c
0088c000-0088ffff : /soc/[email protected]
008c0000-008c5fff : /soc/qcom,[email protected]
00a84000-00a87fff : /soc/[email protected]
00ac0000-00ac5fff : /soc/qcom,[email protected]
01d90000-01d97fff : /soc/[email protected]
01fcb244-01fcb247 : vls_clamp_reg
01fed000-01fed027 : /soc/[email protected]
03000000-03dc1fff : pinctrl
...
08804000-08804fff : hc_mem
088e0000-088e1fff : eud_base
088e2000-088e217f : qusb_phy_base #usb phy
088e3000-088e317f : qusb_phy_base
090cc000-090cc2ff : lagg-base
0a60c100-0a60ccff : /soc/[email protected]/[email protected] #usb0
0a800000-0a807fff : /soc/[email protected]/[email protected] #usb1
...
(2) View the device and master device number registered in the system :
sm6150:/ # cat /proc/devices | grep usb
180 usb
189 usb_device
494 ccid_usb
495 msm_usb_bridge
506 gsi_usb
3. host
(1) see USB Insert device information , Print all device information under the bus ( Contains descriptor information ).
cat /sys/kernel/debug/usb/devices
(2) see usb Under the bus device:
ls /sys/bus/usb/devices/
1-0:1.0 2-0:1.0 3-0:1.0 usb1 usb2 usb3
analysis :
1-0:1.0 1-0( A hub 1- Hub port number 0):1( The first configuration ).0( First interface )
usb1 dummy root hub、USB Host controller 、USB Bus 1;
usb2 2.0 root hub、USB host 2.0 controller 、USB Bus 2;
usb3 3.0 root hub、USB host 3.0 controller 、USB Bus 3;
Insert U disc ( There is one more device interface :2-1:1.0)
1-0:1.0 2-0:1.0 2-1 2-1:1.0 3-0:1.0 usb1 usb2 usb3
analysis ;
2-1 u Disk equipment
2-1:1.0 2-1( A hub 2- Hub port number 1):1( The first configuration ).0( First interface )
(3) View the device tree node architecture :
ls /sys/devices/platform/soc/4e00000.ssusb/4e00000.dwc3/xhci-hcd.2.auto/usb2/2-1/2-1:1.0
analysis :
soc # Child nodes of the root node of the device tree , As platform device It is parsed by the system
4e00000.ssusb # because soc have compatible Of bus attribute , Its child nodes act as platform Device registration , Qualcomm defined mdwc
4e00000.dwc3 #dwc3 usb core Subsystem , By mdwc register
xhci-hcd.2.auto # Host controller xhci
usb2 #usb2.0 controller ,usb Bus 2
2-1 #usb equipment ( Such as U disc )
2-1:1.0 #usb Interface device
边栏推荐
- Arduino string to hexadecimal number for large color serial port screen.
- How to prompt
- Wealth freedom skills: commercialize yourself
- MySQL增删查改(初阶)
- Plug in installation and shortcut keys of jupyter notebook
- 2021-08-04
- 路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
- Vulhub replicate an ActiveMQ
- 数字孪生智慧水务,突破海绵城市发展困境
- R language Markov chain Monte Carlo: practical introduction
猜你喜欢

The role of children's programming in promoting traditional disciplines in China

Clion项目中运行多个main函数

Business process diagram design

What can Arthas do for you?

On virtual memory and oom in project development

进度条

【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长

浅谈虚拟内存与项目开发中的OOM问题

论文回顾:Unmixing-Based Soft Color Segmentation for Image Manipulation

经典模型——AlexNet
随机推荐
Distributed e-commerce project grain mall learning notes < 3 >
类图
Group note data representation and operation check code
Google recommends using kotlin flow in MVVM architecture
图扑软件数字孪生海上风电 | 向海图强,奋楫争先
golang正則regexp包使用-06-其他用法(特殊字符轉換、查找正則共同前綴、切換貪婪模式、查詢正則分組個數、查詢正則分組名稱、用正則切割、查詢正則字串)
How Inkscape converts PNG pictures to SVG pictures without distortion
Mysql常用sql语句之修改表名、删除表、获取表信息、删除指定日期的表记录
学习太极创客 — MQTT(五)发布、订阅和取消订阅
少儿编程对国内传统学科的推进作用
jupyter notebook的插件安装以及快捷键
QT compilation error: unknown module (s) in qt: script
论文回顾:Unmixing-Based Soft Color Segmentation for Image Manipulation
How to prompt
Analysis of the multiple evaluation system of children's programming
usb peripheral 驱动 - 枚举
The role of children's programming in promoting traditional disciplines in China
UE5全局光照系統Lumen解析與優化
Wealth freedom skills: commercialize yourself
虫子 拷贝构造 运算符重载