内核版本:2.6.10 在/home/tmp/下建立两个文件hello.c,Makefile hello.c ------------ #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> MODULE_LICENSE("GPL"); static int hello_init(void) { printk(KERN_ALERT "hello module init\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "hello module exit\n"); } module_init(hello_init); module_exit(hello_exit); -------------- Makefile ---------- ifneq ($(KERNELRELEASE),) obj-m := hello.o else KERNELDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules endif clean: rm -f *.ko *.mod.c *.mod.o *.o ----------- 编译模块 #make 清除 #make clean ----------- 为了能够在终端显示信息,要修改 /lib/modules/2.6.10/build/include/linux/kernel.h 文件的KERN_ALERT宏。 #define KERN_ALERT "<1>" 修改为 #define KERN_ALERT "<0>" ...... 点击查看原文:http://www.hzlitai.com.cn/article/ARM9-article/system/1773.html

评论