Invalid module format linux
Библиотека сайта rus-linux.net
Основные ошибки модуля
Нормальная загрузка модуля командой insmod происходит без сообщений. Но при ошибке выполнения загрузки команда выводит сообщение об ошибке — модуль в этом случае не будет загружен в состав ядра. Вот наиболее часто получаемые ошибки при неудачной загрузке модуля, и то, как их следует толковать:
insmod: can’t read ‘./params’: No such file or directory — неверно указан путь к файлу модуля (возможно, в текущем каталоге не указано ./); возможно, в указании имени файла не включено стандартное расширение файла модуля ( *.ko ), но это нужно делать обязательно.
insmod: error inserting ‘./params.ko’: -1 Operation not permitted — наиболее вероятная причина: у вас элементарно нет прав root для выполнения операций установки модулей. Другая причина того же сообщения: функция инициализации модуля возвратила ненулевое значение, нередко такое завершение планируется преднамеренно, особенно на этапах отладки модуля.
insmod: error inserting ‘./params.ko’: -1 Invalid module format — модуль скомпилирован для другой версии ядра; перекомпилируйте модуль. Это та ошибка, которая почти наверняка возникнет, когда вы перенесёте любой рабочий пример модуля на другой компьютер, и попытаетесь там загрузить модуль: совпадение реализаций разных инсталляций до уровня подверсий — почти невероятно.
insmod: error inserting ‘./params.ko’: -1 File exists — модуль с таким именем уже загружен, попытка загрузить модуль повторно.
insmod: error inserting ‘./params.ko’: -1 Invalid parameters — модуль запускается с указанным параметром, не соответствующим по типу ожидаемому для этого параметра.
Ошибка (сообщение) может возникнуть и при попытке выгрузить модуль. Более того, обратите внимание, что прототип функции выгрузки модуля void module_exit( void ) — не имеет возможности вернуть код неудачного завершения: все сообщения могут поступать только от подсистемы управления модулями операционной системы. Наиболее часто получаемые ошибки при неудачной попытке выгрузить модуль:
ERROR: Removing ‘params’: Device or resource busy — счётчик ссылок модуля ненулевой, в системе есть (возможно) модули, зависимые от данного; но не исключено и то, что вы в самом своём коде инкрементировали счётчик ссылок, не декрементировав его назад.
ERROR: Removing ‘params’: Operation not permitted — самая частая причина такого сообщения — у вас просто нет прав root на выполнение операции rmmod . Более экзотический случай появления такого сообщения: не забыли ли вы в коде модуля вообще прописать функцию выгрузки ( module_exit() )? В этом случае в списке модулей можно видеть довольно редкий квалификатор permanent (в этом случае вы создали не выгружаемый модуль, поможет только перезагрузка системы) :
insmod error: inserting ‘./hello.ko’: -1 Invalid module format»
I have just made my first driver module, the hello world module following LDD3. However unfortunately encountered this error:
I am doing this on Ubuntu 11.04, and my environment:
I get the kernel source like this:
and then I compile the kernel
and then I compile my kernel module
and then finally when I insert the module:
what I found in dmesg:
So what’s the problem?
I have also noticed that the linux-header is -2.26.38-generic and source code version is -2.26.38, is this the problem? but I have really not found a linux-source-2.26.38-generic package on web.
status update: I have found that the file /lib/moduels/$(name -r)/build/Makefile indicate my running kernel version:
So I download the linux-2.6.38.2 and compile, but still the same error.
I have also found that there is a line in /boot/config-$(uname -r):
Does any one know what is this mean? I don’t see it in the config file of the kernel i am building.
Invalid Module Format #7
Comments
Copy link Quote reply
SchruteRampage commented Aug 17, 2013
Hello, I seem to have everything running a built correctly except I am getting one error that I can’t figure out.
When I run the ‘sudo insmod usbtv.ko’ command when I am located in the usbtv folder, I get the error: could not insert module usbtv.ko: invalid module format.
Copy link Quote reply
gkaindl commented Aug 18, 2013
«invalid module format» is usually the error message you get if you build a module for a different kernel (e.g. with different kernel headers and/or symbol file) than for the kernel you want to insert it into. make sure that the kernel headers/sources that you are using the build the module match the version of the kernel you are running.
the script I put in the «misc» folder works for me, but be aware that I just pulled this off a «gist» on github. If it doesn’t install the right kernel headers for you, you can still pull them from the raspberry pi repository (they also keep the Module.symvers files for all their builds there).
Copy link Quote reply
SchruteRampage commented Aug 20, 2013
So I am at the point where I will send you $10 bucks to your paypal if you just take a few minutes and talk me through getting this setup. I’m not a linux guru and I can’t figure out the usbtv driver. I spend a lot of money on the LED strips and the other parts, so I would really like this to get running. The script in the misc folder you were talking about was the get-kernel-source right? So does that script download the necessary files with your PAL alterations and it just happens that his script downloads the wrong headers/sources, which don’t match the kernel running on my pi which is 3.6.11+?? Please let me know if you have time to just help me out until I get it working.
Copy link Quote reply
andyclarke commented Aug 20, 2013
I too am having this problem. Looking at dmesg and it is as you say, a version mismatch. I’m just not sure how.
Copy link Quote reply
SchruteRampage commented Aug 20, 2013
He said it has something to do with the file in the misc folder called «get-kernel-source», but the actual code inside this script pulls the newest version or the kernel’s headers and source files or something like that, but it refuses to match with the 3.6.11+ kernel version running on the pi. I’ve worked on it for days and have not been able to figure it out lol
Copy link Quote reply
mjseid commented Aug 22, 2013
Are you guys still having this issue? I remember hitting this as well, and I can look through my notes and post maybe more verbose steps to run the script and insert the proper modules in the proper order.
Copy link Quote reply
SchruteRampage commented Aug 22, 2013
Yeah still having the issue. And yes, your help would be awesome.
Copy link Quote reply
andyclarke commented Aug 22, 2013
Yes, I’m still having issues as well. I’ve tried several times running updates at different times.
It seems to compile it against 3.6.11 and not 3.6.11+
Any help most appreciated.
Copy link Quote reply
mjseid commented Aug 22, 2013
I am running the 3.6.11+ kernel and using his script it does pull down and compile the right versions for me. The script gets the current kernel version from uname so it knows which one to pull down.
Here’s what I did to get it going:
cd /abmi-tv/misc/
chmod 755 get-kernel-source.sh
./get-kernel-source.sh
You can verify the version of kernel your running with «uname -r» and you can verify the source the script pulled down by the following command «more /lib/modules/3.6.11+/build/arch/arm/kernel/asm-offsets.s | grep 3.6».
Now make the usbtv driver:
cd usbtv-driver/
make && make install
_not sure if these are necessary, I was trying to get things working so might not be required_*
apt-get install v4l-utils ffmpeg libcunit1-dev v4l2loopback-dkms v4l2loopback-source v4l2loopback-utils dov4l
Now you’re ready to load the modules:
* make sure you load these kernel modules, in order, they are required for the usbtv module to load**
modprobe spi-bcm2708
modprobe videobuf2-vmalloc
modprobe videobuf2-core
insmod usbtv.ko
That should be enough to get it working. I want to load the modules automatically at boot so I also did the following:
**** copy the usbtv driver ot the current kernel module path and rebuild module map
cd /lib/modules/3.6.11+/kernel/drivers/media/video/
cp /ambi-tv/misc/usbtv-driver/usbtv.ko .
depmod -a
and add the following lines to the end of /etc/modules so they are loaded automatically on boot:
spi-bcm2708
videobuf2-vmalloc
videobuf2-core
usbtv
Copy link Quote reply
andyclarke commented Aug 22, 2013
Thank you for taking the time to post that.
It is pretty much what I have done.
The problem is still with trying to load the usbtv.ko module.
pi@raspberrypi
/ambi-tv/misc/usbtv-driver $ sudo insmod usbtv.ko
Error: could not insert module usbtv.ko: Invalid module format
And dmesg shows:
usbtv: disagrees about version of symbol module_layout
I have tried both before and after running rpi-update (with complete fresh installs inbetween and running the included script to get the shouce).
The only thing you appear to have done which is different to what I did, is when building the module I just typed build and you say you typed make && make install.
Trying that I get this other error:
Where it still looks like it is looking for a 3.6.11 directory not 3.6.11+, but I could be wrong.
Copy link Quote reply
mjseid commented Aug 22, 2013
I’m not sure why, but the «make install» part the script dumps the .ko file into the 3.6.11 branch instead of the 3.6.11+ branch. That’s why you have to manually insmod the file instead of just calling modprobe, b/c the install is not putting it into the right path for modprobe to find.
It should still result in a working module though. The errors you saw are b/c you were not using sudo. I have a bad habit of always doing things as root 🙂