https://blog.csdn.net/yusiguyuan/article/details/11144941
-
//刚下载的linux源代码,一个简单的hello驱动都没有编译通过
-
//下面是驱动源代码
-
#include <linux/init.h>
-
#include <linux/module.h>
-
static int hello_init(void)
-
{
-
printk(KERN_ALERT "Hello, Tekkaman Ninja !\n");
-
return 0;
-
}
-
static void hello_exit(void)
-
{
-
printk(KERN_ALERT "Goodbye, Tekkaman Ninja !\n Love Linux !Love ARM ! Love KeKe !\n");
-
}
-
module_init(hello_init);
-
module_exit(hello_exit);
-
MODULE_LICENSE("Dual BSD/GPL");
下面是简单的makefile文件
-
obj-m := hello.o
-
KERNELDIR = /home/xduser/study/driver/src/linux-2.6.22
-
PWD := $(shell pwd)
-
default:
-
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
但是却有错误
-
make[1]: Entering directory `/home/xduser/study/driver/src/linux-2.6.22'
-
ERROR: Kernel configuration is invalid.
-
include/linux/autoconf.h or include/config/auto.conf are missing.
-
Run 'make oldconfig && make prepare' on kernel src to fix it.
-
WARNING: Symbol version dump /home/xduser/study/driver/src/linux-2.6.22'/Module.symvers
-
is missing; modules will have no dependencies and modversions.
原因是内核没有编译,先处理内核
进入内核目录执行
1, make oldconfig
2, make prepare
3, make scripts
然后在执行make编译hello驱动即可