简体   繁体   中英

Linux Kernel Module Error on Raspberry Pi

I have got one of the small raspberry pi computers, and i am having my first play with creating a kernel module. I have downloaded the source, and managed to compile my test module but when i try and load it i get this error:

insmod: error inserting 'hello.ko': -1 Invalid module format

and when i look in dmesg i see this error:

hello: version magic '3.1.9+ mod_unload modversions ARMv6 p2v8 ' should be '3.1.9+ mod_unload modversions ARMv6 '

Can anyone point me in the right direction, i'm not sure what its telling me?

Cheers Luke

It sounds like the kernel source you downloaded does not match the kernel installed on your Pi.

Where did you download it from?

To get the correct source for your kernel type the following on the command line:

sudo apt-get install linux-source 

This should download the correct kernel source for you kernel (it is a meta-package). You should now see a directory under /lib/modules/ that matches your kernel version (the version printed out when you type uname -r )

Recompile and link you code - make sure you pick up the correct kernel source by having a line like this in your Makefile:

all:
    make -C /lib/modules/$(shell uname -r)/build M=${PWD} modules

You newly compiled .ko module should now match you kernel and insert without complaints.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM