Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1257156
  • 博文数量: 160
  • 博客积分: 4132
  • 博客等级: 中校
  • 技术积分: 2086
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-06 21:56
文章分类

全部博文(160)

文章存档

2012年(25)

2011年(120)

2010年(15)

分类: LINUX

2011-02-20 20:50:10

经过这几天艰苦奋斗,毕设终于从只有流程写到基本完成了~
现在仅剩唯一的问题就是从陀螺仪读入的十六进制信号用fwrite写入txt时是乱码,下午换用fprintf的所有格式也还是不行…先总结一部分之前的调试笔记吧

之前最要命的问题当属segmentation fault了,
每隔几行一个print终于确定open就有问题,再加print发现是头文件定义地址时就有问题。反复查阅手册发现没错的情况下,顺着hardware.h一路找下去,发现是板子在初始化时 就已经将uart的物理地址做过了偏移。定义地址改为虚拟的偏移值后 段错问题才得以解决。
最核心的报错:
  1.    internal error:Oops:805
我的错误和下边查到这个很像
oops消息
大部分错误都是因为对NULL指针取值或因为使用了其他不正确的指针值,这些错误通常会导致一个oops信息。
由于处理器使用的地址几乎都是虚拟地址,这些地址(除了内存管理子系统本身所使用的物理内存外)通过一个复杂的被称为页表的结构映射为物理地址,当引用一个非法指针时,分页机制无法将该地址映射为物理地址,此时处理器就会想操作系统发出一个信号,而这时处理器恰好处于超级用户模式,系统就会产生一个oops
oops显示出错时处理器的状态,比如cpu寄存器的内容以及其他看上去无法理解的信息。这些信息有printk打印出来
下面使用各使用NULL指针而导致oops的例子
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 805 [#1]
Modules linked in:
CPU: 0    Not tainted (2.6.22.6 #18)
PC is at s3c2410fb_probe+0x18/0x560
LR is at platform_drv_probe+0x20/0x24
pc : []    lr : []    psr: a0000013
sp : c042fe64 ip : c042fea0 fp : c042fe9c
r10: 00000000 r9 : c0025864 r8 : c03892ec
r7 : 00000000 r6 : c0353358 r5 : 00000000 r4 : c032c560
r3 : 00001234 r2 : 00000001 r1 : c047bd84 r0 : c032c558
Unable to handle kernel NULL pointer dereference at virtual address 00000000
可以看出使用了空指针。找出函数调用关系:PC is at s3c2410fb_probe+0x18/0x560
,表示出错指令为 s3c2410fb_probe函数中偏移为0X18的指令。pc : [] 表示出错指令的地址为c001abc4

剩下都是些比较易懂的报错信息,这些报错和警告之后的调制问题 留在下一篇总结吧,一会儿再去试试修改fwrite函数,差一点儿没弄出来比较着急 哈哈


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'数据类型不一样 改统一了就好了



阅读(2807) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~