Results 1 to 5 of 5

Thread: Problem with re-compiling kernel modules

  1. #1

    Default Problem with re-compiling kernel modules

    Hi all,

    I'm trying to re-compile a module from the Linux kernel source. The module is compiled on the machine that it's supposed to run on. I'm also running the kernel, I'm compiling the module for.

    Compiling seems to work without problems, but trying to insert the module gives the following error messages:
    Code:
    box:/usr/src/linux # insmod drivers/media/dvb-frontends/rtl2830.ko
    insmod: error inserting 'drivers/media/dvb-frontends/rtl2830.ko': -1 Invalid module format
    
    box:/usr/src/linux # tail -1 /var/log/messages
    2014-02-06T22:48:19.379714+01:00 box kernel: [28302.526141] rtl2830: no symbol version for module_layout

    What am I doing wrong?


    Here's what I did line by line:
    Code:
    box:/ # cd /usr/src/linux
    [...]
    box:/usr/src/linux # make mrproper
    [...]
    box:/usr/src/linux # make cloneconfig
    [...]
    box:/usr/src/linux # make modules_prepare
    [...]
    box:/usr/src/linux # make drivers/media/dvb-frontends/rtl2830.ko
    make[1]: Nothing to be done for `all'.
    make[1]: Nothing to be done for `relocs'.
      CHK     include/generated/uapi/linux/version.h
      CHK     include/generated/utsrelease.h
      CALL    scripts/checksyscalls.sh
      CC [M]  drivers/media/dvb-frontends/rtl2830.o
      MODPOST 1 modules
      CC      drivers/media/dvb-frontends/rtl2830.mod.o
      LD [M]  drivers/media/dvb-frontends/rtl2830.ko
    
    box:/usr/src/linux # lsmod | grep rtl
    
    box:/usr/src/linux # insmod drivers/media/dvb-frontends/rtl2830.ko
    insmod: error inserting 'drivers/media/dvb-frontends/rtl2830.ko': -1 Invalid module format
    
    box:/usr/src/linux # tail -1 /var/log/messages
    2014-02-06T22:48:19.379714+01:00 box kernel: [28302.526141] rtl2830: no symbol version for module_layout
    This is the system I'm trying this on:
    Code:
    box:~> lsb-release -d
    Description:    openSUSE 13.1 (Bottle) (x86_64)
    
    box:~> uname -a
    Linux box 3.11.6-4-desktop #1 SMP PREEMPT Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) x86_64 x86_64 x86_64 GNU/Linux
    
    box:~> rpm -qa kernel\*
    kernel-default-devel-3.11.6-4.1.x86_64
    kernel-desktop-3.11.6-4.1.x86_64
    kernel-desktop-devel-3.11.6-4.1.x86_64
    kernel-devel-3.11.6-4.1.noarch
    kernel-firmware-20130714git-2.5.1.noarch
    kernel-source-3.11.6-4.1.noarch
    kernel-syms-3.11.6-4.1.x86_64
    kernel-xen-devel-3.11.6-4.1.x86_64

    Any hints or pointers are much appreciated!


    TIA -- Till

  2. #2
    Join Date
    Sep 2012
    Posts
    7,096

    Default Re: Problem with re-compiling kernel modules

    Quote Originally Posted by tdoerges View Post
    What am I doing wrong?
    Most likely this

    Code:
    box:/ # cd /usr/src/linux
    [...]
    box:/usr/src/linux # make mrproper
    This destroys existing kernel development environment which is fully prepared for building external modules.
    Never build kernel module as root and never do it in system directories. You should build it in in local directory. Something like
    Code:
    make -C /usr/src/linux M=$PWD

  3. #3

    Default Re: Problem with re-compiling kernel modules

    Hi,

    thanks for the quick reply.

    Quote Originally Posted by arvidjaar View Post
    Most likely this

    Code:
    box:/ # cd /usr/src/linux
    [...]
    box:/usr/src/linux # make mrproper
    This destroys existing kernel development environment which is fully prepared for building external modules.
    After a clean install of the Kernel sources I tried the above without mrproper: No difference.

    Quote Originally Posted by arvidjaar View Post
    Never build kernel module as root and never do it in system directories. You should build it in in local directory. Something like
    Code:
    make -C /usr/src/linux M=$PWD
    AFAIK this is what you do for external kernel modules. (And it has worked before for me.) But I would like to re-compile an internal (in-tree) kernel module.

    Regards, Till

  4. #4
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Problem with re-compiling kernel modules

    On 2014-02-09 21:36, tdoerges wrote:
    > AFAIK this is what you do for *external* kernel modules. (And it has
    > worked before for me.) But I would like to re-compile an *internal
    > (in-tree)* kernel module.


    What I normally do, after installing the opensuse kernel sources, is to
    run "make cloneconfig". Then I change things (including giving the
    kernel a different name, in "make menuconfig"), and then build the
    kernel (make) and modules.

    Finally I install that kernel (which has a different name than -desktop).


    In order to build as user, I change the permissions of the tree.

    --
    Cheers / Saludos,

    Carlos E. R.

    (from 13.1 x86_64 "Bottle" (Minas Tirith))

  5. #5

    Default Re: Problem with re-compiling kernel modules

    Hi,

    I did some more digging and came up with a working solution. /usr/share/doc/packages/kernel-source/README.SUSE explains several ways of compiling modules, one of which worked for my case.


    The two key ideas are that you have to treat the internal kernel modules as external modules, too, and that you have to use the packages kernel-syms and kernel-$flavour-devel.

    After installing the packages
    Code:
    box:~ #zypper install kernel-desktop-devel kernel-syms
    you can compile all modules in the directory using
    Code:
    box:/usr/src/linux/drivers/media/dvb-frontends # make -C /usr/src/linux-obj/x86_64/desktop M=$(pwd)
    Just compiling one module should work like this:
    Code:
    box:/usr/src/linux/drivers/media/dvb-frontends # make -C /usr/src/linux-obj/x86_64/desktop M=$(pwd) rtl2830.ko
    BTW, what tipped me off, was this warning, when trying to compile:
    Code:
    Symbol version dump /usr/src/linux-3.11.10-7/Module.symvers is missing; modules will have no dependencies and modversions.
    HTH, Till

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •