网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 操作系统 > Linux
本月文章推荐
.Linux操作系统JDK中文字体设置方.
.The Linux Bootdisk HOWTO 中译版.
.新版Ubuntu Linux系统威胁Window.
.在Linux终端下不常用但很有用的查.
.在一个硬盘上安装两个Linux操作系.
.做一个最小的Linux kernel.
.Linux用户要注意修复漏洞.
.Ubuntu Linux:MySQL安装指南.
.关于Linux和Windows文件路径的解.
.Linux命令Man解释:groupmod :修改.
.让linux支持你的DMA66硬盘.
.新手看招:在Linux系统下玩Windo.
.Linux 网管 123 --- 第10章. 升级.
.Linux系统上从源代码安装软件的一.
.Ubuntu Linux显示器屏幕偏移的解.
.Redhat9.0 下DNS配置笔记.
.文件的存取权限—模式位疑难详解.
.rpm命令参数列表.
.The Linux BootPrompt-HowTo 中译.
.Linux用mrtg监控网络设备端口流量.

Linux驱动Invalid module format错误解决

发表日期:2008-5-10


 

1.编译错误(其实这个问题和 Makefile有很大关系)

2.Invalid module format 错误

3.insmod: error inserting './hello.ko': -1 File exists

开发环境

内核版本:2.6.22(我下载的最新版本)

gcc:gcc (GCC) 4.1.2

Makefile

gcc -D__KERNEL__ -DMODULE -DLINUX -I /usr/local/src/linux2.4/include -c -o hello.o hello.c

上面这种写法适合 2.4 版本的内核,在2.6下用这种写法很可能导致许多编译错误,即使编译通过也会产生 Invalid module format 错误。

2.6下正确的 Makefie 如下:

# Makefile2.6
ifneq ($(KERNELRELEASE),)
#kbuild syntax. dependency relationshsip of files and target modules are listed here.
mymodule-objs := hello.o
obj-m := hello.o 
else
PWD := $(shell pwd)
KVER ?= $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD)
clean:
rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions
endif

使用上面的 Makefie 同时也解决了 Invalid module format 错误

insmod: error inserting './hello.ko': -1 File exists 错误解决

第一次insmod ./hello.ko 没有输出表示你的模块被正常载入了,后来的错误是你重复载入这个模块导致的

用命令 lsmod | grep hello 看看是不是有这个模块?

用命令 tail /var/log/messages

有 hello,world

module程序正常执行。

上一篇:技巧:为Fedora Linux 8设置本地更新源 人气:1027
下一篇:Linux操作系统上去掉文件属性的命令介绍 人气:816
浏览全部Linux的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐