免费注册 查看新帖 |

Chinaunix

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

hello驱动模块交叉编译错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-09-19 17:57 |只看该作者 |倒序浏览
本帖最后由 KenZhang1031 于 2017-09-19 18:02 编辑

海思交叉编译器,编译hello模块错误,linux内核目录在/root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y,hello目录在/root/hisi/MyDriver/hello,里面的Makefile为:
  1. PWD         := $(shell pwd)
  2. KERNEL_DIR   = /root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y
  3. MODULE_NAME  = hello
  4. ARCH = arm
  5. CROSS_COMPILE = arm-hisiv200-linux-
  6. CC    = $(CROSS_COMPILE)gcc
  7. obj-m       := $(MODULE_NAME).o   
  8. modules:
  9.         make -C $(KERNEL_DIR) M=$(PWD) modules
  10. clean:
  11.         rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

  12. .PHONY: modules clean
复制代码
内核已经用make ARCH=arm CROSS_COMPILE=arm-hisiv200-linux- uImage编译成功了
编译hello模块的时候,执行make,错误如下:
  1. [root@KenCentOS hello]# make
  2. make -C /root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y M=/root/hisi/MyDriver/hello  modules
  3. make[1]: Entering directory `/root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y'
  4.   CC [M]  /root/hisi/MyDriver/hello/hello.o
  5. cc1: error: unrecognized command line option "-m64"
  6. cc1: error: unrecognized command line option "-mno-red-zone"
  7. cc1: error: unrecognized command line option "-mcmodel=kernel"
  8. cc1: error: unrecognized command line option "-maccumulate-outgoing-args"
  9. cc1: error: unrecognized command line option "-mno-sse"
  10. cc1: error: unrecognized command line option "-mno-mmx"
  11. cc1: error: unrecognized command line option "-mno-sse2"
  12. cc1: error: unrecognized command line option "-mno-3dnow"
  13. cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable"
  14. make[2]: *** [/root/hisi/MyDriver/hello/hello.o] 错误 1
  15. make[1]: *** [_module_/root/hisi/MyDriver/hello] 错误 2
  16. make[1]: Leaving directory `/root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y'
  17. make: *** [modules] 错误 2
复制代码
但是Makefile里面改成make ARCH=arm CROSS_COMPILE=arm-hisiv200-linux- -C $(KERNEL_DIR) M=$(PWD) modules就能编译成功
为什么前面定义的ARCH=arm 和 CROSS_COMPILE=arm-hisiv200-linux- 不起作用,要在make语句定义才有用呢?

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
2 [报告]
发表于 2017-09-19 20:02 |只看该作者
回复 1# KenZhang1031

你修改

  1. PWD         := $(shell pwd)
  2. KERNEL_DIR   = /root/hisi/Hi3531_SDK_V1.0.B.0/osdrv/kernel/linux-3.0.y
  3. MODULE_NAME  = hello
  4. ARCH = arm
  5. CROSS_COMPILE = arm-hisiv200-linux-
  6. CC    = $(CROSS_COMPILE)gcc
  7. obj-m       := $(MODULE_NAME).o  

  8. export ARCH CROSS_COMPILE
  9. modules:
  10.         make -C $(KERNEL_DIR) M=$(PWD) modules
  11. clean:
  12.         rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

  13. .PHONY: modules clean
复制代码
这样就可以了。
加了
  1. export ARCH CROSS_COMPILE
复制代码

评分

参与人数 1信誉积分 +50 收起 理由
KenZhang1031 + 50 问题解决

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP