您的位置:首页 > 其它

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

2017-08-07 11:15 465 查看
makefile:

ifeq ($(KERNELRELEASE),)

KERNELDIR ?= /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/

PWD := $(shell pwd)

modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules modules_install clean

else
obj-m := channel_drv.o
endif


错误如下:

make -C /home/sfe1012/GSRD/linux-socfpga-socfpga-3.12/ M=/home/sfe1012/GSRD/Qt/FpgaChannelDriver modules
make[1]: Entering directory '/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12'
CC [M] /home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.o
In 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' failed
make[2]: *** [/home/sfe1012/GSRD/Qt/FpgaChannelDriver/channel_drv.o] Error 1
Makefile:1229: recipe for target '_module_/home/sfe1012/GSRD/Qt/FpgaChannelDriver' failed
make[1]: *** [_module_/home/sfe1012/GSRD/Qt/FpgaChannelDriver] Error 2
make[1]: Leaving directory '/home/sfe1012/GSRD/linux-socfpga-socfpga-3.12'
Makefile:8: recipe for target 'modules' failed
make: *** [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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: