交叉编译2.6驱动无法通过
各位大哥,小弟正在从pc上编译驱动到arm板,但是在交叉编译这一步怎么也过不去,请各位大侠帮忙指点一下!
编译器arm-linux-gcc-3.4.1,试验代码hello.c照抄ldd3的代码:
#include <linux/init.h>
#include <linux/module.h>
//MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk("Hello, worldn");
return 0;
}
static void hello_exit(void)
{
printk("Goodbye, cruel worldn");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
#################################
编译方法一:利用Makefile,内容如下:
armgcc1 = /usr/local/arm/3.4.1/bin/arm-linux-gcc
INCLUDELDIR = /usr/local/arm/3.4.1/arm-linux/sys-include
NOWFLAG = -I$(INCLUDELDIR)
hello.o: hello.c
default:
$(armgcc1) -mcpu=arm920 $(NOWFLAG) --host=arm-linux -c hello.c
显示cc -c -o hello.o hello.c,生成的hello。o,用file ./hello.o查看是./hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
在2410上insmod hello。o提示如下:hello.o: ELF file hello.o not for this architecture
#############################
编译方法2:直接ARM-GCC
#/usr/local/arm/3.4.1/bin/arm-linux-gcc -c hello.c
却得到一大堆include file的错误,错误完整内容如下:
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:12,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/jiffies.h:16: error: parse error before "jiffies_64"
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/jiffies.h:20: error: parse error before "get_jiffies_64"
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:18,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:18: error: parse error before "wait_queue_head_t"
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h: In function `sema_init':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:46: error: dereferencing pointer to incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:47: error: dereferencing pointer to incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:48: error: dereferencing pointer to incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h: In function `sema_count':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:66: error: dereferencing pointer to incomplete type
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/signal.h:4,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:25,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/list.h:682:2: warning: #warning "don't include kernel headers in userspace"In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/siginfo.h:4,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/signal.h:7,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:25,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/siginfo.h: At top level:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/siginfo.h:58: error: size of array `_pad' is too large
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:29,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/completion.h:15: error: parse error before "wait_queue_head_t"
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/completion.h: In function `init_completion':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/completion.h:26: error: dereferencing pointer to incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/completion.h:27: error: dereferencing pointer to incomplete type
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:30,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/pid.h: At top level:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/pid.h:18: error: field `task_list' has incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/pid.h:19: error: field `hash_chain' has incomplete type
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/pid.h:24: error: field `pid_chain' has incomplete type
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:31,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/percpu.h: In function `__alloc_percpu':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/percpu.h:45: error: `GFP_KERNEL' undeclared (first use in this function)
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/percpu.h:45: error: (Each undeclared identifier is reported only once
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/percpu.h:45: error: for each function it appears in.)
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:102,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/timer.h: At top level:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/timer.h:12: error: field `entry' has incomplete type
In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/local.h:1,
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:21,
from hello.c:6:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h: In function `local_inc':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:65: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:65: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h: In function `local_dec':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:72: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:72: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h: In function `local_add':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:79: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:79: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h: In function `local_sub':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:86: error: invalid type argument of `->'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/local.h:86: error: invalid type argument of `->'
#####################################
小弟我分析了一下,可能是因为include module。h,因为我又编译了更为简单的hello。c
#include <stdio.h>
int main() { printf("Hello, world!n"); return 0; }
这一次顺利通过,而且可以在arm上运行
###############################
各位大侠,请帮忙分析一下,或者提供你们在编写drivers for 2.6所使用的交叉编译方法,多谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
lz最好先了解一下用户态编程和核心态编程的区别。
多谢,回头马上调试,
致谢!!!!
2.6的内核,那你的Makefile有错,见ldd3
试下这个Makefile
复制代码
用这个命令make
复制代码
没有环境测试,不知是否正确
!!!
无人作答,独自垂泪!
upupup
pc上环境FC5,kernel2.6.15.4