I am following the tutorial @ http://www.embeddedsystemonline.com/home/embedded-system/embedded_linux/lab3-linux-device-driver

on step #7 of this tutorial,

$ cd /usr/src/kernels/linux-
$ /sbin/insmod hello1.ko

I then receive the following error (after sudo /sbin/insmod hello1.ko)

insmod: error inserting 'hello1.ko': -1 Invalid module format

Using the lsmod command, I do not see the module in the kernel

| improve this question | | | | |
  • This link explains why invalid module format issues occurs and how to fix it. Take a look here. I see that this is very old thread. Updating it so that, it will help the people who are recently searching for this particular fix. – Shantanu Ade Oct 15 '16 at 0:31

Try running the command without doing the sudo, instead become root and try it.

$ sudo su -
$ /sbin/insmod hello1.ko

Also take a look in dmesg to see if there are any additional messages as to what went wrong, and also take a peek at the module using modinfo.

$ modinfo /dir/to/mod/hello1.ko
| improve this answer | | | | |

Are you compiling the module against the correct Kernel Version headers ? I faced this issue and then I installed headers of correct kernel version.

| improve this answer | | | | |

Make sure that you are:

  1. using the source code of the same version of kernel, kernel source can be found here
  2. using the same kernel Configuration of the current installed kernel, usually can be found here :

  3. using the right compiling toolchain .

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.