Linux

使已在 Fedora 上停用的核心模組可用

  • May 11, 2015

編輯:我把克里斯蒂安的回答變成了一個自動完成所有事情的腳本:https ://github.com/frans-fuerst/magic/blob/master/fedora-activate-can.sh

我需要一些在 Linux 原始碼中可用但在 Fedora 20 上停用的核心模組,我想知道使它們可用的最簡單和最先進的方法是什麼。(即 net/CAN 支持導致一些 can_* 模組)

  • 是否有使停用的模組可用的 fedora-repos/rpms?
  • 還是我必須手動編譯這些模組?
  • 在這種情況下 - 是否有一些機制可以在核心更新的情況下自動執行此操作,還是我必須一遍又一遍地編譯它們?

我已經遵循了這個HowTo(還有更多非常相似的方法),但是“僅建構模組”部分似乎僅適用於尚未禁用的模組,因為在這種情況下,甚至模組源都失去了。

這是我在提到的HowTo之後嘗試的方法:

首先,我嘗試遵循Out Of Tree Modules部分,但在附帶的該死的原始碼樹中,kernel-devel甚至缺少 CAN 支持的原始碼。所以我嘗試從 src.rpm 建構模組:

$ 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

然後我建構並收到一些警告:

$ 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

我究竟做錯了什麼?

我想我明白了,儘管它可能遠非完美。

  1. 通過執行準備原始碼
rpmbuild -bp --target=$(uname -m) kernel.spec
  1. 轉到建構目錄,例如:
cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64
  1. 編輯Makefile並設置EXTRAVERSION為:
EXTRAVERSION = -200.fc20.x86_64
  1. 啟用模組。我建議從目錄下的相應文件開始configs(我用過kernel-3.14.8-x86_64.config)。
  2. 為模組準備核心:
make modules_prepare
  1. 建構模組:
make M=drivers/net/can
  1. 利潤!插入模組:
insmod can-dev.ko

引用自:https://serverfault.com/questions/606069