3

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-2.6.20.1/drivers/char/examples
$ /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

1
  • 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. Oct 15, 2016 at 0:31

4 Answers 4

4

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
0

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 :

    /proc/config.gz
    /boot/config
    /boot/config-*
    
  3. using the right compiling toolchain .

0

I resolved this by installing headers of correct kernel version.

0

Run:

make clean

and then re-run:

make
1
  • Welcome to the site, and thank you for your contribution. Please note that brevity is acceptable, but fuller explanations are better. You may want to add a note why you think this approach will solve the OPs problem, in particular considering that the OP didn't state how the kernel module was built in the first place.
    – AdminBee
    Jun 16, 2023 at 13:08

You must log in to answer this question.

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