主题 : linux驱动程序无法加载问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 3070
精华: 0
发帖: 17
金钱: 170 两
威望: 162 点
综合积分: 34 分
注册时间: 2008-12-25
最后登录: 2013-05-21
楼主  发表于: 2009-04-10 21:33

 linux驱动程序无法加载问题

编写了简单的hello驱动程序,编译通过,生程hello.ko文件,但是无法insmod,提示Invalid module format 错误,网上查是pc内核版本和编译程序所用版本不同的造成的。因为驱动程序总得针对开发板内核。新手,不知道如果解决这个问题
注,我编译程序时是将2440板子自带的2.6.13内核拷至pclinux中的kernel中,移走了原来kernel文件夹的内核文件。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-04-11 23:49
I think you can try following:

$cd /path/to/your/kernel/source
$cp config_xxx (e.g. config_n35, depens on your board configuration) .config
$make ARCH=arm CROSS_COMPILE=/usr/local/arm/3.4.1/bin/arm-linux- oldconfig modules_prepare

then, re-compile your kernel module and try again
[ 此帖被kasim在2009-04-11 23:55重新编辑 ]
"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: 3070
精华: 0
发帖: 17
金钱: 170 两
威望: 162 点
综合积分: 34 分
注册时间: 2008-12-25
最后登录: 2013-05-21
2楼  发表于: 2009-04-12 13:04
阁下意思是不是修改makefile,重新编译内核,可是我发帖之前已经是按照config_n35编译过内核了。
又不太理解“oldconfig modules_prepare”。。。
不过谢谢你,回头再试试。
thx
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2009-04-12 13:14

 回 2楼(lianwei) 的帖子

我的意思不是让你修改makefile或者编译内核, 只是根据你目前用的开发板,加载对应的内核配置。
"oldconfig modules_prepare"是两个make的target, 用来使内核当前配置生效,并且为编译内核模块做好准备。理论上,你用modinfo命令看你编译出来的内核应该会看到version magic是2.6.13 preempt ARMv4 gcc-3.4

可以的话, 把具体出错信息贴出来,这样解决问题会比较准确一些
"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: 3070
精华: 0
发帖: 17
金钱: 170 两
威望: 162 点
综合积分: 34 分
注册时间: 2008-12-25
最后登录: 2013-05-21
4楼  发表于: 2009-04-15 13:37
前两天已经将问题解决,原因我我用友善提供的内核编译驱动,但是驱动却放到了扬创2440开发板上加载了,起初我误以为只要内核版本一样就行(扬创的也是2.6.13内核),谁知道还是有差别。
thx~