今天终于将dev_dbg信息输出了,为了以后方便查找,特记录下来:
1、修改缺省信息的宏定义级别(kernel\include\linux\printk.h文件内):
/* printk's without a loglevel use this.. */ #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT /* We show everything that is MORE important than this.. */ #define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */ #define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */ #define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */ #define CONSOLE_LOGLEVEL_DEFAULT 8 /* anything MORE serious than KERN_DEBUG */ #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */ #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
//#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
将值改为8
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than KERN_DEBUG */
该行表示只有打印级别高于DEFAULT_CONSOLE_LOGLEVEL(值小于DEFAULT_CONSOLE_LOGLEVEL)的打印才会出现在终端上。
而 KERN_DEBUG也为7,所以我们的调试不会直接打印出来
kernel\include\linux\kern_levels.h
#define KERN_SOH "\001" /* ASCII Start Of Header */ #define KERN_SOH_ASCII '\001' #define KERN_EMERG KERN_SOH "0" /* system is unusable */ #define KERN_ALERT KERN_SOH "1" /* action must be taken immediately */ #define KERN_CRIT KERN_SOH "2" /* critical conditions */ #define KERN_ERR KERN_SOH "3" /* error conditions */ #define KERN_WARNING KERN_SOH "4" /* warning conditions */ #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */ #define KERN_INFO KERN_SOH "6" /* informational */ #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
2、在要输出dev_dbg信息的*.c文件的最前面添加:
#define DEBUG 1
因为dev_dbg的宏定义在kernel\include\linux\device.h,而这文件通常被其它文件引用,在本BSP内被kernel/include/linux/platform_device.h引用,因此必须在引用这头文件之前定义DEBUG。