Jump to content

Loading custom kernel module


mmax

Recommended Posts

Hi,

 

I am trying to write my own kernel module/drive for the NanoPi air, running a self-compiled version of armbian 5.83. Actually I only added the PREEMTION option to get real-time behavior when reading/writing from IO pins. I started using the "hello world" template from here. To get the module compiled I had to build the headers for my kernel as well using the option INSTALL_HEADERS in the armbian-build config file. The build debian-package called "linux-headers-next-sunxi_5.83_armhf.deb" was copied and installed on the NanoPi.

 

OK, so now compiling (on the NanoPi - so no cross-compilation) works like a charm:

> make
make -C /lib/modules/4.19.36-sunxi/build M=/home/gresy/Examples modules
make[1]: Entering directory '/usr/src/linux-headers-4.19.36-sunxi'
  CC [M]  /home/gresy/Examples/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/gresy/Examples/hello.mod.o
  LD [M]  /home/gresy/Examples/hello.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.19.36-sunxi'

But when I try to load the hello-world module it's rejected:

> sudo insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Invalid module format

The following message shows up in the kernel buffer, which implies to me the module is not "preemtion compatible" ... if that's possible at all. Or at least the version magic is wrong.

> dmesg
...
[  710.970775] hello: version magic '4.19.36-sunxi SMP mod_unload ARMv7 thumb2 p2v8 ' should be '4.19.36-sunxi SMP preempt mod_unload ARMv7 thumb2 p2v8 '

Here some other information which might be useful:

> sudo modinfo hello.ko
filename:       /home/gresy/Examples/hello.ko
version:        0.1
description:    A simple Hello world LKM!
author:         Akshat Sinha
license:        GPL
srcversion:     B7B3CF8B5A8284B3911C7AF
depends:        
name:           hello
vermagic:       4.19.36-sunxi SMP mod_unload ARMv7 thumb2 p2v8

> uname -a
Linux nanopiair 4.19.36-sunxi #5.83 SMP PREEMPT Tue Apr 30 11:04:15 CEST 2019 armv7l GNU/Linux

So, does anyone know why the module will not get loaded?

 

Thanks for your help,

Markus

Link to comment
Share on other sites

I installed the kernel-source package (created when compiling armbian in Ubuntu VM) and compiled my module against this directory. Now the "preemt" tag appeared in the vmagic string but the tag "sunxi" got lost.

Currently the vermagic string of my module is "4.19.36+ SMP preempt mod_unload ARMv7 thumb2 p2v8" but it should be "4.19.36-sunxi SMP preempt mod_unload ARMv7 thumb2 p2v8"

 

Any Idea?

Link to comment
Share on other sites

On 5/2/2019 at 11:26 AM, mmax said:

I installed the kernel-source package (created when compiling armbian in Ubuntu VM) and compiled my module against this directory. Now the "preemt" tag appeared in the vmagic string but the tag "sunxi" got lost.

Currently the vermagic string of my module is "4.19.36+ SMP preempt mod_unload ARMv7 thumb2 p2v8" but it should be "4.19.36-sunxi SMP preempt mod_unload ARMv7 thumb2 p2v8"

 

Any Idea?

The same problem. Did you find any solutions?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines