Enable/Disable pr_debug in Linux Device Driver

By default, the pr_debug messages are disabled. Consider the below sample code:


#include <linux/module.h>
#include <linux/kernel.h>
static int myinit(void)
{
pr_alert("pr_alert\n");
pr_crit("pr_crit\n");
pr_err("pr_err");
pr_warning("pr_warning\n");
pr_notice("pr_notice\n");
pr_info("pr_info\n");
pr_debug("pr_debug\n");
return 0;
}
static void myexit(void) { }
module_init(myinit)
module_exit(myexit)
MODULE_LICENSE("GPL");
view raw hello.c hosted with ❤ by GitHub
Output:


You can see, pr_debug log was not displayed on the dmesg output.


To enable debugging output, build the appropriate file with -DDEBUG by adding
CFLAGS_[filename].o := -DDEBUG to the Makefile


Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto