/usr/src/kernels/ 下没有当前内核文件夹 及 insmod错误Invalid module format

8 篇文章 0 订阅

我是在加载设备驱动程序的时候遇到的问题。

$ sudo insmod Dev_hello.ko


然后出现了问题 


Error: could not insert module Dev_hello.ko: Invalid module format



通过查 *.ko 文件vermagic和内核版本号:
[lgw@localhost shareArm]$ sudo modinfo Dev_hello.ko [sudo] password for lgw: filename: /home/lgw/shareArm/Dev_hello.ko depends: vermagic: 3.5.0-2.fc17.i686 SMP mod_unload 686

 

lgw@localhost shareArm]$ uname -r 3.5.0-2.fc17.i686.PAE

然后在网上还查到执行命令cat /var/log/message | tail 命令去查看日志文件错误信息

相关部分:

Aug 10 14:24:29 localhost kernel: [14410.773882] Dev_hello: version magic '3.5.0-2.fc17.i686 SMP mod_unload 686 ' should be '3.5.0-2.fc17.i686.PAE SMP mod_unload 686 ' 



=========================================内核问题==============================

 

然后我查看我的内核根目录是/usr/src/kernels/

里面只有3.5.0-2.fc17.i686 文件夹,而我的内核版本是PAE版的,却没有这个选项。

而在之前Makefile中用到的 /lib/modules下却有三个文件夹:3.3.4-5.fc17.i686 3.5.0-2.fc17.i686 3.5.0-2.fc17.i686.PAE

Makefile中相关的几句是:

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

结果是这样一条命令:make -C /lib/modules/3.5.0-2.fc17.i686.PAE/build M=/home/lgw/shareArm modules

这个build的软链接是链接到 /usr/src/kernels/3.5.0-2.fc17.i686.PAE,但是这个链接是不存在的,于是我将这个链接改到没有PAE的那个文件夹上去了,结果Makefile可以make成功了,但是,insmod却一直报错。(我好废话啊~~~毕竟辛苦试了一天,各种找方法,各种试,至少最后找到办法了!还是google比较强大,各种英文的论坛看啊)


===========================================================================

===============================解决办法=====================================

===========================================================================


sudo yum isntall kernel-PAE-devel




然后/usr/src/kernels/文件夹下就出现了3.5.0-2.fc17.i686.PAE文件夹。


谢谢回复我http://topic.csdn.net/u/20120810/14/a350bd84-ff57-4a44-bb88-1960fe5f21c3.html?seed=1160754062&r=79376733#r_79376733这篇帖子的两位朋友!


下面晒一晒我加载好的驱动!

(图中可以看出进入的文件夹路径是带PAE的~)


(加载后,$  dmesg)



(卸载后,$  dmesg)




参考:

 

fedoraforum.org论坛该帖子的5楼

Old  17th April 2010, 10:44 PM
smr54  Online
Registered User
 
Join Date: Jan 2010
Posts: 4,055
linuxopera
Re: No kernel source files in /usr/src/kernels/ directory

Hrrm, looking at the Fedora link CSchwangler provided, it seems to me that they're making a very simple thing more complex than it is, as well as not even giving the necessary information. 


If you have the i686 kernel, chances are that it runs the PAE kernel by default. Rather than using the vanilla kernel, you're usually better off, when using Fedora, to use its own kernel packages. 

Do 

uname -r

If it has the letters PAE in it, then do 

yum install kernel-PAE-devel

Actually, probably better off doing yum update linux-kernel, and if a later kernel is available, reboot into it, then do yum isntall kernel-PAE-devel, to make sure that there are no version mismatches. (I'd also remove the links you've already created to avoid conflicts.)

Then you're done, almost no muss, fuss, or bother.



  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值