求助:交叉编译驱动模块报错

内核编译和嵌入式产品的设计与开发
回复
foxrommel
帖子: 2
注册时间: 2010-11-24 20:42

求助:交叉编译驱动模块报错

#1

帖子 foxrommel » 2010-11-24 20:59

有一个简单的helloworld驱动程序,只有基本的安装和卸载功能,并打印出语句。现在已经在PC上编译出.ko模块,然后insmod加载到内核,这些都已经实现了。现在我想把这个驱动加载到2440开发板的嵌入式linux上,于是arm-linux-gcc交叉编译,但是报错了,请问如何解决?
我的配置:PC机ubuntu9.04,2.6.28,arm-linux-gcc 4.3.3; 开发板2440,linux 2.6.30
Makefile如下:
# Makefile 2.6

obj-m += hello.o

CC=arm-linux-gcc

KDIR:=/lib/modules/$(shell uname -r)/build

#PWD=$(shell pwd)

all:

make -C $(KDIR) M=$(PWD) modules

clean:

make -C $(KDIR) M=$(PWD) clean
报错:
root@xdh-laptop:/home/xdh/helloworld# make
make -C /lib/modules/2.6.28-11-generic/build M=/home/xdh/helloworld modules
make[1]: 正在进入目录 `/usr/src/linux-headers-2.6.28-11-generic'
CC [M] /home/xdh/helloworld/hello.o
Assembler messages:
Error: unknown architecture `i586'

Error: unrecognized option -march=i586
cc1: error: unrecognized command line option "-m32"
cc1: error: unrecognized command line option "-mregparm=3"
cc1: error: unrecognized command line option "-mpreferred-stack-boundary=2"
cc1: error: unrecognized command line option "-mno-sse"
cc1: error: unrecognized command line option "-mno-mmx"
cc1: error: unrecognized command line option "-mno-sse2"
cc1: error: unrecognized command line option "-mno-3dnow"
/home/xdh/helloworld/hello.c:1: error: bad value (generic) for -mtune= switch
/home/xdh/helloworld/hello.c:1: error: bad value (i586) for -march= switch
make[2]: *** [/home/xdh/helloworld/hello.o] 错误 1
make[1]: *** [_module_/home/xdh/helloworld] 错误 2
make[1]:正在离开目录 `/usr/src/linux-headers-2.6.28-11-generic'
make: *** [all] 错误 2
头像
tonghuix
帖子: 355
注册时间: 2010-10-08 0:55

Re: 求助:交叉编译驱动模块报错

#2

帖子 tonghuix » 2010-11-25 0:29

看一下你的arm-linux-gcc版本
另外,有可能是需要指定一下编译参数
-march=armv4t -mthumb
/***
* @tonghuix 佟辉 Tong Hui
* @brief 启智开源 编码自由
* @brief Open Source Open Mind, Coding for free!
* @website: https://tonghuix.io
* @weibo http://weibo.com/234826309
* @Twitter http://twitter.com/tonghuix
* @G+ http://gplus.to/tonghuix
*/
回复