免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2886 | 回复: 4
打印 上一主题 下一主题

[驱动] arm hello模块make时错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-01-08 22:30 |只看该作者 |倒序浏览
arm hello模块make时错误

宿主机环境:PC 虚拟机 Linux(2.6.18-53.el5)_redhat gcc(4.3.2)
目标机:arm Linux(2.6.29) mini2440 hello.ko模块在本开发板挂载

出现以下错误:
[root@localhost arm_hello_module_makefile]# ls
hello.c  Makefile
[root@localhost arm_hello_module_makefile]# make
make -C /home/sun/linux-2.6.29/ M=/temp/arm_hello_module_makefile modules ARCH=arm CROSS_COMPILE=arm-linux-
make[1]: Entering directory `/home/sun/linux-2.6.29'
  CC [M]  /temp/arm_hello_module_makefile/hello.o
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /temp/arm_hello_module_makefile/hello.c:1:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /temp/arm_hello_module_makefile/hello.c:1:
include/linux/mmzone.h:290: error: 'MAX_NR_ZONES' undeclared here (not in a function)
/temp/arm_hello_module_makefile/hello.c:10: warning: function declaration isn't a prototype
/temp/arm_hello_module_makefile/hello.c:16: warning: function declaration isn't a prototype
make[2]: *** [/temp/arm_hello_module_makefile/hello.o] Error 1
make[1]: *** [_module_/temp/arm_hello_module_makefile] Error 2
make[1]: Leaving directory `/home/sun/linux-2.6.29'
make: *** [all] Error 2



Makefile文件内容如下:
ifneq ($(KERNELRELEASE),)

obj-m := hello.o

else

KDIR := /home/sun/linux-2.6.29/
all:
        make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=arm-linux-
clean:
        rm -f *.ko *.o *.mod.o *.mod.c *.symvers

endif

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
2 [报告]
发表于 2015-01-20 13:38 |只看该作者
看上去有可能是kernel版本没有对上
报错是没有找到对应的头文件

论坛徽章:
0
3 [报告]
发表于 2015-01-22 15:31 |只看该作者
编译环境:
linux-2.6.29 arm-linux-gcc gcc 4.3.2

加载方法:
1.  hello_module.ko文件正确
hello_module.ko  对应的编译内核与ARM开发板内核一致
如果内核不一致,不兼容,则会显示路径变换chdir

2.  路径正确
#cp hello_module.ko /lib/modules/2.6.29.4-FriendlyARM/
如果路径不正确,则会找不到模块

3.  加载查看卸载
#modprobe hello_module 加载模块
#lsmod  查看使用的模块
#rmmod hello_module  卸载模块

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
4 [报告]
发表于 2015-01-23 17:06 |只看该作者
elesun8 发表于 2015-01-22 15:31
编译环境:
linux-2.6.29 arm-linux-gcc gcc 4.3.2


?说什么呢?

论坛徽章:
0
5 [报告]
发表于 2015-01-23 17:20 |只看该作者
问题已解决,这是我的总结。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP