I just made my first driver module, hello world module after LDD3. However, unfortunately, this error occurred:
insmod: error inserting './hello.ko': -1 Invalid module format.
I do this on Ubuntu 11.04 and in my environment:
$ uname -r 2.6.38-8-generic
I get the kernel source as follows:
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
my / usr / src:
$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
and then I compile the kernel
$sudo cp /boot/config-2.6.38-8-generic ./.config $sudo make menuconfig -- load the .config file $make $make modules
and then I compile the kernel module
$make -C /usr/src/linux-source-2.6.38/linux-source-2.6.38 M=`pwd` modules
with makefile:
obj-m := hello.o
and then finally when I insert the module:
$sudo insmod hello_world.ko insmod: error inserting 'hello_world.ko': -1 Invalid module format
what i found in dmesg:
hello: disagrees about version of symbol module_layout
So what's the problem?
I also noticed that linux-header is -2.26.38-generic and source version is -2.26.38, is this a problem? but I really did not find the linux-source-2.26.38-generic package on the Internet.
update status: I found that the file / lib / moduels / $ (name -r) / build / Makefile indicates my current kernel version:
VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 38 EXTRAVERSION = .2
So, I download linux-2.6.38.2 and compile, but still the same error.
I 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"
Does anyone know what that means? I do not see it in the kernel configuration file that I create.