交叉编译内核模块时构建错误

时间:2012-02-20 15:10:04

标签: linux-kernel arm cross-compiling kernel-module

我正在尝试使用规范交叉编译helloworld内核模块:

  • 主机:intel x86 32位,linux-3.0.0
  • 目标:ARM机器(Parrot AR.Drone),linux-2.6.27.47

我正在使用makefile:

PWD := $(shell pwd)
obj-m := test.o
all:
    $(MAKE) -C /path/to/kernel M=$(PWD) CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm  modules

其中arm-none-linux-gnueabi-是arm工具链的前缀。

使用kernel.org的2.6.27.47内核,会出现以下错误:

make -C /home/jens/linux-2.6.27.47 M=/home/jens/test CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm KBUILD_VERBOSE=1 modules
make[1]: Entering directory `/home/jens/linux-2.6.27.47'
mkdir -p /home/jens/test/.tmp_versions ; rm -f /home/jens/test/.tmp_versions/*

  WARNING: Symbol version dump /home/jens/linux-2.6.27.47/Module.symvers
           is missing; modules will have no dependencies and modversions.

make -f scripts/Makefile.build obj=/home/jens/test
  arm-none-linux-gnueabi-gcc -Wp,-MD,/home/jens/test/.test.o.d  -nostdinc -isystem /opt/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include -D__KERNEL__ -Iinclude  -I/home/jens/linux-2.6.27.47/arch/arm/include -include include/linux/autoconf.h -mlittle-endian  -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -fno-delete-null-pointer-checks -O2 -marm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -msoft-float -Uarm -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(test)"  -D"KBUILD_MODNAME=KBUILD_STR(test)" -c -o /home/jens/test/.tmp_test.o /home/jens/test/test.c
In file included from include/asm/system.h:10,
                 from include/asm/processor.h:17,
                 from include/linux/prefetch.h:14,
                 from include/linux/list.h:6,
                 from include/linux/module.h:9,
                 from /home/jens/test/test.c:1:
include/linux/kernel.h:195: warning: 'regparm' attribute directive ignored
include/linux/kernel.h:197: warning: 'regparm' attribute directive ignored
include/linux/kernel.h:221: warning: 'regparm' attribute directive ignored
In file included from include/linux/thread_info.h:47,
                 from include/linux/preempt.h:9,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:29,
                 from include/linux/time.h:8,
                 from include/linux/stat.h:60,
                 from include/linux/module.h:10,
                 from /home/jens/test/test.c:1:
include/asm/thread_info.h:172: error: invalid register name for 'current_stack_pointer'
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:197: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 /home/jens/test/test.c:1:
include/linux/mmzone.h:218: error: 'MAX_NR_ZONES' undeclared here (not in a function)
In file included from include/linux/rwsem.h:22,
                 from include/linux/notifier.h:14,
                 from include/linux/memory_hotplug.h:6,
                 from include/linux/mmzone.h:560,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/rwsem.h:48: warning: 'regparm' attribute directive ignored
include/asm/rwsem.h:50: warning: 'regparm' attribute directive ignored
include/asm/rwsem.h:52: warning: 'regparm' attribute directive ignored
include/asm/rwsem.h:54: warning: 'regparm' attribute directive ignored
In file included from include/asm/smp.h:12,
                 from include/linux/smp.h:28,
                 from include/linux/topology.h:33,
                 from include/linux/mmzone.h:683,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/mpspec.h:9:25: error: mach_mpspec.h: No such file or directory
In file included from include/asm/smp.h:12,
                 from include/linux/smp.h:28,
                 from include/linux/topology.h:33,
                 from include/linux/mmzone.h:683,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/mpspec.h:36: error: 'MAX_MP_BUSSES' undeclared here (not in a function)
In file included from include/asm/smp.h:15,
                 from include/linux/smp.h:28,
                 from include/linux/topology.h:33,
                 from include/linux/mmzone.h:683,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/io_apic.h:149: error: 'MAX_IRQ_SOURCES' undeclared here (not in a function)
In file included from include/linux/smp.h:28,
                 from include/linux/topology.h:33,
                 from include/linux/mmzone.h:683,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/smp.h:187:28: error: mach_apicdef.h: No such file or directory
In file included from include/linux/smp.h:28,
                 from include/linux/topology.h:33,
                 from include/linux/mmzone.h:683,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /home/jens/test/test.c:1:
include/asm/smp.h: In function 'hard_smp_processor_id':
include/asm/smp.h:191: error: implicit declaration of function 'GET_APIC_ID'
make[2]: *** [/home/jens/test/test.o] Error 1
make[1]: *** [_module_/home/jens/test] Error 2
make[1]: Leaving directory `/home/jens/linux-2.6.27.47'
make: *** [test_arm2] Error 2

就在这里,我被困住了。

1 个答案:

答案 0 :(得分:1)

我的问题是,就像sessyargc.jp建议的那样,由于配置错误。我已经应用了默认配置,而我应该使用特定于arm的配置。使用它,解决了编译问题。