We help IT Professionals succeed at work.

Invalid Module format error in Linux kernel 2.6.28

tittu
tittu asked
on
629 Views
Last Modified: 2012-05-07
I have compiled open source USB driver for Fedora 8, when I Insert  the driver module .ko file on
Fedora 9 using  insmod driver.ko  i get the error Invalid Module format error  ?
why is this coming when i am inserting/deploying on higher version i.e Fedora 9 and compiled driver.ko on Fedora 8 ?
1.) Do i need to compile the driver along with kernel source where ever driver.ko is deployed ?
2.) I there any way at least for the minor number version change the driver.ko will insert ?
3.) It is not a good solution in every machine driver source is compiled, infact some of the client  
    machines doesn't have compilers and kernel sources installed

Comment
Watch Question

Both Fedora 8 and Fedora 9 are old releases, you should upgrade to Fedora 11.

You are saying you were compiling open source USB driver, but that doesn't make much sense. Why would you do so? Standard kernel packages support USB for a very long time.

If you want to compile a driver, you need to compile it for the exact version of kernel, it even must be the same flavour, because distribution specific patches might make your driver incompatible.
Top Expert 2009

Commented:
As stated, a module needs to match the base kernel. You can try loading with -f flag, but I'm sure this won't work between kernels of Fedora 8 vs 9, I only ever use it between minor patch level differences.

See the Kernel Loadable Module howto:

http://tldp.org/HOWTO/Module-HOWTO/basekerncompat.html#AEN507

Author

Commented:
The USB driver is a custom driver not a standard driver
It is working fine with FC8 when compiled and installed.
my question can i atleast insert this driver module even in FC8 without recompiling every time on the
deployment targets, in brief how windows drivers work like simple layman installation without compiling
compiling driver sources even for minor kernel version releases is a bad thing ?
some of the client machines even doesn't have compilers and kernel sources installed.
please give me a good solution for this instead of pointing links , i already tried all the links
Top Expert 2009

Commented:
>>my question can i atleast insert this driver module even in FC8 without recompiling every time on the deployment targets,

Yes, using the -f flag as I said. Did you try that?

With major kernel versions you really should be distributing a module for each kernel. Note, it has nothing to do with FC8 vs FC9, sometimes the distribution versions use the same base kernel version.

Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
You absolutely have to compile it. It relies on addresses in the built kernel. The smallest thing can make these change.
You could integrate the driver source into the kernel source tree so it will "just build" as you generate a new kernel. You need to pick some folder where the source will go (e.g. /usr/src/linux/drivers/usb/serial) and edit the files Kconfig and Makefile there. Your driver will then be visible in "make xconfig" &c.
Once complied by whatever means, you can deploy it with that kernel to other machines without recompiling (i.e. the modules folder and the kernel image are a matched pair. If there is also an initrd, then it's part of a matched triplet).

Author

Commented:

I will try  

Author

Commented:
Sun VirtualBox is compiling the kernel and Integrating into the existing kernel how is it doing
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
What commands are you using to start the build? When you say "Integrating into the existing kernel", what exactly do you mean? Has a new kernel been built? Can you boot into it? Is your new module present?

I guess I'm saying I need rather more specific feedback to be able to help you further.

Author

Commented:
when Sun Virtual Box is installed using an RPM, it is integrating virtual box module into the existing
kernel. and now the virtual box is working fine with the existing new kernel is not installed and infact
compiling without kernel sources installed in the system.
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
(Back from overseas trip)
That's as may be. Perhaps the RPM had a precompiled version for your kernel. Maybe it used mod-versions. There are all kind of advanced techniques it might have used.
If you simply have source for your custom driver, none of these are available to you. You have to have kernel source and you have to be running the kernel you built from that source. It sounds like you had better include the virtual box module in that kernel.Ideally you should have the configuration file (.config) for your current kernel, otherwise you have to build absolutely everything as a module and have an initrd (which is what distributors do, but the build takes ages). Or you might get away with working back from  an lsmod to know what you actually need. Without an initrd, you need to ensure that your kernel has built in support for your boot media - that's what I always do.
It's a bit of an undertaking if you haven't done this sort of thing before, but once you get the hang of it the next one will be much easier.

Author

Commented:
I need some clarification , why do i need always kernel sources when ever iam going to install drivers or .ko files , windows OS is intelligent in this case.
Software Developer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
not complete solution
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.