编辑 :我把克里斯蒂安答案变成一个脚本,它会自动执行一切: https : //github.com/frans-fuerst/magic/blob/master/fedora-activate-can.sh
我需要一些在Linux源代码中可用的内核模块,但在Fedora 20上停用,我不知道什么是最简单和最前沿的方式来使它们可用。 (即networking/ CAN支持导致一些can_ *模块)
我已经遵循这个 HowTo(还有更多非常类似的东西),但是“ 仅构build一个模块 ”部分似乎只适用于未被禁用的模块,因为在这种情况下,即使模块源也缺失。
这是我试图按照提到的方法 :
首先,我试图按照Out of Tree Modules部分,但是在kernel-devel附带的那个该死的源代码树中,甚至缺less了CAN支持的源代码。 所以我尝试从src.rpm构build模块:
$ yumdownloader --source kernel $ sudo yum-builddep kernel-3.14.8-200.fc20.src.rpm $ rpm -Uvh kernel-3.14.8-200.fc20.src.rpm $ cd ~/rpmbuild/SPECS $ rpmbuild -bp --target=$(uname -m) kernel.special $ cd ~/rpmbuild/BUILD/<kerneldir>/<linuxdir> $ <configure the kernel using menuconfig> $ make prepare
然后我build立并得到一些警告:
$ make -C /lib/modules/`uname -r`/build M=`pwd`/net/can modules make: Entering directory `<rpmbuild-BUILD-kernel-linux-dir>' WARNING: Symbol version dump <rpmbuild-BUILD-kernel-linux-dir>/Module.symvers is missing; modules will have no dependencies and modversions. CC [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/bcm.o CC [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/gw.o CC [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/raw.o CC [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/af_can.o CC [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/proc.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.o Building modules, stage 2. MODPOST 4 modules CC <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.mod.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.ko CC <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.mod.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.ko CC <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.mod.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.ko CC <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.mod.o LD [M] <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.ko make: Leaving directory `<rpmbuild-BUILD-kernel-linux-dir>' $ sudo make -C /lib/modules/`uname -r`/build M=`pwd`/net/can modules_install make: Entering directory `<rpmbuild-BUILD-kernel-linux-dir>' INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.ko Can't read private key INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.ko Can't read private key INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.ko Can't read private key INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.ko Can't read private key DEPMOD 3.14.8 make: Leaving directory `<rpmbuild-BUILD-kernel-linux-dir>'
当我运行make modules时,我没有得到第一个警告,但是这花了我大约一个小时。
但安装后, .ko文件位于错误的目录( /usr/lib/modules/3.14.8而不是/usr/lib/modules/3.14.8-200.fc20.x86_64 ),并在depmod -a和我可以得到modprobe can
modprobe: ERROR: could not insert 'can': Exec format error
我究竟做错了什么?
我想我知道了,尽pipe可能还远远不够完美。
通过运行来准备源代码
rpmbuild -bp --target=$(uname -m) kernel.spec
转到生成目录,例如:
cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64
编辑Makefile并将EXTRAVERSION设置为如下所示:
EXTRAVERSION = -200.fc20.x86_64
启用模块。 我build议从configs目录下的相应文件开始(我使用的是kernel-3.14.8-x86_64.config )。
准备模块的内核:
make modules_prepare
构build模块:
make M=drivers/net/can
利润! 插入模块:
insmod can-dev.ko
为了完整起见,这里有一个完整的步骤列表,你需要使得已经在Fedora上禁用的CAN模块(或任何其他模块)可用(删除源代码,所以只使用kernel-devel-approach不行)。
这个过程可能并不完美,但对我来说peak_usb ,并且启用了peak_usb和vcan以及Fedora上的CAN模块。
我将不胜感激,因为我将经常这样做。
你可能想要现在更新你的内核,以便不必执行两次
sudo yum update reboot
准备,获取并安装Fedora内核源代码树
rpmdev-setuptree yumdownloader --source kernel sudo yum-builddep kernel-3.14.8-200.fc20.src.rpm rpm -Uvh kernel-3.14.8-200.fc20.src.rpm cd ~/rpmbuild/SPECS rpmbuild -bp --target=$(uname -m) kernel.spec
编辑Makefile并将EXTRAVERSION设置为如下所示:
cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64 EXTRAVERSION = -200.fc20.x86_64
通过首先获取基本configuration来configuration内核,例如
cp /boot/config-3.14.8-200.fc20.x86_64 .config
要么
cp configs/kernel-3.14.8-x86_64.config .config
并通过激活所需的模块进行configuration,例如
make menuconfig
构build模块
make modules_prepare make M=net/can modules make M=drivers/net/can modules
安装并加载
sudo make M=net/can modules_install sudo make M=drivers/net/can modules_install sudo depmod -a sudo modprobe can