Invalid module format while loading driver in imx6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Invalid module format while loading driver in imx6

4,003 Views
chandraevolute
Contributor V

I am trying to load module through modprobe. I am getting below error

root@imx6ulevk:/lib/modules/3.14.38-6UL_ga+ge4944a5/kernel/drivers/usb/gadget# modprobe libcomposite
libcomposite: version magic '3.14.38-6UL_ga+ge4944a5 SMP preempt mod_unload modversions ARMv7 p2v8 ' should be '3.14.38-6UL_ga+ge4944a5 preempt mod_unload ARMv7 p2v8 '
modprobe: can't load module libcomposite (kernel/drivers/usb/gadget/libcomposite.ko): invalid module format

below is the output of uname -r 

root@imx6ulevk:/lib/modules/3.14.38-6UL_ga+ge4944a5/kernel/drivers/usb/gadget# uname -r
3.14.38-6UL_ga+ge4944a5

why is the error coming and can anyone give a solution for this 

Labels (2)
Tags (1)
0 Kudos
7 Replies

2,507 Views
igorpadykov
NXP Employee
NXP Employee

Hi chandra

reason may be that  libcomposite was compiled in other kernel version, more details can be found in

http://unix.stackexchange.com/questions/170503/insmod-error-could-not-insert-module-8188eu-ko-invali...
http://www.tldp.org/LDP/lkmpg/2.6/html/x380.html

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,507 Views
chandraevolute
Contributor V

Hi igor

you can see my uname -r output the kernel versions and driver mod info are same

0 Kudos

2,507 Views
marius_grigoras
NXP Employee
NXP Employee

Hi,

What's the output for modinfo libcomposite.ko ?

Naturally, in most of the cases, this error is complaining about different version magic encapsulated inside of kernel module and compared with the one from kernel. 

Try to use --force-vermagic as parameter for modprobe.

--force-vermagic
Every module contains a small string containing important information, such as the kernel and compiler versions. If a module fails to load and the kernel complains that the "version magic"
doesn't match, you can use this option to remove it. Naturally, this check is there for your protection, so this using option is dangerous unless you know what you're doing.

This applies to any modules inserted: both the module (or alias) on the command line and any modules on which it depends.

Thank you,

Marius

0 Kudos

2,507 Views
marius_grigoras
NXP Employee
NXP Employee

Or simpler, can force the insertion using -f to avoid any versions check.

-f, --force
Try to strip any versioning information from the module which might otherwise stop it from loading: this is the same as using both --force-vermagic and --force-modversion. Naturally, these
checks are there for your protection, so using this option is dangerous unless you know what you are doing.

This applies to any modules inserted: both the module (or alias) on the command line and any modules it on which it depends.

0 Kudos

2,507 Views
chandraevolute
Contributor V

Hi Maruis 

this is my output of modprobe libcomposite.ko

root@imx6ulevk:/lib/modules/3.14.38-6UL_ga+ge4944a5/kernel/drivers/usb/gadget# modinfo libcomposite.ko
filename: libcomposite.ko
license: GPL
author: David Brownell
srcversion: 3C154B8E069FE5773D21EE2
depends:
vermagic: 3.14.38-6UL_ga+ge4944a5 SMP preempt mod_unload modversions ARMv7 p2v8

there is no -f option for modprobe 

modprobe -f libcomposite
modprobe: invalid option -- 'f'
BusyBox v1.23.1 (2017-04-11 16:49:06 IST) multi-call binary.

Usage: modprobe [-alrqvsD] MODULE [SYMBOL=VALUE]...

If I do modprobe libcomposite I am having the ibnvlid module format error. Even though the kernel version is same.

root@imx6ulevk:/lib/modules/3.14.38-6UL_ga+ge4944a5/kernel/drivers/usb/gadget# modprobe libcomposite
libcomposite: disagrees about version of symbol module_layout
modprobe: can't load module libcomposite (kernel/drivers/usb/gadget/libcomposite.ko): invalid module format

How to strip versioning information from module?

What is causing the error invalid module format??

0 Kudos

2,507 Views
marius_grigoras
NXP Employee
NXP Employee

Indeed, the version magic seems to be ok, but somehow unfortunately you corrupted the module kernel during build time (maybe a build interrupt, a different build time, a different toolchain...and so on).

The only way to fix this seems to regenerate/rebuild the linux kernel module from the same linux tree [1] and make sure you're using on the target both the linux and kernel module from the same build. 

[1] linux - Invalid module format with matching vermagic value - Stack Overflow 

Thank you,

Marius

0 Kudos

2,507 Views
chandraevolute
Contributor V

Hi mariusviorelgrigoras-b32331‌ 

I regenerated the linux and kernel module from the same build, the driver is loading. But the problem is I want to use the USB OTG port which we use for mfgtool we make it as gadget file system. And we cant use it as gadget HID. My requirement is to use the same OTG as gadget HID. 

In kernel config I should make the USB gadget as gadget Filesystem only If i make other than that I cant use mfgtool for flashing. Is there any work around for this in kernel config 

0 Kudos