调试指南
TSensor 调试包含以下步骤:
- 调试开关在 luban 根目录下执行 make kernel-menuconfig,进入 kernel 的功能配置,可以打开 TSensor 模块的 DEBUG 选项:
Linux Kernel hacking Artinchip Debug [*] Thermal Sensor driver debug
此 DEBUG 选项打开的影响:
- TSensor 驱动以-O0 编译
- TSensor 的 pr_dbg()和 dev_dbg()调试信息会被编译
在系统运行时,如果要打印 pr_dbg()和 dev_dbg()信息,还需要调整 loglevel 为 8,两个方法:
-
在 dts 中修改 bootargs,增加“loglevel=8”
-
在板子启动到 shell 后,执行命令:
echo8 > /proc/sys/kernel/printk
- Sysfs 节点状态信息在 TSensor 驱动初始化成功后,会在 Sysfs 中注册生成一个
status
节点,其中打印了当前的 TSensor 配置及状态信息:# cat /sys/devices/platform/soc/19253000.tsen/status In Thermal Sensor V1.00: ch0: aic-tsen-cpu, Enable: 1, Value: 0 ch1: aic-tsen-adc, Enable: 1,Value: 0
- Sysfs 节点读取温度Linux Thermal 子系统提供一些 Sysfs 节点,可以用来获取温度值等操作。
# cd /sys/class/thermal/ [aic@thermal] # ls thermal_zone0 thermal_zone1 [aic@thermal] # cd thermal_zone0/ [aic@thermal_zone0] # ls available_policies k_po policy type hwmon0 k_pu slope uevent integral_cutoff mode subsystem k_d offset sustainable_power k_i passive temp [aic@thermal_zone0] # cat temp 0 [aic@thermal_zone0] # cat type aic-tsen-cpu