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 (в этом случае вы создали не выгружаемый модуль, поможет только перезагрузка системы) :
Источник
Invalid module format
The Makefile is a mix of tradition format (using (CC)) and module build system format «make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules» .
The system is 1.6.18-194.el5 x86_64. The same Makefile works fine when it is used in i386 machine.
Any idea of what to look into? Thanks.
hello.c
2 Answers 2
The dmesg output tells you what is wrong:
On the x86-64 architecture, all code running in the kernel (including modules) must be compiled with a special flag, which tells the compiler to generate code which will run in the top half of the virtual address space (user mode programs run on the bottom half of the address space).
If I am reading your Makefile correctly, you are compiling the C code outside the kernel build system, and calling into the kernel build system only for the final linking. Do not do this. It is not just the memory model, there are several other flags which must be added when compiling the C source code. These flags can change with the kernel version, or even with the kernel configuration — you do not know, and you are not supposed to have to know, since the kernel build system deals with it all for you.
It is not just -mcmodel=kernel . There are many others, and getting them wrong can and will cause problems.
The fact that you are missing the correct flags is quite visible in your code:
No, this is not needed. If you need it, you are doing it wrong. Take a look at one of the flags the kernel build system passes to the C compiler:
This flags tells the C compiler to always implicitly include the linux/autoconf.h header. Since it is always implicitly included, you never have to include it manually. And since you never include it manually, its location is allowed to change — it moved to generated/autoconf.h and later to linux/kconfig.h , and who knows where else it will end up next.
The fact that it worked at all for you in 32-bit x86 is just luck. You should do it the correct way even on 32-bit.
Источник
ошибка insmod: вставка ‘./привет.ko’: -1 недопустимый формат модуля»
Я только что сделал свой первый модуль драйвера, модуль hello world после LDD3. Однако, к сожалению, столкнулся с этой ошибкой:
я делаю это на Ubuntu 11.04, и мое окружение:
Я получаю источник ядра следующим образом:
и затем я компилирую ядро
а затем я компилирую свой модуль ядра
С Файл Makefile:
и, наконец, когда я вставляю модуль:
что я нашел в dmesg:
так в чем проблема?
Я также заметил, что linux-header is -2.26.38-generic и версия исходного кода -2.26.38, это проблема? но я действительно не нашел linux-source-2.26.38-generic пакета по сети.
обновить статус : Я обнаружил, что файл / lib / moduels / $(name-r) / build/Makefile указывает на мое запущенное ядро версия:
поэтому я загружаю linux-2.6.38.2 и компилирую, но все та же ошибка.
Я также обнаружил, что есть строка в /boot / config — $(uname-r):
кто-нибудь знает, что это значит? Я не вижу его в конфигурационном файле ядра, которое я создаю.
3 ответов
ядро, из которого вы создаете свой модуль ядра и в который вы вставляете модуль, должно иметь ту же версию. Если вы не хотите заботиться об этой вещи, вы можете использовать следующий Makefile.
Теперь вы можете построить и попытаться вставить модуль.
Я предлагаю вам стать root, если это возможно, перед этой строкой
$sudo cp / boot / config-2.6.38-8-общий ./.config
альтернативно вы также можете использовать после make file
попробуйте использовать кросс-компиляции. Пожалуйста, посмотрите на код ниже для файла make. Помните о отступе, иначе вы можете закончить с ошибкой, такой как отсутствует сепаратор. Остановка
obj-m += hello_.o # это имя должно быть имя .файл c. Я просто использую hello, например
Я предлагаю лучший подход через кросс-компиляцию
создайте переменную для хранения имени каталога, в котором находится каталог ядра linux в моем примере, измените значение «PATH_TO_LINUX_KERNEL_DIRECTORY» в реальный путь значение Пример
/ linux Вам действительно нужно сделать это, чтобы файл make знал, где найти arm-linux-gnueabi-без этого вы, скорее всего, столкнетесь с проблемами arm-linux-gnueabi-
вы сделали все правильно, но не загрузили свою систему с ядром, которое вы скомпилировали, поэтому первым шагом является загрузка с ним. Если вы используете Ubuntu, вы можете удерживать кнопку shift во время загрузки, и вам будет предоставлен список скомпилированного ядра в вашей системе, оттуда выберите linux-source-2.6.38 а затем попробуйте построить свой модуль и установить его по-своему ,чем вы не найдете никаких проблем. Гудлак.
Источник
UNIX for Dummies Questions & Answers
insmod: Invalid module format error
I have open suse kernel kernel 3.1.0-1.2-desktop on which I used kernel source 3.1.10-1.2 downloaded from kernel.org.
The module gets built.
While loading a kernel module I am getting Invalid module format error with description «first_driver: no symbol version for module_layout»
The following are the logs:
I guess this is because of mismatching kernel versions.
Cannot I use kernel source 3.1.10-1.2-desktop on kernel 3.1.0-1.2-desktop?
Where can I get the kernel source for 3.1.0-1.2-desktop
How to resolve this issue?
Thanks Coronna for the reply.
Where can I find the suse kernel source?
fine to download the suse kernel source?
I have linux installed in vmware which is not connected to net and so I have to manually download the source.
———- Post updated 02-03-12 at 01:03 PM ———- Previous update was 02-02-12 at 08:56 PM ———-
Now I have open suse kernel kernel 3.1.0-1.2-desktop and its kernel source.
Again the module gets built.
While loading a kernel module I am getting Invalid module format error with description «first_driver: no symbol version for module_layout»
The following are the logs:
FYI I have compiled the kernel as follows:
Make mrprpoper
make menuconfig
Make
Make modules
Make modules_install
Make install
Am I missing something?
How to resolve this issue?
Источник
Invalid module format linux
So I have a bunch of modules that I added to the kernel.
I ran:
make clean
make && make modules install.
I copied arch/i686/bzImage over properly
I ran depmod -a
I ran update-modules
I tried to load the module:
# insmod /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd.koinsmod: error inserting ‘/lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd.ko’: -1 Invalid module format
That same error comes up as a warning during my boot sequence.
Here is my /etc/modules.autoload file.
Код: |
# /etc/modules.autoload.d/kernel-2.6: kernel modules to load when system boots. # # Note that this file is for 2.6 kernels. # # Add the names of modules that you’d like to load when the system # starts into this file, one per line. Comments begin with # and # are ignored. Read man modules.autoload for additional details. # For example: nvidia |
And here is my modprobe -l
Код: |
# modprobe -l /lib/modules/2.6.21-gentoo-r4/kernel/crypto/sha1.ko /lib/modules/2.6.21-gentoo-r4/kernel/crypto/sha256.ko /lib/modules/2.6.21-gentoo-r4/kernel/crypto/crypto_null.ko /lib/modules/2.6.21-gentoo-r4/kernel/crypto/cbc.ko /lib/modules/2.6.21-gentoo-r4/kernel/crypto/blowfish.ko /lib/modules/2.6.21-gentoo-r4/kernel/crypto/pcbc.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd-rawmidi.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/oss/snd-mixer-oss.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/oss/snd-pcm-oss.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/snd-seq-virmidi.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/snd-seq-device.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/snd-seq-midi-event.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/oss/snd-seq-oss.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/snd-seq-midi.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/seq/snd-seq.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd-pcm.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd-page-alloc.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/core/snd-timer.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/pci/hda/snd-hda-codec.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/pci/hda/snd-hda-intel.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/soc/snd-soc-core.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/drivers/snd-virmidi.ko /lib/modules/2.6.21-gentoo-r4/kernel/sound/soundcore.ko /lib/modules/2.6.21-gentoo-r4/kernel/drivers/video/backlight/lcd.ko /lib/modules/2.6.21-gentoo-r4/kernel/drivers/pcmcia/rsrc_nonstatic.ko /lib/modules/2.6.21-gentoo-r4/kernel/drivers/pcmcia/yenta_socket.ko /lib/modules/2.6.21-gentoo-r4/misc/svgalib_helper.ko /lib/modules/2.6.21-gentoo-r4/misc/vboxdrv.ko /lib/modules/2.6.21-gentoo-r4/video/nvidia.ko /lib/modules/2.6.21-gentoo-r4/net/wireless/ipw3945.ko |
Why can’t I load those bloody modules? Now that I know about that, and now that I know those modules aren’t being loaded, I suspect they may be causing a bunch of my sound issues. At least I hope so, cause then they’d be fixed.
HEY KIDS, ALWAYS REMEMBER TO DOUBLE-CHECK THAT GRUB IS LOADING THE RIGHT KERNEL. :s
Последний раз редактировалось: GivePeaceAChance (пт дек 28, 2007 9:39 pm), всего редактировалось 1 раз
Bodhisattva
Зарегистрирован: 04 ноя 2005
Сообщений: 9410
Добавлено: чт дек 27, 2007 11:31 am Заголовок сообщения: | |
Moved from Installing Gentoo to Kernel & Hardware. |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: чт дек 27, 2007 11:47 am Заголовок сообщения: | |||
GivePeaceAChance,
and try again. Computer users fall into two groups:- |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: чт дек 27, 2007 11:57 am Заголовок сообщения: | |||
I just installed that like you said, and ran:
_________________ |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: чт дек 27, 2007 4:16 pm Заголовок сообщения: | |||
GivePeaceAChance, modprobe knows where to look for your kernel modules, hence providing a path name failed insmod needs the full path name as you gave it but are you running a kernel called 2.6.21-gentoo-r4 ? If you want to use insmod use the command
so insmod asks the kernel for its name. I’m not sure in insmod needs the .ko extension either. There may also be some useful information in dmesg. Computer users fall into two groups:- |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 12:25 am Заголовок сообщения: | |||||||
If I take out the .ko, and just run, I get this:
And the only dir in /lib/modules is 2.6.21-gentoo-r4. my kernel in /boot is kernel-2.6.21-gentoo-r4. I tried «modprobe ipw3945» to load a module that was already loaded, and it worked fine, no output. but the second I tried «modprobe snd» I got the invalid format errors.
Here’s some output that might be relevant in dmesg. Can you tell me any other output I should be looking for in dmesg?
_________________ |
n00b
Зарегистрирован: 27 дек 2007
Сообщений: 32
Добавлено: пт дек 28, 2007 1:33 am Заголовок сообщения: | |||||
Hello
Make sure has a folder alsa-driver, if you delete. This way you will be using alsa kernel. |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 2:38 am Заголовок сообщения: | |
I am not using alsa-driver. I made sure to compile alsa support into the kernel. _________________ I am not a Linux Guru, but a n00b with a lot of questions. |
n00b
Зарегистрирован: 27 дек 2007
Сообщений: 32
Добавлено: пт дек 28, 2007 3:01 am Заголовок сообщения: | |
Ok I talked about the alsa-driver because I had this problem using kernel 2.6.23. I had this problem because I had installed the alsa-driver. This message kernel says that there is another driver installed with the same name but elsewhere. For example in my case: I had the snd_hda_intel folder / lib/modules/2.6.23-gentoo-r3/kernel/drivers/sound / and also had / lib/modules/2.6.23-gentoo-r3/alsa-driver /. You compiles its driver, as audio module? |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 3:12 am Заголовок сообщения: | |||
/lib/modules/2.6.21-gentoo-r4/
_________________ |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 7:23 am Заголовок сообщения: | |
Hi, Where is the list that tells what modules should be loaded at boot? Because I’ve commented out all the modules except for nvidia and vboxusers in my /etc/modules.autoload.d/kernel-2.6 and I’ve even changed all the erroring modules to .bak files, and I still get the Warning messages in my boot process. There is no kernel-2.4 folder/file for modules — I deleted it to avoid confusion. So where are these errors coming from? |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 11:34 am Заголовок сообщения: | |||||||
GivePeaceAChance, There are three ways of building ALSA and your dmesg
says you have used at least two of them at the same time. The methods are emerge alsa-drivers . don’t do that. Do the following
it will fail if alsa-drivers is not installed. Thats ok,
This will ensure you have at most one set of ALSA installed. If your kernel ALSA is set to attempts to load the modules wil fail. Computer users fall into two groups:- |
Watchman
Зарегистрирован: 14 июл 2005
Сообщений: 7310
Добавлено: пт дек 28, 2007 11:40 am Заголовок сообщения: | |||
See wiki.
People make every mistake imaginable, with those options. |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 12:10 pm Заголовок сообщения: | |||
^^ In reply to Paul: I’m going through the howto now, and I’m curious about this part:
How am I supposed to know which packages I’ve emerged make modules? I haven’t been keeping track up til now, so how do I know which ones to re-emerge? |
Watchman
Зарегистрирован: 14 июл 2005
Сообщений: 7310
Добавлено: пт дек 28, 2007 12:23 pm Заголовок сообщения: | |
Read the next line, re module-rebuild. Very few apps create kernel modules, so it’s easy to keep track of manually in your kernel recompilation script. |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 12:24 pm Заголовок сообщения: | |||
GivePeaceAChance, That remove command is badly broken and should not be used.
It removes all modules from all installed kernels that were provided by most but not all packages that install kernel modules. Working down the list The /*/ causes the command to operate on all your module directories, so it breaks all your previously installed kernels. Its unlikely you want that. Computer users fall into two groups:- |
Watchman
Зарегистрирован: 14 июл 2005
Сообщений: 7310
Добавлено: пт дек 28, 2007 12:39 pm Заголовок сообщения: | |||
It’s OK for the target audience of the document, who I have to assume aren’t complete idiots. It seems to be obvious to people that, if a kernel module is missing (e.g. nvidia), they should re-emerge the nvidia package. But, on the other hand, if the kernel module is present but «stale», they will fill the forums with duplicate «Invalid Module Error! WTF??» threads. |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 12:51 pm Заголовок сообщения: | |
PaulBredbury, . that gives rise to a whole new class of problems . like . I emerged nvidia-drivers and it still won’t load . because the user didn’t point /usr/src/linux to the kernel they wanted to build against. Computer users fall into two groups:- |
Watchman
Зарегистрирован: 14 июл 2005
Сообщений: 7310
Добавлено: пт дек 28, 2007 1:17 pm Заголовок сообщения: | |||
Well, the wiki article does say to use ln , and does include checks, later in the doc. It’s impossible to write a document containing step-by-step instructions, when the users are such idiots that they can’t follow step-by-step instructions without making every mistake imaginable. The normal viewer of my doc will be someone who can’t get ALSA working. So it tries to get one kernel version working with ALSA, whilst reducing complexity. It doesn’t destroy the other kernels — they will still boot. The other kernels will almost certainly not have ALSA working in them anyway, so what use are they? The doc is already too complex — witness the number of ALSA threads where they actually post all the info I describe at the bottom of the doc — practically no-one. Too much effort for the poor souls, obviously. |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 3:34 pm Заголовок сообщения: | |
PaulBredbury, From the perspective you just outlined . I agree. Computer users fall into two groups:- |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 7:29 pm Заголовок сообщения: | |||||||||
OK, looks like I’m a complete idiot then. SoI guess I’m going to take a few steps back to /etc/modules.d/alsa to save myself, and anyone else who is helping me (a big thank you, btw), some trouble. The first thing I did on this webpage is:
but it failed miserably with the «Invalid module format» errors. The nex tthing I did on that page was straight up copy the following and add it to the end of /etc/modules.conf. I’m an idiot, so I don’t know if I need to, but they said to do so, so I did it.
Here is my resulting modules.conf file:
I then went BACK to the ALSA gentoo howto, and I’m at the point where it is not necessary to run alsaconf. I’ll continue on my way and simply run update-modules. After that, I ran:
Am I doing OK up to this point, because the next part may require some questions since I don’t know how to use module-rebuild. i.e. Do I remove the kernels with the rm command listed, then run module-rebuild? |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 8:40 pm Заголовок сообщения: | |||||||||||||||||
GivePeaceAChance, The problem I have with helping you right now is that I don’t know where you are. snd-alsa-hda is a difficult module to make make work because thare are lots of slightly different pieces of hardware that it covers. Start with a nice clean kernel tree and rip out alsa-drivers, even if its not installed. Do
Ignore errors from emerge -C alsa-driver. Next, configure your kernel for kernel ALSA with OSS support, to be made as modules.
make sure OSS is off.
Under Generic devices —> ensure everything is off
Set everything else off unless you have more sound cards. Now build your kernel, install and boot into it. Check that the time and date shown in uname -a is the new kernel build time.
should list your sound modules. Next install all the supporting things by following the Gentoo ALSA Guide Add your normal user to the audio group, log out and back in to pick up the new group membership Since you have snd-intel-hda, it probably won’t work. Check that your system has /dev/snd and /dev/sound and that the files in them are owned by root and in group audio. The last step is to fiddle with module options. You do that with the routine
Test the sound, with a simple command line player. I like
You will find some options in
Its a big file but you are only interested in the Intel HDA section. When you find the right option, you can make it be used at startup by including it in /etc/modules.d/alsa Any problems, stop at the error, tell us what you did, what you think should have happened, what actually happened and provide any error messages from the screen or dmesg verbatim. Computer users fall into two groups:- |
Guru
Зарегистрирован: 26 мая 2007
Сообщений: 480
Добавлено: пт дек 28, 2007 9:39 pm Заголовок сообщения: | |||
Well ****. Maybe I’m too stupid to learn linux. Shit. ****. I did what you suggested, checked uname -a, and it kept giving me Aug 14, when I originally set up gentoo. This puzzled me. Sooooo, over to grub’s menu.lst. Lo and behold! I THOUGHT it was loading kernel-2.6.21-gentoo-r4, but it was loading vmlinux-2.6.21-gentoo-r4. So I changed this, prayed for the best, and **** yeah, no error messages, and the kernels load properly. ****ing dumbshit I am. Well, as long as I didn’t make you guys upset with my stupidity, all I can say is, *hopefully* I’m all the more wiser. (big question mark on that one, but we’ll hope for the best). |
Administrator
Зарегистрирован: 05 июл 2003
Сообщений: 49011
Откуда: 56N 3W
Добавлено: пт дек 28, 2007 10:23 pm Заголовок сообщения: | |
GivePeaceAChance, There are many ways to mess up a kernel install. When you have done it once, you learn that command and apply it as a sanity check, every time. Computer users fall into two groups:- |
Список форумов: Gentoo Forums | Часовой пояс: GMT | |
Страница 1 из 1 |
Вы не можете начинать темы Вы не можете отвечать на сообщения Вы не можете редактировать свои сообщения Вы не можете удалять свои сообщения Вы не можете голосовать в опросах |