views:

329

answers:

3

Dear All,

I made certain modifications in hid module.

I can make it and load (insmod) it on kernel v 2.6.27.14 sucessfully

Now I am willing to load the same kernel module on kernel v 2.6.27.11

As there is no differance in the kerbel source files for both the kernel versions

I can make it sucessfully, but I cannot add / insmod in this .11 kernel version

**

                ERROR: Module myhid does not exist in /proc/modules

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

**

Regards,

A: 

see what "modinfo" tells you about your module:

Check that it's compiled properly, linked to the right kernel.

$ modinfo hid
filename:       /lib/modules/2.6.27.7/kernel/drivers/hid/hid.ko
license:        GPL
depends:        
vermagic:       2.6.27.7 mod_unload 486 
parm:           pb_fnmode:Mode of fn key on Apple keyboards (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst) (int)

When you compile/install modules, don't forget that you have to run "depmod" (as root) to rebuild the modules dependancies before running insmod/modprobe.

wazoox
+2  A: 

You can't load a module compiled for another kernel version. That the source code of the module did not change does not mean that the binary will be the same for another kernel version. Any interface change of kernel internal APIs (even when not directly visible) will break the module...

Therefore, the kernel stays on the safe side by disallowing loading of modules that were built for another kernel version. Alternatively, you can set the MODVERSIONS configuration option when building your kernel. This will embed version information into all symbols used by your module and with luck you can load it on another kernel version.

If any interface used by your module changed, the result will be the same though.

Bluehorn
Thanks ! Yes it works if I compile my source files on every kernel version. How can we set the MODVERSIONS configuration option when building our kernel. Is it in MAKEFILE or in any source file? Regards,
Madni
It is set in .config, usually by running `make menuconfig` or the like. For more information, have a look at `Documentation/kbuild/modules.txt` in your kernel sources.
Bluehorn
Thank you! I am still working with MODVERSIONS but still have not a good picture of it. Will you please send me an example of it. Regards
Madni
A: 

Thanks ! Here is the make file . I dowload all the dependent source files for HID.O and rename them

MAKEFILE

obj-m := myhid.o

myhid-objs := my-hiddraw.o my-hid-core.o my-hid-input.o my-hid-input-quirk.o

KDIR := /lib/modules/$(shell uname -r)/build

PWD := $(shell pwd)

default:

$(MAKE) -C $(KDIR) M=$(PWD) modules
Madni