注册 登录
编程论坛 Linux教室

arm hello模块make时错误

elesun8 发布于 2015-01-08 22:31, 4194 次点击
arm hello模块make时错误

宿主机环境:PC 虚拟机 Linux(2.6.18-53.el5)_redhat gcc(4.3.2)
目标机:arm Linux(2.6.29) mini2440 hello.ko模块在本开发板挂载

出现以下错误:
[root@localhost arm_hello_module_makefile]# ls
hello.c  Makefile
[root@localhost arm_hello_module_makefile]# make
make -C /home/sun/linux-2.6.29/ M=/temp/arm_hello_module_makefile modules ARCH=arm CROSS_COMPILE=arm-linux-
make[1]: Entering directory `/home/sun/linux-2.6.29'
  CC [M]  /temp/arm_hello_module_makefile/hello.o
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /temp/arm_hello_module_makefile/hello.c:1:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /temp/arm_hello_module_makefile/hello.c:1:
include/linux/mmzone.h:290: error: 'MAX_NR_ZONES' undeclared here (not in a function)
/temp/arm_hello_module_makefile/hello.c:10: warning: function declaration isn't a prototype
/temp/arm_hello_module_makefile/hello.c:16: warning: function declaration isn't a prototype
make[2]: *** [/temp/arm_hello_module_makefile/hello.o] Error 1
make[1]: *** [_module_/temp/arm_hello_module_makefile] Error 2
make[1]: Leaving directory `/home/sun/linux-2.6.29'
make: *** [all] Error 2



Makefile文件内容如下:
ifneq ($(KERNELRELEASE),)

obj-m := hello.o

else

KDIR := /home/sun/linux-2.6.29/
all:
        make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=arm-linux-
clean:
        rm -f *.ko *.o *.mod.o *.mod.c *.symvers

endif
2 回复
#2
elesun82015-01-09 12:43
没有人遇到过这个问题嘛
#3
elesun82015-01-09 20:51
出现这种错误的原因主要是由于linux内核做过 make clean 命令,把bounds.h 文件清除掉了(可以查看makefile 中的写法),因而需要重新生成这个头文件,使用命令 make prepare
cd linux2.29,make prepare,cd file_module,make   OK
1