编译内核驱动模块的时候错误解决方案

来源:互联网 发布:sqlserver 导出数据 编辑:程序博客网 时间:2024/06/15 14:54

makefile:

ifeq ($(KERNELRELEASE),)KERNELDIR ?= /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/PWD := $(shell pwd)modules:$(MAKE) -C $(KERNELDIR) M=$(PWD) modulesmodules_install:$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_installclean:rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions.PHONY: modules modules_install cleanelse    obj-m := channel_drv.oendif

错误如下:

make -C /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/ M=/home/sfe1012/GSRD/Qt/FpgaChannelDriver modulesmake[1]: Entering directory '/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12'  CC [M]  /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.oIn file included from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/bitops.h:16:0,                 from include/linux/bitops.h:22,                 from include/linux/kernel.h:10,                 from include/linux/cache.h:4,                 from include/linux/time.h:4,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/arch_hweight.h:53:42: error: expected ‘:’ or ‘)’ before ‘POPCNT64’  asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)                                          ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/alternative.h:98:31: note: in definition of macro ‘ALTINSTR_REPLACEMENT’  b_replacement(number)":\n\t" newinstr "\n" e_replacement(number) ":\n\t"                               ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/arch_hweight.h:53:7: note: in expansion of macro ‘ALTERNATIVE’  asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)       ^In file included from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/segment.h:148:0,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/ptrace.h:4,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/alternative.h:8,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/bitops.h:16,                 from include/linux/bitops.h:22,                 from include/linux/kernel.h:10,                 from include/linux/cache.h:4,                 from include/linux/time.h:4,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/processor.h: At top level:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/cache.h:7:25: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function) #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/cache.h:8:30: note: in expansion of macro ‘L1_CACHE_SHIFT’ #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)                              ^include/linux/cache.h:12:25: note: in expansion of macro ‘L1_CACHE_BYTES’ #define SMP_CACHE_BYTES L1_CACHE_BYTES                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/processor.h:131:30: note: in expansion of macro ‘SMP_CACHE_BYTES’ } __attribute__((__aligned__(SMP_CACHE_BYTES)));                              ^In file included from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/thread_info.h:22:0,                 from include/linux/thread_info.h:54,                 from include/linux/preempt.h:9,                 from include/linux/spinlock.h:50,                 from include/linux/seqlock.h:35,                 from include/linux/time.h:5,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/processor.h:164:0: warning: "cache_line_size" redefined #define cache_line_size() (boot_cpu_data.x86_cache_alignment) ^In file included from include/linux/time.h:4:0,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:include/linux/cache.h:64:0: note: this is the location of the previous definition #define cache_line_size() L1_CACHE_BYTES ^In file included from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic.h:274:0,                 from include/linux/atomic.h:4,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/thread_info.h:23,                 from include/linux/thread_info.h:54,                 from include/linux/preempt.h:9,                 from include/linux/spinlock.h:50,                 from include/linux/seqlock.h:35,                 from include/linux/time.h:5,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:19:40: error: unknown type name ‘atomic64_t’ static inline long atomic64_read(const atomic64_t *v)                                        ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h: In function ‘atomic64_read’:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:21:32: error: request for member ‘counter’ in something not a structure or union  return (*(volatile long *)&(v)->counter);                                ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h: At top level:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:31:33: error: unknown type name ‘atomic64_t’ static inline void atomic64_set(atomic64_t *v, long i)                                 ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:43:41: error: unknown type name ‘atomic64_t’ static inline void atomic64_add(long i, atomic64_t *v)                                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:57:41: error: unknown type name ‘atomic64_t’ static inline void atomic64_sub(long i, atomic64_t *v)                                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:73:49: error: unknown type name ‘atomic64_t’ static inline int atomic64_sub_and_test(long i, atomic64_t *v)                                                 ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:89:33: error: unknown type name ‘atomic64_t’ static inline void atomic64_inc(atomic64_t *v)                                 ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:102:33: error: unknown type name ‘atomic64_t’ static inline void atomic64_dec(atomic64_t *v)                                 ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:117:41: error: unknown type name ‘atomic64_t’ static inline int atomic64_dec_and_test(atomic64_t *v)                                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:135:41: error: unknown type name ‘atomic64_t’ static inline int atomic64_inc_and_test(atomic64_t *v)                                         ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:154:49: error: unknown type name ‘atomic64_t’ static inline int atomic64_add_negative(long i, atomic64_t *v)                                                 ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:171:48: error: unknown type name ‘atomic64_t’ static inline long atomic64_add_return(long i, atomic64_t *v)                                                ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:176:48: error: unknown type name ‘atomic64_t’ static inline long atomic64_sub_return(long i, atomic64_t *v)                                                ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:184:37: error: unknown type name ‘atomic64_t’ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)                                     ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:189:34: error: unknown type name ‘atomic64_t’ static inline long atomic64_xchg(atomic64_t *v, long new)                                  ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:203:39: error: unknown type name ‘atomic64_t’ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)                                       ^/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/atomic64_64.h:227:45: error: unknown type name ‘atomic64_t’ static inline long atomic64_dec_if_positive(atomic64_t *v)                                             ^In file included from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/segment.h:148:0,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/ptrace.h:4,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/alternative.h:8,                 from /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/bitops.h:16,                 from include/linux/bitops.h:22,                 from include/linux/kernel.h:10,                 from include/linux/cache.h:4,                 from include/linux/time.h:4,                 from include/linux/stat.h:18,                 from include/linux/module.h:10,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/cache.h:12:31: error: ‘CONFIG_X86_INTERNODE_CACHE_SHIFT’ undeclared here (not in a function) #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT                               ^include/linux/cache.h:57:35: note: in expansion of macro ‘INTERNODE_CACHE_SHIFT’  __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))                                   ^include/linux/mmzone.h:99:3: note: in expansion of macro ‘____cacheline_internodealigned_in_smp’ } ____cacheline_internodealigned_in_smp;   ^In file included from include/linux/elf.h:4:0,                 from include/linux/module.h:14,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/elf.h: In function ‘elf_common_init’:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/elf.h:172:3: error: ‘struct thread_struct’ has no member named ‘fs’  t->fs = t->gs = 0;   ^In file included from include/linux/module.h:22:0,                 from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/module.h: At top level:/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/arch/x86/include/asm/module.h:57:2: error: #error unknown processor family #error unknown processor family  ^In file included from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:16:0:include/linux/module.h:305:27: error: field ‘arch’ has incomplete type  struct mod_arch_specific arch;                           ^/home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c: In function ‘request_io_irqs’:/home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:239:35: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type [-Wincompatible-pointer-types]     if (request_irq(KEY_GPIO_IRQ, key_irq_irq_handler,IRQF_DISABLED, "channel_drv irq", NULL) ) /* 申请中断 */                                   ^In file included from /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.c:26:0:include/linux/interrupt.h:129:1: note: expected ‘irq_handler_t {aka enum irqreturn (*)(int,  void *)}’ but argument is of type ‘irqreturn_t (*)(unsigned int,  void *) {aka enum irqreturn (*)(unsigned int,  void *)}’ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, ^scripts/Makefile.build:314: recipe for target '/home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.o' failedmake[2]: *** [/home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.o] Error 1Makefile:1229: recipe for target '_module_/home/sfe1012/GSRD/Qt/FpgaChannelDriver' failedmake[1]: *** [_module_/home/sfe1012/GSRD/Qt/FpgaChannelDriver] Error 2make[1]: Leaving directory '/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12'Makefile:8: recipe for target 'modules' failedmake: *** [modules] Error 2


解决办法:

将内核源代码中的根目录中的makefile

ARCH        ?= $(SUBARCH)
CROSS_COMPILE    ?= $(CONFIG_CROSS_COMPILE:"%"=%)
# Architecture as present in compile.h
UTS_MACHINE     := $(ARCH)
SRCARCH     := $(ARCH)


更改为
ARCH        = arm
CROSS_COMPILE    = arm-linux-gnueabihf-   (arm-gcc 目录)
# Architecture as present in compile.h
UTS_MACHINE     := $(ARCH)
SRCARCH     := $(ARCH)






原创粉丝点击