- проблема после сборки модулей для ядра
- Invalid module format
- hello.c
- insmod error: inserting './hello.ko': -1 Invalid module format"
- insmod: ERROR: could not insert module 8188eu.ko: Invalid module format
- 1 Answer 1
- Building example device driver error: insmod invalid module format
- 4 Answers 4
- You must log in to answer this question.
- Related
- Hot Network Questions
- Subscribe to RSS
проблема после сборки модулей для ядра
Сама задача была скомпилировать модули для телефона с arm, но как бы не пытался всё равно insmod и modprobe выдают can’t load module invalid module format. Собирал вот так. make modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KERNELRELEASE=3.0.31-1071214 Пробовал разными компиляторами, результат тот же. Потом уже попробовал теми же методами собрать модуля под десктопную машину, модули собираються но результат тот же, но ещё в логах вот такое
ath: no symbol version for module_layout
Ядра брал с kernel.org, точно тех версий что показывает uname -r вот машины 3.2.0-32-generic
а это для примера modinfo mwl8k.ko
filename: mwl8k.ko license: GPL author: Lennert Buytenhek version: 0.12 description: Marvell TOPDOG(R) 802.11 Wireless Network Driver firmware: mwl8k/fmimage_8366_ap-2.fw firmware: mwl8k/fmimage_8366.fw firmware: mwl8k/helper_8366.fw firmware: mwl8k/fmimage_8687.fw firmware: mwl8k/helper_8687.fw firmware: mwl8k/fmimage_8363.fw firmware: mwl8k/helper_8363.fw srcversion: 63FF6676F54CF2FF2E96220 alias: pci:v000011ABd00002A43sv*sd*bc*sc*i* alias: pci:v000011ABd00002A40sv*sd*bc*sc*i* alias: pci:v000011ABd00002A30sv*sd*bc*sc*i* alias: pci:v000011ABd00002A2Bsv*sd*bc*sc*i* alias: pci:v000011ABd00002A24sv*sd*bc*sc*i* alias: pci:v000011ABd00002A0Csv*sd*bc*sc*i* alias: pci:v000011ABd00002A0Asv*sd*bc*sc*i* depends: mac80211,cfg80211 intree: Y vermagic: 3.2.0-32-generic SMP mod_unload modversions parm: ap_mode_default:Set to 1 to make ap mode the default instead of sta mode (bool)
Может кто чем подскажет где я ошибку делаю, ответа что в темах есть не нашёл?
Ядро и модули должны быть собраны одной и той же версией компилятора с использованием одной и той же версии glibc.
Т.е. если у вас уже есть собранное ядро, например разработчиками установленной на аппарате операционной системы. Затем вы просто берёте исходные коды ядра с kernel.org, конфиг от уже собранного разработчиками ядра. Исходники распаковываете, помещаете конфиг ядра, включаете поддержку нужного модуля, затем собираете модуль и просто копирете его в систему. После чего пытаетесь подгрузить его, то ничего не получится.
Вам нужно собирать заново и ядро и все нужные модули. Ну либо можете собрать ядро, отключить в нём проверку того, под какое ядро собран загружаемый модуль. И потом сможете загружать модули, собранные даже под другую версию ядра, но в этом случае ни кто не гарантирует стабильность.
В общем, собираейте ядро и модули, после чего используете свеже собранное ядро и модули от него на вашей системе. По другому ни как.
Ядро и модули должны быть собраны . с использованием одной и той же версии glibc
Надо же такую жуйню спороть.
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.
#Makefile, mix of (CC) and kernel module build system CFLAGS+=-D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(hello)" CFLAGS+=-D__KERNEL__ -DMODULE -I$(KERNEL_BUILD_DIR)/include KERNEL_BUILD_DIR=/lib/modules/2.6.18-194.el5/build TARGETNAME=hello BUILD_ALT_DIR=linux # The main target (note that both library and driver are .ko files # all: $(BUILD_ALT_DIR)/$(TARGETNAME).ko $(BUILD_ALT_DIR)/_$(TARGETNAME).o: hello.o @echo Linking objects to loadable module @mkdir -p $(BUILD_ALT_DIR) @echo $(CURDIR)/$@ @$(LD) -Map=$@.map -r -o $@ $^ @echo " LD_D [$@]" $(BUILD_ALT_DIR)/$(TARGETNAME).ko: $(BUILD_ALT_DIR)/_$(TARGETNAME).o @rm -f $(BUILD_ALT_DIR)/$(TARGETNAME).o @echo create Makefile @$(SHELL) -c 'echo "obj-m := $(TARGETNAME).o" > $(BUILD_ALT_DIR)/Makefile' @$(SHELL) -c 'echo "$(TARGETNAME)-objs := _$(TARGETNAME).o" >> $(BUILD_ALT_DIR)/Makefile' @$(SHELL) -c 'echo ".PHONY: `pwd`/$(BUILD_ALT_DIR)/_$(TARGETNAME).o" >> $(BUILD_ALT_DIR)/Makefile' @$(SHELL) -c 'cd $(BUILD_ALT_DIR); $(MAKE) -C $(KERNEL_BUILD_DIR) M=`pwd`' @echo " KO_D [$@]" $(BUILD_ALT_DIR)/%.o: %.c @echo Compiling C source to object file: @mkdir -p $(BUILD_ALT_DIR) # @echo $(CURDIR)/$@ @$(CC) -c -Wall $(CFLAGS) $(CFLAGS) $< -o $@ @echo " CC_D [$@]" clean: rm -f $(BUILD_ALT_DIR)/*.o $(BUILD_ALT_DIR)/*.d $(BUILD_ALT_DIR)/core $(BUILD_ALT_DIR)/*.map
hello.c
#include // this is needed #include #include static int hello_init(void) < printk(KERN_ALERT "Hello, world\n"); return 0; >static void hello_exit(void) < printk(KERN_ALERT "Goodbye, cruel world\n"); >module_init(hello_init); module_exit(hello_exit);
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:
insmod: error inserting './hello.ko': -1 Invalid module format.
sudo apt-cache search linux-source linux-source - Linux kernel source with Ubuntu patches linux-source-2.6.38 - Linux kernel source for version 2.6.38 with Ubuntu patches $sudo apt-get install linux-source-2.6.38
$ls /usr/src/ linux-headers-2.6.38-8 linux-source-2.6.38 vboxguest-5.0.10 linux-headers-2.6.38-8-generic linux-source-2.6.38.tar.bz2
$sudo cp /boot/config-2.6.38-8-generic ./.config $sudo make menuconfig -- load the .config file $make $make modules
$make -C /usr/src/linux-source-2.6.38/linux-source-2.6.38 M=`pwd` modules
$sudo insmod hello_world.ko insmod: error inserting 'hello_world.ko': -1 Invalid module format
hello: disagrees about version of symbol module_layout
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:
VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 38 EXTRAVERSION = .2
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):
CONFIG_VERSION_SIGNATURE="Ubuntu 2.6.38-8.42-generic 2.6.38.2"
insmod: ERROR: could not insert module 8188eu.ko: Invalid module format
I'm trying to use the TL-WN725N as an USB WiFi-Adapter with Fedora 20. I followed these insructions and the adapter worked fine and even survived two updates during the last few weeks. Then I did a yum update today, and it still worked fine until I restarted my computer. I tried to reload the module and got insmod: ERROR: could not insert module 8188eu.ko: Invalid module format . What I found out was, that my kernel and the kernel-headers in the module are not the same anymore and that I had to update the kernel, so I did that and got
sudo yum install kernel-headers Loaded plugins: langpacks, refresh-packagekit Package kernel-headers-3.17.3-200.fc20.x86_64 already installed and latest version Nothing to do
1 Answer 1
Your module was built for an earlier kernel (the one that has just been updated).
Make sure that you've rebooted so that you are using the latest kernel.
Confirm that the running kernel and the installed version of kernel-headers is the same.
You'll now need to recompile your module again for the current kernel:
cd rtl8188eu make clean make all make install modprobe -r 8188eu modprobe 8188eu
Unfortunately, you'll have to keep doing this every time you update the kernel until that driver makes it into the mainstream kernel package.
There is a facility called Dynamic Kernel Module Support that can automatically build out-of-tree modules such as yours every time the kernel is updated (VirtualBox drivers use it, for example) but it will involve a fair amount of additional work to configure. You may find that it's more effort than it's worth.
This is the downside of living on the bleeding edge of technology 😉
Building example device driver error: insmod invalid module format
This link explains why invalid module format issues occurs and how to fix it. Take a look here. I see that this is very old thread. Updating it so that, it will help the people who are recently searching for this particular fix.
4 Answers 4
Try running the command without doing the sudo , instead become root and try it.
$ sudo su - $ /sbin/insmod hello1.ko
Also take a look in dmesg to see if there are any additional messages as to what went wrong, and also take a peek at the module using modinfo .
- using the source code of the same version of kernel, kernel source can be found here
- using the same kernel Configuration of the current installed kernel, usually can be found here :
/proc/config.gz /boot/config /boot/config-*
I resolved this by installing headers of correct kernel version.
Welcome to the site, and thank you for your contribution. Please note that brevity is acceptable, but fuller explanations are better. You may want to add a note why you think this approach will solve the OPs problem, in particular considering that the OP didn't state how the kernel module was built in the first place.
You must log in to answer this question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.