(OK) 编译 Android, 打印 内核信息 - pr_info - pr_notice


修改内核源代码:

-------------------------------
add pr_*
-------------------------------
	pr_emerg("%s: unable to restart system\n", __func__);
	pr_alert("%s: SGE packet mismatch\n", adapter->name);
	pr_crit("%s: cannot initialize default policy table: %d\n", __func__, err);
	pr_err("%s: Couldn't initialize inode slabcache\n", __func__);
	pr_warn("Freeing alive inet6 address %p\n", ifp);
	pr_notice("delayed DAD work was pending while freeing ifa=%p\n", ifp);
	pr_info("%s: use_tempaddr is disabled\n", __func__);
	pr_debug("%s\n", __func__);

-------------------------------
can use printk
-------------------------------
	printk(KERN_DEBUG "MPTCP - %s: %d: %s\n", __FILE__, __LINE__, __func__ );
	printk(KERN_INFO "MPTCP - %s: %d: %s\n", __FILE__, __LINE__, __func__ );

	// printk("%02x ", data[i]);
	// printk("\n");
	sed -i "s/printk(KERN_DEBUG \"MPTCP/printk(KERN_INFO \"MPTCP/g" `grep "printk(KERN_DEBUG \"MPTCP" -rl ./`
-------------------------------
#define KERN_EMERG "<0>" /* system is unusable*/
#define KERN_ALERT "<1>" /* action must be taken immediately*/
#define KERN_CRIT "<2>" /* critical conditions*/
#define KERN_ERR "<3>" /* error conditions*/
#define KERN_WARNING "<4>" /* warning conditions*/
#define KERN_NOTICE "<5>" /* normal but significant condition*/
#define KERN_INFO "<6>" /* informational*/
#define KERN_DEBUG "<7>" /* debug-level messages*/
-------------------------------


启动 Android,执行下面命令:

//// To determine your current console_loglevel you simply enter:

# cat /proc/sys/kernel/printk
	7       4       1       7
	current	default	minimum	boot-time-default

//// To change your current console_loglevel simply write to this file, 
//// so in orderto get all messages printed to the console do a simple
//// and every kernel message will appear on your console.
# echo 7 > /proc/sys/kernel/printk
or
# dmesg -n 7


cat /proc/kmsg


adb -s 192.168.56.3 shell cat /proc/kmsg






posted @ 2016-09-22 23:41  张同光  阅读(837)  评论(0编辑  收藏  举报