FeroxCannibal
Posts: 38
Joined: Fri Apr 28, 2017 8:00 am

Compiling modules with a custom kernel don't work

Wed Dec 06, 2017 8:01 am

Hello friends,

I recently compiled a kernel by myself after the instructions from the kernel building guide. I also configured the kernel with some custom flags. I turned on device drivers/sound card support/also/debug options.

After that I installed the modules copied the zImage and the device trees (plus overlays) and everything booted up.

Now comes my problem: I need to compile some .Ko modules to run a hardware. That's why I installed the same version kernel headers. After the compilation I get an error with the compiled modules.

"Disagrees with version of ...."
"Can't find symbol ... "

After some research I found out it seems that I don't even need the same numerical version but also the same configuration. Since the kernel has other flags than the vanilla headers.

First I tried to just edit the config and then compile but it didn't helped. After that I packed the header folder in a tar from the build machine and extracted it on the pi. Because I don't want to compile it on the slow pi :D but this didn't helped either.

What am I missing here? Thanks a lot for your help!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Compiling modules with a custom kernel don't work

Wed Dec 06, 2017 10:10 pm

Have you worked through this guide? https://github.com/raspberrypi/linux/bl ... odules.txt

Notice particularly the part about Module.symvers.

sparkie777
Posts: 121
Joined: Tue Nov 27, 2012 4:37 am

Re: Compiling modules with a custom kernel don't work

Thu Dec 07, 2017 3:41 am

what kernel do you use?

- a kernel installed by means of the 'raspberrypi-kernel' package?
- a kernel installed by means of Hexxeh's 'rpi-update'?

both methods are covered here:
How compile a loadable kernel module without recompiling kernel - Raspberry Pi Stack Exchange

FeroxCannibal
Posts: 38
Joined: Fri Apr 28, 2017 8:00 am

Re: Compiling modules with a custom kernel don't work

Thu Dec 07, 2017 8:43 am

As I said I compiled a kernel by myself since I nedt the ALSA xrun_debug flags (https://www.alsa-project.org/main/index.php/XRUN_Debug). Therefore I git cloned rasppi kernel headers in version 4.9.66-v7 which my kernel also shows right now. At the pi itself I downloaded the headers at https://www.niksula.hut.fi/~mhiienka/Rp ... aders-rpi/ in version 4.9.66-v7 and run dpkg -i .

Since at an older kernel version my modules worked I can explain my process so far:

I have a simple Makefile for one goal module, and run make -C /usr/src/lin.....4.9.66-v7 M=($PWD) modules something like this. After that I copy them into /lib/module/4.9.66-v7/kernel/sound/soc/codecs and run depmod. Looking into the modules.dep file at /lib/modules/4.9.66-v7/ level I have both .ko files with all the dependent other modules. Also I checked the Modules.symvers file and I have for example the snd_soc_register_codec symbol there. Thats why I even more believe that it has something to do with the custom kernel flags I set which werent at first in the downloaded sources if you know what I mean.
This indicates you have compiled the module against a different version of the kernel than is running. Note that even if the running kernel and kernel source have the same numerical value (e.g. both are 2.6.31-20-server), if the two use different configuration options, you may see this error. Also check if there are multiple versions of this module on the machine and ensure you are loading the correct one.
https://stackoverflow.com/questions/272 ... patibility

Edit: With being in the 4.9.66-v7/kernel/.../codecs/ folder running insmod file.ko I make sure that it is the correct one, dont I? Because as I say I once had an other version of this module but with the 4.9.30-v7 version compiled.

FeroxCannibal
Posts: 38
Joined: Fri Apr 28, 2017 8:00 am

Re: Compiling modules with a custom kernel don't work

Mon Dec 11, 2017 9:13 pm

To close this thread, I compiled the modules on the build machine and this worked. But I am kind of angry why cant I use the /lib/modules/..../build folder?

Return to “Advanced users”