AnsweredAssumed Answered

Unable to insert module -- no /lib/module/`uname -r`

Question asked by tgm on Mar 8, 2018
Latest reply on Mar 9, 2018 by tgm

I've got a Zed Board (xc7z020clg484-1, Rev. D) coupled with Analog Devices AD-FCOMMS2-FBZ, it runs an ADI provided Linux (SD card image: 2016 2015_R2-2016_03_15.img)

Details:

analog@analog:~$ uname -a
Linux analog 4.0.0-g5e6cec4 #35 SMP PREEMPT Tue Mar 15 15:27:20 GMT 2016 armv7l armv7l armv7l GNU/Linux
analog@analog:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Linaro
Description: Linaro 14.04
Release: 14.04
Codename: trusty

I've compiled a simple module example from this site: https://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN323 against Linux kernel obtained from: https://github.com/analogdevicesinc/linux.git commit: 5e6cec4 (which is the exact commit of the kernel used by ADI on their SD card, letter 'g' is added for some reason I don't know, but this is not important), modinfo of the compiled module is:

analog@analog:~$ modinfo hello-5.ko 
filename: /home/analog/hello-5.ko
description: Hello module
author: tgm
license: GPL
depends:
vermagic: 4.0.0-xilinx-g5e6cec4 SMP preempt mod_unload modversions ARMv7 p2v8
parm: number:A number printed when loading module (int)
parm: text:A string printed when loading module (charp)

After unsuccessful module inserting attempt, the response is:

analog@analog:~$ sudo modprobe --force-vermagic hello-5.ko
modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.0.0-g5e6cec4/modules.dep.bin'

Nothing is logged in dmesg -- it probably fails at the directory look-up stage.

There is no /lib/module directory at all.

I've also tried:

analog@analog:~$ sudo insmod hello-5.ko 
insmod: ERROR: could not insert module hello-5.ko: Invalid module format

The dmesg returns:

analog@analog:~$ dmesg | tail -1
hello_5: disagrees about version of symbol module_layout

I thought that it is because the "xilinx" part in the vermagic, so I've tried adding:

 

MODULE_INFO(vermagic, "4.0.0-g5e6cec4 SMP preempt mod_unload modversions ARMv7 p2v8 ");

to the source code, after that modinfo changed to:

analog@analog:~$ modinfo hello-5.ko 
filename: /home/analog/hello-5.ko
vermagic: 4.0.0-g5e6cec4 SMP preempt mod_unload modversions ARMv7 p2v8
description: Hello module
author: tgm
license: GPL
depends:
vermagic: 4.0.0-xilinx-g5e6cec4 SMP preempt mod_unload modversions ARMv7 p2v8
parm: number:A number printed when loading module (int)
parm: text:A string printed when loading module (charp)

Note that there two vermagics now, I'm not sure why, but that's how it looks after compiling.

The error messages from modprobe and insmod are exactly the same, as well as the result of dmesg | tail.

 

And just to ensure that I'm using the right toolchain:

analog@analog:~$ file hello-5.ko
hello-5.ko: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), BuildID[sha1]=415373f715d807eff1737b2d4c383bf389f4954e, not stripped

 

Now question.

1. How can I insert the module into the kernel?

2. Am I doing something wrong? If so what?

3. Where's the /lib/modules directory?

4. Why it cannot be loaded even with the --force-modversion to the modprobe? Is it because there is no /lib/moduels directory?

5. Why insmod cannot load the module into the kernel even when I change the the vermagic?

 

Note that

analog@analog:~$ uname -r
4.0.0-g5e6cec4

is the same as the commit I've found in the ADI's git repository.

 

And just for the convenience:

analog@analog:~$ lsha /lib | grep modul
drwxr-xr-x 2 root root 4.0K Jan 1 1970 modules-load.d

Note that there is no /lib/modules directory, not to mention /lib/modules/`uname -r`

 

-- TGM

Outcomes