主题 : 驱动无法插入的问题 - insmod: kernel-module version mismatch,求解 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 2660
精华: 1
发帖: 17
金钱: 130 两
威望: 46 点
贡献值: 10 点
综合积分: 54 分
注册时间: 2008-12-01
最后登录: 2013-06-13
楼主  发表于: 2008-12-10 16:43

 驱动无法插入的问题 - insmod: kernel-module version mismatch,求解

管理提醒: 本帖被 qq2440 执行取消置顶操作(2009-08-07)
按照mini2440手册上所写,将启动改为NFS启动。
简单编译了一个hello.ko
直接引用开发板自带的内核源码包。
编译通过。

在板上执行insmod hello.ko时,报告以下错误:

Using hello.ko
insmod: kernel-module version mismatch
        hello.ko was compiled for kernel version
        while this kernel is version 2.6.13.

发现检测不到hello.ko对应的内核版本,不知道是什么原因。
[ 此帖被kasim在2008-12-13 08:06重新编辑 ]
级别: 新手上路
UID: 2660
精华: 1
发帖: 17
金钱: 130 两
威望: 46 点
贡献值: 10 点
综合积分: 54 分
注册时间: 2008-12-01
最后登录: 2013-06-13
1楼  发表于: 2008-12-10 16:44
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE ("Dual BSD/GPL");

static int hello_init (void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init (hello_init);
module_exit (hello_exit);


驱动代码
级别: 新手上路
UID: 2660
精华: 1
发帖: 17
金钱: 130 两
威望: 46 点
贡献值: 10 点
综合积分: 54 分
注册时间: 2008-12-01
最后登录: 2013-06-13
2楼  发表于: 2008-12-10 16:44
makefile:

ifneq ($(KERNELRELEASE),)
    obj-m := hello.o
else
    KERNELDIR ?= /home/cpsoft/mini2440/kernel-2.6.13
#    KERNELDIR ?= /home/cpsoft/toolchain/linux-2.6.25
    PWD := $(shell pwd)

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2008-12-11 06:31
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 2660
精华: 1
发帖: 17
金钱: 130 两
威望: 46 点
贡献值: 10 点
综合积分: 54 分
注册时间: 2008-12-01
最后登录: 2013-06-13
4楼  发表于: 2008-12-11 12:47
谢谢楼上兄弟的答复。

同时附上网上兄弟编译busybox-1.13.1的过程
http://hi.baidu.com/mystreetzone/blog/item/e816d21634f8f456f3de3273.html

My 2410编译busybox
by hipboi ee team
at.the.street@gmail.com
主机:ubuntu 8.10 x86_64
交叉编译器:/usr/local/arm/3.3.2/bin/arm-linux-
Busybox版本:busybox-1.13.1.tar.bz2
Busybox嵌入式Linux中的瑞士军刀
BusyBox - The Swiss Army Knife of Embedded Linux
首先,去http://busybox.net/下载最新版本的busybox,目前最新版为29 November 2008 -- BusyBox 1.13.1
解压,进入目录,
make menuconfig
Busybox Settings-->Build Options--> Build BusyBox as a static binary (no shared libs) 选上。静态编译,为了以后方便。
在Busybox Settings-->Build Options-->Cross Compiler Prefix
填入交叉编译器路径。这里用3.3.2的版本。
由于编译器版本,glibc的版本匹配问题,编译过程中可能会出错。有些错误是莫名其妙的。
编译过程中出现了
In file included from miscutils/watchdog.c:13:
/usr/local/arm/3.3.2/arm-linux/sys-include/linux/watchdog.h:17: error: parse error before "__u32"
/usr/local/arm/3.3.2/arm-linux/sys-include/linux/watchdog.h:19: error: parse error before "identity"
/usr/local/arm/3.3.2/arm-linux/sys-include/linux/watchdog.h:20: error: parse error before '}' token
make[1]: *** [miscutils/watchdog.o] 错误 1
make: *** [miscutils] 错误 2
可是/usr/local/arm/3.3.2/arm-linux/sys-include/linux/watchdog.h相关行
struct watchdog_info {
__u32 options; /* Options the card/driver supports */
__u32 firmware_version; /* Firmware version of the card */
__u8 identity[32]; /* Identity of the board */
};
并没有语法错误,解决办法为,去掉相应选项,
make menuconfig
去掉Miscellaneous Utilities --->里的最后一个watchdog(实际上它是指pc机上的,和我们板子的看门狗没有关系)
继续make
networking/brctl.c: In function `brctl_main':
networking/brctl.c:186: error: `SIOCBRADDBR' undeclared (first use in this function)
networking/brctl.c:186: error: (Each undeclared identifier is reported only once
networking/brctl.c:186: error: for each function it appears in.)
networking/brctl.c:186: error: `SIOCBRDELBR' undeclared (first use in this function)
networking/brctl.c:202: error: `SIOCBRADDIF' undeclared (first use in this function)
networking/brctl.c:202: error: `SIOCBRDELIF' undeclared (first use in this function)
make[1]: *** [networking/brctl.o] 错误 1
make: *** [networking] 错误 2
在3.3.2的编译器/usr/local/arm/3.3.2/arm-linux/sys-include/linux/sockios.h里没有找到
SIOCBRDELBR等相关定义,解决办法:在自己电脑的内核头文件里找到相关定义,并加入。
稍微新一点的内核都应该增加了以下定义,
#define SIOCBRADDBR 0x89a0 /* create new bridge device */
#define SIOCBRDELBR 0x89a1 /* remove bridge device */
#define SIOCBRADDIF 0x89a2 /* add interface to bridge */
#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */
把他们加入到busybox的networking/brctl.c
继续,make
networking/ifenslave.c出错,出错信息太多,直接去掉选项。
接着,networking/interface.o出错,
ARPHRD_INFINIBAND没有定义,
由主机上的内核源码目录include/linux/if_arp.h可知,其值为32
在networking/ifenslave.c合适的地方加上
#define ARPHRD_INFINIBAND 32 /* InfiniBand */
再make,通过编译。
然后make install
在 _install目录下得到所有二进制文件。

我发现友善提供的根文件系统中insmod是链接到modbox上的。所以除了从新安装busybox外,还需要将链接也修改掉。
级别: 新手上路
UID: 4017
精华: 0
发帖: 15
金钱: 100 两
威望: 44 点
贡献值: 0 点
综合积分: 30 分
注册时间: 2009-02-21
最后登录: 2012-03-10
5楼  发表于: 2009-04-19 16:53
我发现友善提供的根文件系统中insmod是链接到modbox上的。所以除了从新安装busybox外,还需要将链接也修改掉。

这怎么改?
自信人生两百年
级别: 新手上路
UID: 8078
精华: 0
发帖: 10
金钱: 70 两
威望: 36 点
贡献值: 0 点
综合积分: 20 分
注册时间: 2009-08-09
最后登录: 2015-08-14
6楼  发表于: 2009-08-15 18:26
我检查我的NFS,其实已经安装了Busybox ,版本是2.0的。情况还是一样提示版本不匹配。目前还是没有办法动态加入一个简单的驱动。
级别: 新手上路
UID: 17756
精华: 0
发帖: 5
金钱: 30 两
威望: 6 点
贡献值: 0 点
综合积分: 10 分
注册时间: 2010-04-01
最后登录: 2010-04-27
7楼  发表于: 2010-04-08 00:10

 Re:驱动无法的问题 - insmod: kernel-module version mismatch,求解

version magic '2.6.32.2 mod_unload modversions ARMv5 '  should be '2.6.32.2-FriendlyARM mod_unload ARMv4 '
我在插入时遇到这样的问题。怎么改写呢?
重新换驱动吗?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
8楼  发表于: 2010-04-08 11:38

 回 7楼(qianlin256) 的帖子

在编译模块之前,你必须先正确地配置内核源代码。看你的开发板使用手册。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."