linux找不到mach/regs-gpio.h文件,郁闷啊
时间:10-02
整理:3721RD
点击:
我把TQ2440开发板的linux源代码放到了虚拟机上面,用的是redhat 4 企业版,并且把EABI编译器安装上了,编译内核的时候没有问题,能生成zImage,可我编写驱动程序的时候,linux/下的文件都能找到,比如 #include <linux/fs.h>,但是mach下的却找不到,#include <mach/regs-gpio.h> 就会出现 No directory。,但是涉及硬件必须要用啊,郁闷,我想知道,编译器是怎么寻找头文件的,这种情况到底是怎么回事,一概不知啊,恳请哪路大神帮小弟一把!
Makefile的内容
ifneq ($(KERNELRELEASE),)
obj-m :=EmbedSky_gpio.o
ARCH =arm
CROSS_COMPILE =arm-linux-
else
KERNELDIR =/opt/EmbedSky/linux-2.6.30.4/
#KERNELDIR=/lib/modules/$(shell uname -r)/build
#KERNELDIR=/usr/src/kernels/2.6.21-1.3194.fc7-i686
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
endif
结果:
[root@vm-dev led]# make
make -C /opt/EmbedSky/linux-2.6.30.4/ M=/lifuxing/led modules
make[1]: Entering directory `/opt/EmbedSky/linux-2.6.30.4'
CC [M] /lifuxing/led/EmbedSky_gpio.o
/led/EmbedSky_gpio.c:11:28: error: mach/regs-gpio.h: No such file or directory
/led/EmbedSky_gpio.c:42: error: 'S3C2410_GPB5' undeclared here (not in a function)
/led/EmbedSky_gpio.c:43: error: 'S3C2410_GPB6' undeclared here (not in a function)
/led/EmbedSky_gpio.c:44: error: 'S3C2410_GPB7' undeclared here (not in a function)
/led/EmbedSky_gpio.c:45: error: 'S3C2410_GPB8' undeclared here (not in a function)
/led/EmbedSky_gpio.c:51: error: 'S3C2410_GPB5_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:51: error: initializer element is not constant
/led/EmbedSky_gpio.c:51: error: (near initialization for 'gpio_cfg_table[0]')
/led/EmbedSky_gpio.c:52: error: 'S3C2410_GPB6_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:52: error: initializer element is not constant
/led/EmbedSky_gpio.c:52: error: (near initialization for 'gpio_cfg_table[1]')
/led/EmbedSky_gpio.c:53: error: 'S3C2410_GPB7_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:53: error: initializer element is not constant
/led/EmbedSky_gpio.c:53: error: (near initialization for 'gpio_cfg_table[2]')
/led/EmbedSky_gpio.c:54: error: 'S3C2410_GPB8_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:54: error: initializer element is not constant
/led/EmbedSky_gpio.c:54: error: (near initialization for 'gpio_cfg_table[3]')
/led/EmbedSky_gpio.c: In function 'tq2440_gpio_ioctl':
/led/EmbedSky_gpio.c:72: error: implicit declaration of function 's3c2410_gpio_setpin'
/led/EmbedSky_gpio.c: In function 'dev_init':
/led/EmbedSky_gpio.c:104: error: implicit declaration of function 's3c2410_gpio_cfgpin'
make[2]: *** [/led/EmbedSky_gpio.o] 错误 1
make[1]: *** [_module_/led] 错误 2
make[1]: Leaving directory `/opt/EmbedSky/linux-2.6.30.4'
make: *** [default] 错误 2
[root@vm-dev led]#
Makefile的内容
ifneq ($(KERNELRELEASE),)
obj-m :=EmbedSky_gpio.o
ARCH =arm
CROSS_COMPILE =arm-linux-
else
KERNELDIR =/opt/EmbedSky/linux-2.6.30.4/
#KERNELDIR=/lib/modules/$(shell uname -r)/build
#KERNELDIR=/usr/src/kernels/2.6.21-1.3194.fc7-i686
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
endif
结果:
[root@vm-dev led]# make
make -C /opt/EmbedSky/linux-2.6.30.4/ M=/lifuxing/led modules
make[1]: Entering directory `/opt/EmbedSky/linux-2.6.30.4'
CC [M] /lifuxing/led/EmbedSky_gpio.o
/led/EmbedSky_gpio.c:11:28: error: mach/regs-gpio.h: No such file or directory
/led/EmbedSky_gpio.c:42: error: 'S3C2410_GPB5' undeclared here (not in a function)
/led/EmbedSky_gpio.c:43: error: 'S3C2410_GPB6' undeclared here (not in a function)
/led/EmbedSky_gpio.c:44: error: 'S3C2410_GPB7' undeclared here (not in a function)
/led/EmbedSky_gpio.c:45: error: 'S3C2410_GPB8' undeclared here (not in a function)
/led/EmbedSky_gpio.c:51: error: 'S3C2410_GPB5_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:51: error: initializer element is not constant
/led/EmbedSky_gpio.c:51: error: (near initialization for 'gpio_cfg_table[0]')
/led/EmbedSky_gpio.c:52: error: 'S3C2410_GPB6_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:52: error: initializer element is not constant
/led/EmbedSky_gpio.c:52: error: (near initialization for 'gpio_cfg_table[1]')
/led/EmbedSky_gpio.c:53: error: 'S3C2410_GPB7_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:53: error: initializer element is not constant
/led/EmbedSky_gpio.c:53: error: (near initialization for 'gpio_cfg_table[2]')
/led/EmbedSky_gpio.c:54: error: 'S3C2410_GPB8_OUTP' undeclared here (not in a function)
/led/EmbedSky_gpio.c:54: error: initializer element is not constant
/led/EmbedSky_gpio.c:54: error: (near initialization for 'gpio_cfg_table[3]')
/led/EmbedSky_gpio.c: In function 'tq2440_gpio_ioctl':
/led/EmbedSky_gpio.c:72: error: implicit declaration of function 's3c2410_gpio_setpin'
/led/EmbedSky_gpio.c: In function 'dev_init':
/led/EmbedSky_gpio.c:104: error: implicit declaration of function 's3c2410_gpio_cfgpin'
make[2]: *** [/led/EmbedSky_gpio.o] 错误 1
make[1]: *** [_module_/led] 错误 2
make[1]: Leaving directory `/opt/EmbedSky/linux-2.6.30.4'
make: *** [default] 错误 2
[root@vm-dev led]#
我把这个文件单独放到所在驱动的目录下,依然不好使。
我把Makefile里面的obj-m改成obj-y就可以了,可是我不明白这是为什么
按理说这种状况不应该出现,首先确认下你的目录是不是正确的,还有就是尝试一下这个目录下的其他头文件能不能include进来。可以进一步回帖,跟你讨论下。
obj-y:把由foo.c 或者 foo.s 文件编译得到foo.o 并连接进内核.
obj-m: 则表示该文件作为模块编译.
除了y、m以外的obj-x 形式的目标都不会被编译。
除了obj-形式的目标以外,还有lib-y library 库、hostprogs-y 主机程序。
hello-objs := file1.o file2.o ...... 多文件时,用这种形式
目标定义是Kbuild Makefile的主要部分,也是核心部分。主要是定义了要编 译的文件,所有的选项,以及到哪些子目录去执行递归操作。
最简单的Kbuild makefile 只包含一行: 例子: obj-y += foo.o 该例子告诉Kbuild在这目录里,有一个名为foo.o的目标文件。foo.o将从foo.c 或foo.S文件编译得到。 如果foo.o要编译成一模块,那就要用obj-m了。所采用的形式如下: 例子: obj-$(CONFIG_FOO) += foo.o $(CONFIG_FOO)可以为y(编译进内核) 或m(编译成模块)。如果CONFIG_FOO不是y 和m,那么该文件就不会被编译链接了;