linux驱动编译不通过的问题解决
2011-04-09 21:53
316 查看
我的主机是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 编译通过!
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 编译通过!
相关文章推荐
- linux下rtl8188 驱动编译 出现类似 create_proc_entry daemonize 错误问题解决
- Linux环境下驱动编译问题解决
- Linux字符设备驱动-globalmem驱动编译加载遇到的问题及解决办法
- linux下编译新内核,解决无法找到eth0设备问题,安装eth0网卡驱动
- [linux设备驱动程序]scull字符设备驱动编译在新内核编译问题解决方案
- 在编写最简单的linux 内核驱动, 编译后出现的问题以及解决方法。
- Linux编译内核kernel解决USB、网卡驱动等问题【suse enterprise linux】
- Linux 内核编译,解决网卡驱动缺少的问题,使用更新的内核来完善驱动
- boadcom x86_64 431*系列无线网卡驱动在linux 3.10以上内核编译问题的解决
- 解决通过命令行 xcodebuild 编译工程,命令行挂起问题
- Linux下编译安装gtk问题的解决办法
- Ubuntu 11 编译 linux-2.6内核 出错,给出部分编译问题解决
- 34 dht12单总线方式的Linux驱动及解决H3丢失中断的问题
- Linux 环境中从源代码编译安装 ReText 问题与解决
- linux下开发,解决cocos2d-x中编译出现的一个小问题, undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
- 已解决的问题----------vs 中文注释导致编译不能通过!!!
- NCNN在RK3288 Linux系统的原生编译问题解决
- ubuntu环境下编译linux内核问题解决备忘
- 10.24工作笔记——解决linux_jni编译报错问题
- tony之linux driver_LDD3_scull字符设备驱动编译在新内核编译问题