linux驱动编译不通过的问题解决

 我的主机是Ubuntu10.10,目标板上配置的linux2.6.33版本的内核,前两天碰到的问题是,在编写好的驱动目录下面使用make命令后报错如下:

 

ickens@ubuntu:~/Drivers$ make
make -C /home/dickens/linux-2.6.33 M=/home/dickens/Drivers modules
make[1]: 正在进入目录 `/home/dickens/linux-2.6.33'
  CC [M] /home/dickens/Drivers/Led.o
In file included from include/linux/prefetch.h:14,
  from include/linux/list.h:6,
  from include/linux/kobject.h:20,
  from include/linux/device.h:17,
  from include/linux/dma-mapping.h:4,
  from /home/dickens/Drivers/Led.c:2:
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:117: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:117: error: requested alignment is not a constant
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:163: warning: "cache_line_size" redefined
include/linux/cache.h:64: note: this is the location of the previous definition
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:243: error: requested alignment is not a constant
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:274: error: requested alignment is not a constant
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h: In function ‘native_get_debugreg’:
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:506: error: invalid application of ‘sizeof’ to incomplete type ‘struct bug_entry’  
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h: In function ‘native_set_debugreg’:
/home/dickens/linux-2.6.33/arch/x86/include/asm/processor.h:533: error: invalid application of ‘sizeof’ to incomplete type ‘struct bug_entry

 

这些只是错误的一部分,我的makefile写法如下,

 

ARCH=arm

CROSS_COMPILE=arm-linux-
obj-m := Led.o
KDIR := /home/dickens/linux-2.6.33
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean

 

其中,我的内核源码放在/home/dickens/linux-2.6.33 ,按道理路径不会有问题,我所用到的头文件也都存在,不应该有这么多错误,后来仔细分析发现,报错基本上都是在x86的体系文件下,仔细想想,目标板应该是Arm体系,固然不会是x86的结构,在网上搜了很久发现,在linux的顶层Makefile文件里面,有一个ARCH= 的选项,对比后发现,我下载的内核里面这一项写的事ARCH=x86 ,后来我把这一项直接改成ARCH=arm ,保存,然后回到驱动程序的目录下,make 编译通过!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值