1、查看当前打印级别
# cat /proc/sys/kernel/printk
默认为:4 4 1 7
注释:第一个参数表示控制台log Level,第二个参数表示printk默认的logLevel
2、修改打印(数字之间用空格分开)
# echo 8 > /proc/sys/kernel/printk //这样串口才能打印数据
3、内核函数printk的打印级别宏定义:Include/linux/kernel.h
#define KERN_EMERG "" /* system is unusable */
#define KERN_ALERT "" /* action must be taken immediately */
#define KERN_CRIT "" /* critical conditions */
#define KERN_ERR "" /* error conditions */
#define KERN_WARNING "" /* warning conditions */
#define KERN_NOTICE "" /* normal but significant condition */
#define KERN_INFO "" /* informational */
#define KERN_DEBUG "" /* debug-level messages */
printk(KERN_ERR "xxxx---------> %s() " ,__FUNCTION__ );
4.高通系统启动打印串口log到控制台修改:
# adb pull /system/bin/enable_kernel_log.sh .
修改shell脚本后,push到/system/etc目录,重启设备
case "$console_config" in
"1")
echo "Enable console config to $console_config"
echo 0 > /proc/sys/kernel/printk
修改为:
echo 8 > /proc/sys/kernel/printk
;;
*)
echo "Enable console config to $console_config"
esac
而内核级别定义:
ap\kernel\msm-4.9\include\linux\kern_levels.h
可以直接修改
ap\kernel\msm-4.9\include\linux\kern_levels.h
来达到内核一直输出日志信息的目的。