当前位置:网站首页>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
边栏推荐
- 点击事件
- 我在中山,到哪里开户比较好?网上开户是否安全么?
- golang正则regexp包使用-06-其他用法(特殊字符转换、查找正则共同前缀、切换贪婪模式、查询正则分组个数、查询正则分组名称、用正则切割、查询正则字串)
- 计组笔记 数据表示与运算 校验码部分
- 《你不可不知的人性》經典語錄
- [system architecture] - how to evaluate software architecture
- 使用IDEA画结构图
- Lumen Analysis and Optimization of ue5 global Lighting System
- 【论文笔记】Manufacturing Control in Job Shop Environments with Reinforcement Learning
- Analysis of the multiple evaluation system of children's programming
猜你喜欢

How Inkscape converts PNG pictures to SVG pictures without distortion

Graphics card, GPU, CPU, CUDA, video memory, rtx/gtx and viewing mode

MySQL增删查改(进阶)

Learn Tai Chi Maker - mqtt (IV) server connection operation

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

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

双碳红利+基建大年 | 图扑深耕水利水电绿色智能装备领域

Drawing structure diagram with idea

【论文笔记】Supersizing Self-supervision: Learning to Grasp from 50K Tries and 700 Robot Hours

On virtual memory and oom in project development
随机推荐
网络PXE启动WinPE,支持UEFI和LEGACY引导
Network PXE starts winpe and supports UEFI and legacy boot
Using meta analysis to drive the development of educational robot
[solution] cmake was unable to find a build program corresponding to "UNIX makefiles"
How Inkscape converts PNG pictures to SVG pictures without distortion
经典模型——AlexNet
给网站添加“开放搜索描述“以适配浏览器的“站点搜索“
MySQL数据库基础
Survival analysis based on ovarian data set
Question about SQL: SQL question -- SQL code for multiple account logins
ArrayList # sublist these four holes, you get caught accidentally
jupyter notebook的插件安装以及快捷键
[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long
2021-08-04
2022年挖财证券开户安全嘛?
[QT] custom control - switch
小程序或者for循序要不要加key?
GStreamer allocator and pool
解析创客空间机制建设的多样化
[reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters