简体   繁体   English

Raspberry Pi上的Linux内核模块错误

[英]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: 当我查看dmesg时,我看到此错误:

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. 听起来您下载的内核源与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 ) 现在,您应该在/lib/modules/下看到一个与您的内核版本相匹配的目录(当您键入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: 重新编译并链接您的代码-通过在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. 现在,新编译的.ko模块应该与您的内核匹配,并且插入时不会有任何抱怨。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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