基于Ubuntu 12.10,编译Linux驱动程序
1. 准备linux内核源码
此时,我要编译的驱动是基于Ubuntu 12.10内核的,所以我下载的是其对应的内核源码包:
linux_3.5.0-17.28.diff.gz
linux_3.5.0-17.28.dsc
linux_3.5.0.orig.tar.gz
使用命令dpkg-source -x linux_3.5.0-17.28.dsc解压内核源码包,并将diff包中的patch打上。
2. 设置内核源码正确的路径
# cd /root/linux-3.5.0
# ln -s /root/linux-3.5.0 /lib/modules/3.5.0-17-generic/build
3. 编译驱动程序
# cd /root/wifidriver
# make build
此时,可能遇到如下问题:
make[1]: Entering directory `/root/linux-3.5.0' ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it. WARNING: Symbol version dump /root/linux-3.5.0/Module.symvers is missing; modules will have no dependencies and modversions.Building modules, stage 2. /root/linux-3.5.0/scripts/Makefile.modpost:42: include/config/auto.conf: No such file or directory make[2]: *** No rule to make target `include/config/auto.conf'. Stop. make[1]: *** [modules] Error 2 make[1]: Leaving directory `/root/linux-3.5.0' make: *** [default] Error 2 |
其中一个ERROR,需执行make oldconfig && make prepare
其中一个WARNING,需将/usr/src/linux-headers-3.5.0-17-generic/Module.symvers复 制到/root/linux-3.5.0中,然后执行make oldconfig && make prepare && make scripts