简体   繁体   中英

“Invalid module format” error getting while loading driver on different kernel version

I have created one small usbtest driver to test my usb device. I have linux kernel version of 3.2.0 and ubuntu 12.04.

I can load that driver successfully on my PC very well without any issue and i can use that loaded driver without any failure condition.

My Linux PC information :: output of uname -a Linux ci5lub021305 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux

Linux PC information of another PC on which driver loading failed :: uname -a Linux ci5lub021302 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 i686 i686 i386 GNU/Linux

But, When i tried to load that driver into some another Linux Platform which has different kernel version then at that time it giver following while loading that driver.

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

I have seen in the dmesg which shows error regarding module version

usbtest: disagrees about version of symbol module_layout

I have also seen on another forums regarding this issues and they have suggested to compile the driver again in that another PC. But it is not a proper solution which i think.

Is there any one have idea about how to solve this version dependency issue because my client wants the driver from any kernel between 2.6.30 to 3.9 kernel.?

So, I need some specific solution so that compiled driver can be loaded on any Linux kernel version which depending on the specific kernel version.

please help me solve the above issue as soon as possible because this is one critical issue for me.

Thanks in advance for your support.

You are writing a module that is intended to work with multiple versions of the kernel, you likely have to make use of macros and #ifdef constructs to make your code build properly.

you need to make use of the definitions found in linux/version.h .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM