I am trying the linux device programming but run into a strange problem. For all of my printk lines, it will always display twice on the console.
For example, here is my helloworld driver program:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk("<1> Hello world!\n");
return 0;
}
static void hello_exit(void) {
printk("<1> Bye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Here is my make file:
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR := /gumstix/linux-2.6.21gum/
PWD := $(shell pwd)
ARCH := arm
CROSS := arm-linux-
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) clean
endif
When I load the driver, it will show the message twice. The second time will always give some annoying prefix information which I don't need!
# insmod hello.ko
Hello world!
# Oct 31 10:16:35 gumstix user.alert kernel: Hello world!
And I tried changing the printk configuration, it will only supress the first message (see below). and 'dmesg -n 1' has the same result.
# echo 0 0 0 0 > /proc/sys/kernel/printk
# insmod hello.ko
# Oct 31 10:29:58 gumstix user.alert kernel: Hello world!
Can any one tell me why this prefix information (timestamp + "gumstix user.alert kernel:") shows up all the time? How to remove it if possible? Many thanks.
Here below is a summary of my environment:
kernel: linux-2.6.21
qemu: QEMU PC emulator version 0.9.1