Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need some kernel modules which are available in the Linux source but deactivated on Fedora 20 and I wonder what's the easiest and most forward way to do make them available. (namely then net/CAN suport resulting in some can_* modules)

  • are there fedora-repos/rpms which make deactivated modules available?
  • or do I have to compile these modules manually?
  • in this case - is there some mechanism to automate this in case of a kernel update or do i have to compile them over and over again?

I've already followed this HowTo (and there are many more very similar out there) but the "build a module only" section seems to work only for modules which haven't been disabled because in that case even the module sources are missing.

Here is what I tried following the mentioned HowTo:

First I tried to follow the Out Of Tree Modules section but in that damn source tree shipped with kernel-devel even the sources for CAN support are missing. So I try to build the modules from the 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

Then I build and get some warnings:

$ 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>'

I don't get the first warning when I just run make modules but this costs me about an hour.

However after installing, the .ko files are located in the wrong directory (/usr/lib/modules/3.14.8 rather than /usr/lib/modules/3.14.8-200.fc20.x86_64) and after depmod -a and modprobe can I get

modprobe: ERROR: could not insert 'can': Exec format error

What am I doing wrong?

share|improve this question
    
Are the modules that you want included in the src.rpm? If so, why not install the src.rpm, patch the .config to enable them and then build the RPM? You could also probably build just those modules by following the "Building Only Kernel Modules (Out Of Tree Modules)" section of that howto. –  Cristian Ciupitu Jun 23 '14 at 11:57
    
I did so. But maybe I need some detailed instructions for that. I'm unable to just build the required modules running make M='pwd'/net/can modules. I get WARNING: Symbol version dump <DIR>/Module.symvers is missing; modules will have no dependencies and modversions. When I just run make modules the modules are built but I can't install them to the correct location. When I copy them manually and try to load them I get modprobe: ERROR: could not insert 'can': Exec format error –  frans Jun 23 '14 at 12:04
    
There's a similar question on Ask Ubuntu: "How do I build a single in-tree kernel module?" (and it also happens to be about CONFIG_CAN_PEAK_USB). –  Cristian Ciupitu Jun 23 '14 at 14:14
    
Unfortunately this is a different situation - On Ubuntu everything is fine because the source for the CAN modules exists. The .symvers file shipped with Fedora does not contain information about the CAN modules. Looks like I have to migrate to Ubuntu if I don't want to compile very single kernel which is being released.. –  frans Jun 23 '14 at 14:27

2 Answers 2

up vote 5 down vote accepted
+50

I think I got it, although it's probably far from perfect.

  1. Prepare the source code by running

    rpmbuild -bp --target=$(uname -m) kernel.spec
    
  2. Go to the build directory, for example by:

    cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64
    
  3. Edit Makefile and set EXTRAVERSION to something like:

    EXTRAVERSION = -200.fc20.x86_64
    
  4. Enable the modules. I suggest starting with the corresponding file underneath the configs directory (I used kernel-3.14.8-x86_64.config).

  5. Prepare the kernel for modules:

    make modules_prepare
    
  6. Build the module:

    make M=drivers/net/can
    
  7. Profit! Insert the module:

    insmod can-dev.ko
    
share|improve this answer
    
I'll check this tomorrow and in case that works you really deserve this bounty :) But at the same time I'm really gutted about how Fedora treats people who want to modify their system.. bugzilla.redhat.com/show_bug.cgi?id=871655 also demonstrates this attitude. –  frans Jun 23 '14 at 19:18
    
Markdown links are vice-versa [...](...). You could request to include the modules in the kernel-modules-extra package (although they're probably gonna refuse on the same grounds) or perhaps ask the guys from RPM Fusion. –  Cristian Ciupitu Jun 23 '14 at 19:21

For the sake of completeness here is a complete list of steps you need to make the CAN modules (or any other module) available which has been disabled on Fedora (removing the sources, so just using the kernel-devel-approach does not do it).

This procedure might not be perfect but it works for me and enables peak_usb and vcan as well as base CAN modules on Fedora.

Improvements are appreciated and will be honored since I will have to do this very often..

  1. you might want to update your kernel now in order to not having to do it twice

    sudo yum update
    reboot
    
  2. prepare, get and install the Fedora kernel source tree

    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
    
  3. Edit Makefile and set EXTRAVERSION to something like:

    cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64
    EXTRAVERSION = -200.fc20.x86_64
    
  4. Configure the kernel by first fetching a base configuration e.g.

    cp /boot/config-3.14.8-200.fc20.x86_64 .config
    

    or

    cp configs/kernel-3.14.8-x86_64.config .config
    

    and configure it by activating the needed modules, e.g.

    make menuconfig
    
  5. Build the modules

    make modules_prepare
    make M=net/can modules
    make M=drivers/net/can modules
    
  6. Install and load

    sudo make M=net/can modules_install
    sudo make M=drivers/net/can modules_install
    sudo depmod -a
    sudo modprobe can
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.