每隔几行一个print终于确定open就有问题,再加print发现是头文件定义地址时就有问题。反复查阅手册发现没错的情况下,顺着hardware.h一路找下去,发现是板子在初始化时 就已经将uart的物理地址做过了偏移。定义地址改为虚拟的偏移值后 段错问题才得以解决。
scripts/Makefile.build:234: target `drivers/char/Tao' doesn't match the target pattern
CC [M] drivers/char/Tao
.arm-none-linux-gnueabi-gcc: no input files
make[2]: *** [drivers/char/Tao] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2
//设备名不匹配:Kconig,Makefile,makemenuconfig什么的都要一致才行。
drivers/char/Tao.c: In function 'Tao_ioctl':
drivers/char/Tao.c:93: error: 'FILE' undeclared (first use in this function)
drivers/char/Tao.c:93: error: (Each undeclared identifier is reported only once
drivers/char/Tao.c:93: error: for each function it appears in.)
drivers/char/Tao.c:93: error: 'stream' undeclared (first use in this function)
drivers/char/Tao.c:94: warning: ISO C90 forbids mixed declarations and code
drivers/char/Tao.c:95: warning: assignment makes pointer from integer without a cast
drivers/char/Tao.c:100: error: implicit declaration of function 'open'
drivers/char/Tao.c:106: error: implicit declaration of function 'fwrite'
drivers/char/Tao.c:106: warning: incompatible implicit declaration of built-in function 'fwrite'
make[2]: *** [drivers/char/Tao.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2
//stdio.h在make modules时不能加载,把fwrite部分改到应用程序部分。这个查了一下 驱动层里确实不能加载stdio,类似稍高层的头文件也是不行的
uart_app.c:7:19: error: conio.h: No such file or directory
uart_app.c: In function 'main':
uart_app.c:18: warning: incompatible implicit declaration of built-in function 'exit'
uart_app.c:23: warning: integer constant is too large for 'long' type
uart_app.c:27: warning: incompatible implicit declaration of built-in function 'exit'
uart_app.c:35: warning: incompatible implicit declaration of built-in function 'exit'
uart_app.c:39: error: 'FAFF3100D0' undeclared (first use in this function)
uart_app.c:39: error: (Each undeclared identifier is reported only once
uart_app.c:39: error: for each function it appears in.)
uart_app.c:41: warning: incompatible implicit declaration of built-in function 'exit'
uart_app.c:61: warning: assignment makes pointer from integer without a cast
uart_app.c:87: error: 'stream' undeclared (first use in this function)
//控制字过长,把控制字数值改为ctrlword[]数组解决。;类似FAFF3100D0的控制字最后改为ctrlword[5]={0xFA,0xFF,0x31,0x00,0xD0};控制字的判断也从简单的=或!=,改为了数组的逐个比较
uart_app.c: In function 'main':
uart_app.c:31: warning: integer constant is too large for 'long' type
uart_app.c:31: warning: passing argument 2 of 'write' makes pointer from integer without a cast
/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/unistd.h:333: note: expected 'const void *' but argument is of type 'long long int'
uart_app.c:47: warning: integer constant is too large for 'long' type
uart_app.c:69: warning: assignment makes pointer from integer without a cast
//网上说带头文件就有警告#include 。- -
'const void *'和'long long int'数据类型不一样 改统一了就好了