1

after command make I call command sudo insmod example1.ko , I am insertig password and then I had error like this insmod error: could not insert module example1.ko: Invalid module format. My version of ubuntu is 5.8.0-44-generic and version of my example1.ko is 5.8.0-38-generic. Maybe these version should me same? I have been trying change in my Makefile from /lib/modules/($ shell uname -r)/build to /lib/modules/5.8.0.-38-generic/build but still was the same error. I have no idea how to fix this problem.

I used command dmesg to search more information about problem and I found some errors

example1: version magic '5.8.0-38-generic SMP mod_unload' should be '5.8.0-44-generic SMP mod_unload'

and there are more six lines with same problem and two errors Failed to send host log message.

My Makefile file looks in this way :

obj-m := example1.o

default:
  make -C /lib/modules/5.8.0-44-generic/build M=$(PWD) modules
clean
  make -C /lib/modules/5.8.0-44-generic/build M=$(PWD) clean

I ran make clean ; make but it had no effect.

0

1 Answer 1

1

The comments on the question led to a solution that I'll summarize here.

The OP wanted to build a Linux kernel module; they built it against the wrong version of the kernel source (i.e., against a version of the kernel sources different from the running kernel). This was indicated by a log of the dmesg buffer.

To resolve that problem, you need to point to the kernel sources that correspond to the kernel into which you want to load the module. You can do that explicitly on the command line:

$ make -C <path_to_kernel_src> M=$PWD

Or create a Makefile that does the same.

Be sure to clean up any existing artifacts from a previous build before trying to build against the correct kernel sources.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .