0
votes

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.

1
please have a look at the link for your problem stackoverflow.com/questions/18106731/…Gautham Kantharaju
Thanks @GauthamKantharaju, I will look into this and let you know later if any query.Ritesh Prajapati
You have mentioned in that forum that every one have to rebuild the module again if any one want to load the same module on different kernel version.Ritesh Prajapati
thing is your module should be compatible with kernel version 2.6.30 to 3.9, it means that your kernel module code should take care of the api's signature/prototype change as in the link provided, usage of newer api based on kernel version checking i.e. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36). This is about compatibility with different kernel versions.Gautham Kantharaju
Coming to kernel module building or compilation, at any point of time you will be using any one linux kernel version i.e either 2.6.30 or 3.9 for example. Then you have to compile your kernel module against the kernel version being used, irrespective of anything. Regarding disabling of version matching mechanism, I have no idea.Gautham Kantharaju

1 Answers

2
votes

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.