LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   printk not working when i do insmod (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/printk-not-working-when-i-do-insmod-706235/)

KernelPanick 02-20-2009 12:06 PM

printk not working when i do insmod
 
#include<linux/init.h>
2 #include<linux/module.h>
3 #include<asm/current.h>
4 #include<linux/sched.h>
5
6 MODULE_LICENSE("GPL");
7
8
9 static int hello_init(void)
10 {
11 printk("Module Inserted\n");
12 printk(KERN_NOTICE "The process is \"%s\" (pid %i)\n", current->comm, current->pid);
13 return 0;
14 }
15
16 static void hello_exit(void)
17 {
18 printk(KERN_EMERG "Module removed\n");
19 }
20
21 module_init(hello_init);
22 module_exit(hello_exit);


this is a very simple program. when i do insmod, message is not displayed on screen. i have already done
echo 8 > /proc/sys/kernel/printk
but no effect. The module gets inserted correctly though. I am using suse 11.0. Please help.

paulsm4 02-20-2009 12:58 PM

Hi -

Your logging levels probably just aren't configured to see the output.

Try this (then try your "insmod" again):
Quote:

cat /proc/sys/kernel/printk
echo 8 > /proc/sys/kernel/printk
cat /proc/sys/kernel/printk
You can read more about it here (search for "printk"):

http://www.win.tue.nl/~aeb/linux/lk/lk-2.html

http://www.linux.it/~rubini/docs/sysctl/

http://lkml.indiana.edu/hypermail/li...04.3/0681.html

'Hope that helps .. PSM

KernelPanick 02-21-2009 08:00 AM

Thanks paulsm4 for your valuable reply.
I checked the value of loglevel after echo and it is set correctly to 8.

I found out that all kernel messages are diverted to virtual console F10 (ctr + alt + F10).
(if "echo 8 > /proc/sys/kernel/printk" is not done to change loglevel, the messg is not even displayed there.)
One solution is to run command: "dmesg"
Now I am searching for how I can get the messages on current console. I should be able to see the message on any of current virtual terminals 1 to 6, whichever I am using to do "insmod".

thanks in advance.


All times are GMT -5. The time now is 11:20 PM.