The linux driver layer outputs dev_dbg print information

Today, I finally output the dev_dbg information. For the convenience of searching in the future, I specially record it:

1. Modify the macro definition level of the default information (in the kernel\include\linux\printk.h file):

/* 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 */

Change the value to 8

#define DEFAULT_CONSOLE_LOGLEVEL  8 /* anything MORE serious than KERN_DEBUG */

This line indicates that only prints with a print level higher than DEFAULT_CONSOLE_LOGLEVEL (with a value smaller than DEFAULT_CONSOLE_LOGLEVEL ) will appear on the terminal.

And KERN_DEBUG is also 7, so our debugging will not be printed directly

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. Add at the front of the *.c file to output dev_dbg information:

#define DEBUG 1

Because the macro definition of dev_dbg is in kernel\include\linux\device.h, and this file is usually referenced by other files, it is referenced by kernel/include/linux/platform_device.h in this BSP, so it must be defined before referencing this header file DEBUG.

Guess you like

Origin blog.csdn.net/xiaowang_lj/article/details/131979810