内核中的 dev_emerg/dev_alert/dev_crit/dev_err/dev_warn/dev_notice/_dev_info_adaptiver的博客-CSDN博客
使用:
Linux内核中dev_info、dev_dbg、dev_err及动态调试_轩阁楼主的博客-CSDN博客_dev_info linux
笔记:
1、mount命令查看debugfs文件系统是否被挂载
2、dev_info,dev_err信息可以直接在串口中打印出来;
dev_dbg查看打印信息:
a、echo -n "file xxx.c +p" > control
b、dmesg(只能在这里面看到,dmesg打印从内核开始到现在为止的所有内核打印信息)
3、测试程序:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/err.h>
#include <linux/uaccess.h>
#include <linux/platform_device.h>
#include <linux/kthread.h>
struct task_struct *dbg_task;
struct platform_device* pdev;
static int dbg_thread(void *data)
{
while (!kthread_should_stop())
{
dev_dbg(NULL,"songhp dbg print test\n");
mdelay(2000);
}
return 0;
}
static int __init printk_test_init(void)
{
dev_info(NULL,"songhp info print test\n");
dbg_task = kthread_run(dbg_thread, NULL, "dbg_t");
dev_err(NULL,"songhp err print test\n");
return 0;
}
static void __exit printk_test_exit(void)
{
return;
}
module_init(printk_test_init);
module_exit(printk_test_exit);