1. 内核开启
(1)内核配置
Kernel hacking --->
printk and dmesg options --->
[* ] Enable dynamic printk() support
2.驱动支持
以 pr_debug / pr_err / pr_warn / pr_info打印的消息
#if defined(CONFIG_DYNAMIC_DEBUG)
// dynamic_pr_debug() uses pr_fmt() internally so we don't need it here
#define pr_debug(fmt, ...) \
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#elif defined(DEBUG)
#define pr_debug(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_debug(fmt, ...) \
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
3.挂载
mount -t debugfs none /sys/kernel/debug
4.先查看下
cat /sys/kernel/debug/dynamic_debug/control
5.确保printk的打印等级OK
ensure console loglevel value > 7:
cat /proc/sys/kernel/printk
8 4 1 7 //8 is ok
echo 8 > /proc/sys/kernel/printk
6. 使用
1) module
echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control //enable
echo 'module xhci_hcd -p' > /sys/kernel/debug/dynamic_debug/control //disable
other usb module:
echo 'module phy +p' > /sys/kernel/debug/dynamic_debug/control
echo 'module udc_core +p' > /sys/kernel/debug/dynamic_debug/control
echo 'module snps_udc_core +p' > /sys/kernel/debug/dynamic_debug/control
echo 'module libcomposite +p' > /sys/kernel/debug/dynamic_debug/control
2) file
echo 'file hub.c +p' > /sys/kernel/debug/dynamic_debug/control //enable
echo 'file hub.c -p' > /sys/kernel/debug/dynamic_debug/control //disable
3) function
echo 'func hub_event +p' > /sys/kernel/debug/dynamic_debug/control //enable
echo 'func hub_event -p' > /sys/kernel/debug/dynamic_debug/control //disable
离线