使用调试文件系统debugfs

From BananaPro/Pi
Revision as of 20:15, 6 December 2015 by Super (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Other languages:
English • ‎中文(简体)‎

介绍

Debugfs给内核开发者提供了一种从用户空间获取有用信息的简单方法。不同于“/proc”系统,仅针对有关进程或sysfs信息且严格遵守一个文件一个值的规则,debugfs根本没有规则。开发者可以在他们想要的任何位置放置任何信息。debugfs文件系统也没有打算给用户空间提供稳定的ABI接口。理论上讲,debugf对于文件输出没有的稳定约束。然而,现实的世界并不总是那么简单,即使debugfs接口是用“永远不需要改动接口”这个最好的思想设计的。

Debugfs挂载

使用下面命令挂载Debugfs:

mount -t debugfs none /sys/kernel/debug


调试节点命令

查看设置GPIP寄存器

对于GPIOA_OUT_EN,其地址是0xb01b0000,使用下面命令查看GPIOA_OUT_EN的值:

cd /sys/kernel/debug/owl/
echo 0xb01b0000 > reg

返回结果:[0xb01b0000]: 0x00000000。
0x00000000是GPIOA_OUT_EN寄存器的值。
(注意:只有在print的级别大于4时,这些返回值才能被打印出来。)

使用下面命令使能GPIOA15:

cd /sys/kernel/debug/owl/
echo 0xb01b0000=0x00008000 > reg


查看ATC260X(PMU)寄存器

cd /sys/kernel/debug/regmap/0-0065
cat registers
#<寄存器ID:值>
00: e0eb
01: 4017
02: 1a82
03: 4280
04: 0000
05: 0180
06: 0000
07: 0000
08: 0000
09: 0000
0a: 5680
0b: fc00
0c: a680
0d: fc00
0e: e680
0f: fc00
10: 4910
11: e9cf
12: 2cae
13: 334b
14: 85af
15: 6cae
16: 334b
17: 8acf
18: 254c
19: 338a
1a: 0000
1b: 0000
1c: 0000
…


查看电池/充电信息

cd /sys/kernel/debug
cat charger				
charger is off			#是否正在充电
charge current = 0mA		#充电电流大小
wall voltage = 4248 (mV)	#输入电压
vbus voltage = 0 (mV)		#USB3.0输入电压
bat voltage = 17 (mV)		#电池电源
bat current = 0(mA)		#电池电流

查看电源管理

cd /sys/kernel/debug/regulator

我们看到 ldo, dcdc, switch等相关的信息。

查看GPIO信息

cd /sys/kernel/debug/
cat gpio 
GPIOs 0-131, owl-gpio-chip:
 gpio-35  (ft5x06              ) out hi
 gpio-36  (?                   ) out hi
 gpio-37  (?                   ) out hi
 gpio-43  (phy_power_gpio      ) out hi
 gpio-44  (green:GPIOB12       ) out lo
 gpio-49  (?                   ) in  hi
 gpio-62  (wifi_en_gpios       ) out hi
 gpio-63  (blue:GPIOB31        ) out lo
 gpio-66  (card_detect_gpio    ) in  lo
 gpio-120 (pwdn-front-gpios    ) out hi
 gpio-121 (reset-gpios         ) out hi
 gpio-124 (pwdn-rear-gpios     ) out hi
 gpio-125 (actions,atm7059tc-us) out lo
 gpio-126 (wifi_bt_power_gpios ) out hi
 gpio-127 (phy_reset_gpio      ) out hi
 
GPIOs 241-247, platform/atc2603c-sgpio.0, atc2603c-sgpio-chip, can sleep:
 
GPIOs 248-255, platform/atc2603c-gpio.0, atc260x-gpio-chip, can sleep:


查看PWM信息

cd /sys/kernel/debug/
cat pwm
platform/b01b0050.pwm, 6 PWM devices
 pwm-0   (backlight           ): requested enabled
 pwm-1   (vdd-gpu-dcdc        ): requested enabled
 pwm-2   (vdd-core-dcdc       ): requested enabled
 pwm-3   (ext_dcdc_pwm_ctl    ): requested enabled
 pwm-4   ((null)              ):
 pwm-5   ((null)              ):


查看mmc信息

cd /sys/kernel/debug/mmcx
cat ios 
clock:          50000000 Hz
vdd:            15 (2.7 ~ 2.8 V)
bus mode:       2 (push-pull)
chip select:    0 (don't care)
power mode:     2 (on)
bus width:      2 (4 bits)
timing spec:    5 (sd uhs SDR50)
signal voltage: 0 (1.80 V)
mmcx represents mmc0, mmc1, mmc2…


查看USB设备信息

如果连接了USB设备到LeMaker Guitar,使用下面命令查看USB设备相关信息:

cd /sys/kernel/debug/usb
cat devices 
 
T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 3.10
S:  Manufacturer=Linux 3.10.37 aotg_hub_hcd
S:  Product=AOTG USB Host Controller Driver
S:  SerialNumber=aotg_hcd.1
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#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1976 ProdID=4082 Rev= 1.00
S:  Manufacturer=ChipsBnk
S:  Product=USB Reader
S:  SerialNumber=110074973765
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms


另请参阅

  1. https://www.kernel.org/doc/Documentation/filesystems/debugfs.txt