Chinese Yellow Pages | Classifieds | Knowledge | Tax | IME

How to fix “insmod invalid module format” for a out-of-tree linux device driver or kernel module?

If your kernel source tree matched your run time kernel, it turns out that it can be easily fixed by on debian 8:

cp /usr/src/linux-headers-3.16.0-4-amd64/Module.symvers /usr/src/linux

then make

More step by step details on debian 8:

(1) setup a build environment

apt-get install llinux-image-3.16.0-4-amd64 ( but linux-image-amd64 will not work as it will NOT update to the latest debian 8 kernel)

apt-get install linux-headers-3.16.0-4-amd64 linux-source # => linux-source-3.16.tar.xz,

cp /boot/config-3.16.0-4-amd64  /usr/src/linux/.config

make oldconfig && make prepare && make scripts

cp /usr/src/linux-headers-3.16.0-4-amd64/Module.symvers /usr/src/linux

#make && make modules ( it can generate Module.symvers, but it will take a long time)

(2) make your own kernel module

you can cd your module do the make

(3) some sample drivers at:

https://github.com/mingewang/linux_device_driver

Useful commands:

make clean
make distclean
modinfo, insmod, modprobe, dmesg

apt-get source linux-image-$(uname -r)

 

 

References:

http://www.freesoftwaremagazine.com/articles/drivers_linux

Leave a Reply

Your email address will not be published. Required fields are marked *