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:


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:


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:


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

Most likely this

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

make -C /usr/src/linux M=$PWD

Hi,

thanks for the quick reply.

After a clean install of the Kernel sources I tried the above without mrproper: No difference.

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

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))

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

box:~ #zypper install kernel-desktop-devel kernel-syms

you can compile all modules in the directory using

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:

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:

Symbol version dump /usr/src/linux-3.11.10-7/Module.symvers is missing; modules will have no dependencies and modversions.

HTH, Till