TI中文支持网
TI专业的中文技术问题搜集分享网站

AM437x /dev/ttyS1卡死现象

资源情况:

CPU:AM437x

SDK:版本为 06.01.00.08

内核版本:4.19.94

在使用串口1的时候发现一个问题,一个简单的串口测试程序,程序中就是简单的打开串口配置波特率然后循环不停的读取串口1(/dev/ttyS1)的数据,执行这个程序一小段时间然后kill这个程序,再次执行此程序后又杀死,这样操作几此后,整个系统将卡死了,用strace来定位发现在open串口的时候出现卡死不动了

执行cat /dev/ttyS1 读取数据一小段时间,然后用ctrl+c杀死,这样循环操作几次后会出现同样的卡死现象,其他串口暂未测试。

卡死后的日志信息如下:

root@am437x-evm:/opt# strace ./uart_test 
execve("./uart_test", ["./uart_test"], 0xbef3aca0 /* 22 vars */) = 0
brk(NULL)= 0x22000
uname({sysname="Linux", nodename="am437x-evm", ...}) = 0
access("/etc/ld.so.preload", R_OK)= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/v7l/neon/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/v7l/neon/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/v7l/neon/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/v7l/neon", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/v7l/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/v7l/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/v7l/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/v7l", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/neon/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/neon/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/neon/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/neon", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/tls/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/tls", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/v7l/neon/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/v7l/neon/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/v7l/neon/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/v7l/neon", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/v7l/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/v7l/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/v7l/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/v7l", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/neon/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/neon/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/neon/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/neon", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/vfp/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/vfp", 0xbe8810e8) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib", {st_mode=S_IFDIR|0755, st_size=32768, ...}) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=29912, ...}) = 0
mmap2(NULL, 29912, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f51000
close(3)= 0
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\234x\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=16537400, ...}) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f4f000
mmap2(NULL, 1315620, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6de7000
mprotect(0xb6f14000, 61440, PROT_NONE)  = 0
mmap2(0xb6f23000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12c000) = 0xb6f23000
mmap2(0xb6f26000, 8996, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f26000
close(3)= 0
set_tls(0xb6f4fbc0)= 0
mprotect(0xb6f23000, 8192, PROT_READ)= 0
mprotect(0x20000, 4096, PROT_READ)= 0
mprotect(0xb6f59000, 4096, PROT_READ)= 0
munmap(0xb6f51000, 29912)= 0
openat(AT_FDCWD, "/dev/ttyS1", O_RDWR|O_NOCTTY|O_NONBLOCK
[  513.941557] rcu: INFO: rcu_preempt self-detected stall on CPU
[  513.947335] rcu:0-...!: (33265 ticks this GP) idle=8c6/1/0x40000004 softirq=46557/46557 fqs=0 
[  513.956152] rcu:(t=33615 jiffies g=21225 q=40)
[  513.960878] rcu: rcu_preempt kthread starved for 33615 jiffies! g21225 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0
[  513.971266] rcu: RCU grace-period kthread stack dump:
[  513.976334] rcu_preemptR  running task0102 0x00000000
[  513.983412] Backtrace: 
[  513.985874] [<c0942600>] (__schedule) from [<c0942dc4>] (schedule+0x58/0xc4)
[  513.992954]  r10:c0e4e1d3 r9:c0e16340 r8:c0e16320 r7:c0e03048 r6:cf875ee4 r5:c0e16340
[  514.000814]  r4:ffffe000
[  514.003358] [<c0942d6c>] (schedule) from [<c0946a54>] (schedule_timeout+0x180/0x288)
[  514.011132]  r5:c0e16340 r4:ffffd044
[  514.014724] [<c09468d4>] (schedule_timeout) from [<c0183980>] (rcu_gp_kthread+0x5d4/0xbcc)
[  514.023023]  r9:c0e03108 r8:00000001 r7:c0e16320 r6:cf874000 r5:c0e15c54 r4:00000001
[  514.030803] [<c01833ac>] (rcu_gp_kthread) from [<c014b774>] (kthread+0x158/0x160)
[  514.038314]  r7:cf874000
[  514.040858] [<c014b61c>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[  514.048109] Exception stack(0xcf875fb0 to 0xcf875ff8)
[  514.053179] 5fa0:00000000 00000000 00000000 00000000
[  514.061392] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  514.069604] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[  514.076246]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c014b61c
[  514.084106]  r4:cf840440
[  514.086646] Task dump for CPU 0:
[  514.089882] uart_testR  running task0781778 0x00000012
[  514.096960] Backtrace: 
[  514.099418] [<c010cb64>] (dump_backtrace) from [<c010ced4>] (show_stack+0x18/0x1c)
[  514.107019]  r7:c0e15c54 r6:0000030a r5:c0e03048 r4:c8019200
[  514.112703] [<c010cebc>] (show_stack) from [<c0156d08>] (sched_show_task.part.2+0xe8/0x104)
[  514.121091] [<c0156c20>] (sched_show_task.part.2) from [<c0156e18>] (dump_cpu_task+0x38/0x3c)
[  514.129649]  r6:c0e03108 r5:00000000 r4:c0e15c54
[  514.134287] [<c0156de0>] (dump_cpu_task) from [<c018545c>] (rcu_dump_cpu_stacks+0x90/0xd0)
[  514.142587] [<c01853cc>] (rcu_dump_cpu_stacks) from [<c0184b3c>] (rcu_check_callbacks+0x628/0x8ec)
[  514.151584]  r10:c0e16320 r9:c0e030fc r8:00000000 r7:c0e15c54 r6:c0e16074 r5:c0e160e0
[  514.159445]  r4:c0e15c54 r3:91ae3010
[  514.163036] [<c0184514>] (rcu_check_callbacks) from [<c018a938>] (update_process_times+0x3c/0x6c)
[  514.171946]  r10:20000193 r9:c019c3f4 r8:00000000 r7:00000077 r6:00000000 r5:c8019200
[  514.179806]  r4:ffffe000
[  514.182351] [<c018a8fc>] (update_process_times) from [<c019c1cc>] (tick_sched_handle+0x5c/0x60)
[  514.191085]  r7:00000077 r6:a93619ed r5:c8dd7b38 r4:c0e17fc0
[  514.196768] [<c019c170>] (tick_sched_handle) from [<c019c444>] (tick_sched_timer+0x50/0xac)
[  514.205155] [<c019c3f4>] (tick_sched_timer) from [<c018b520>] (__hrtimer_run_queues.constprop.3+0x190/0x228)
[  514.215024]  r7:ffffe000 r6:c0e17480 r5:c0e17fc0 r4:c0e174c0
[  514.220707] [<c018b390>] (__hrtimer_run_queues.constprop.3) from [<c018bce0>] (hrtimer_interrupt+0x120/0x30c)
[  514.230664]  r10:c0a43d00 r9:ffffffff r8:7fffffff r7:00000003 r6:20000193 r5:ffffe000
[  514.238524]  r4:c0e17480
[  514.241069] [<c018bbc0>] (hrtimer_interrupt) from [<c010ed44>] (twd_handler+0x38/0x40)
[  514.249020]  r10:c0a43d00 r9:c8dd6000 r8:cf808000 r7:00000012 r6:cf8325c0 r5:c0e034d4
[  514.256880]  r4:00000001
[  514.259425] [<c010ed0c>] (twd_handler) from [<c01770f8>] (handle_percpu_devid_irq+0x6c/0x104)
[  514.267982]  r5:c0e034d4 r4:cf807300
[  514.271576] [<c017708c>] (handle_percpu_devid_irq) from [<c0171bac>] (generic_handle_irq+0x2c/0x3c)
[  514.280658]  r7:c8dd7c48 r6:00000001 r5:00000000 r4:c0e4c9f0
[  514.286343] [<c0171b80>] (generic_handle_irq) from [<c017238c>] (__handle_domain_irq+0x5c/0xb0)
[  514.295082] [<c0172330>] (__handle_domain_irq) from [<c0457c70>] (gic_handle_irq+0x44/0x70)
[  514.303470]  r9:c8dd6000 r8:fa241100 r7:c8dd7b38 r6:fa240100 r5:fa24010c r4:c0e034d4
[  514.311248] [<c0457c2c>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0xa8)
[  514.318759] Exception stack(0xc8dd7b38 to 0xc8dd7b80)
[  514.323831] 7b20:00404000 00404000
[  514.332044] 7b40: c0e4df80 00000000 00000202 00000000 00000001 00000000 cf808000 c8dd6000
[  514.340258] 7b60: c0a43d00 c8dd7be4 c8dd7be8 c8dd7b88 c0130e20 c0102220 60000113 ffffffff
[  514.348471]  r9:c8dd6000 r8:cf808000 r7:c8dd7b6c r6:ffffffff r5:60000113 r4:c0102220
[  514.356250] [<c0102180>] (__do_softirq) from [<c0130e20>] (irq_exit+0x108/0x114)
[  514.363678]  r10:c0a43d00 r9:c8dd6000 r8:cf808000 r7:00000000 r6:00000001 r5:00000000
[  514.371538]  r4:c0e4c9f0
[  514.374083] [<c0130d18>] (irq_exit) from [<c0172390>] (__handle_domain_irq+0x60/0xb0)
[  514.381949] [<c0172330>] (__handle_domain_irq) from [<c0457c70>] (gic_handle_irq+0x44/0x70)
[  514.390335]  r9:c8dd6000 r8:fa241100 r7:c8dd7c48 r6:fa240100 r5:fa24010c r4:c0e034d4
[  514.398112] [<c0457c2c>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0xa8)
[  514.405624] Exception stack(0xc8dd7c48 to 0xc8dd7c90)
[  514.410696] 7c40:c0e8485c 00000000 00000730 00000000 c0e8485c cf00ea40
[  514.418908] 7c60: 00000000 00000000 ca47f000 c8de6600 c0a43d00 c8dd7cbc c8dd7c68 c8dd7c98
[  514.427119] 7c80: c01155a0 c0521e08 60000013 ffffffff
[  514.432191]  r9:c8dd6000 r8:ca47f000 r7:c8dd7c7c r6:ffffffff r5:60000013 r4:c0521e08
[  514.439973] [<c0521cb0>] (omap_8250_startup) from [<c051be1c>] (serial8250_startup+0x1c/0x28)
[  514.448533]  r6:c8de6600 r5:c0e8485c r4:cf8530d0
[  514.453172] [<c051be00>] (serial8250_startup) from [<c0516264>] (uart_startup.part.4+0x150/0x2cc)
[  514.462085] [<c0516114>] (uart_startup.part.4) from [<c0516438>] (uart_port_activate+0x58/0x84)
[  514.470820]  r9:c8de6600 r8:c8dd6000 r7:cf853150 r6:c8ede840 r5:c8de6600 r4:cf8530d0
[  514.478598] [<c05163e0>] (uart_port_activate) from [<c04fd038>] (tty_port_open+0xbc/0x114)
[  514.486893]  r5:c8de6600 r4:cf8530d0
[  514.490484] [<c04fcf7c>] (tty_port_open) from [<c0514b74>] (uart_open+0x20/0x28)
[  514.497912]  r9:c8de6600 r8:c8dd6000 r7:c0c5efd4 r6:00400041 r5:c8de6600 r4:c8ede840
[  514.505692] [<c0514b54>] (uart_open) from [<c04f5a38>] (tty_open+0xf0/0x464)
[  514.512774] [<c04f5948>] (tty_open) from [<c023fe10>] (chrdev_open+0xf8/0x200)
[  514.520028]  r10:cf4033b8 r9:00000000 r8:c0a43d80 r7:c8ede840 r6:cf00d7d0 r5:c0e03048
[  514.527888]  r4:cf0036c0
[  514.530435] [<c023fd18>] (chrdev_open) from [<c0237108>] (do_dentry_open+0x118/0x3b4)
[  514.538299]  r9:c023fd18 r8:c8ede848 r7:00000902 r6:00000000 r5:cf00d7d0 r4:c8ede840
[  514.546078] [<c0236ff0>] (do_dentry_open) from [<c0238634>] (vfs_open+0x34/0x38)
[  514.553505]  r9:c8ede840 r8:c8dd7f50 r7:00000902 r6:00000000 r5:00000000 r4:c8dd7e90
[  514.561285] [<c0238600>] (vfs_open) from [<c024ac64>] (path_openat+0x2a8/0x1138)
[  514.568713] [<c024a9bc>] (path_openat) from [<c024cb78>] (do_filp_open+0x7c/0xe4)
[  514.576228]  r10:00000142 r9:c8dd6000 r8:00000001 r7:c8dd7f50 r6:c8dd7e90 r5:c0e03048
[  514.584088]  r4:c0e03048
[  514.586633] [<c024cafc>] (do_filp_open) from [<c0238930>] (do_sys_open+0x170/0x1f4)
[  514.594322]  r8:fffff000 r7:cefda000 r6:ffffff9c r5:c0e03048 r4:00000003
[  514.601053] [<c02387c0>] (do_sys_open) from [<c02389ec>] (sys_openat+0x14/0x18)
[  514.608394]  r10:00000142 r9:c8dd6000 r8:c0101204 r7:00000142 r6:000105ac r5:00000000
[  514.616254]  r4:00010934
[  514.618799] [<c02389d8>] (sys_openat) from [<c01011e4>] (__sys_trace_return+0x0/0x1c)
[  514.626659] Exception stack(0xc8dd7fa8 to 0xc8dd7ff0)
[  514.631730] 7fa0:00010934 00000000 ffffff9c 000109a8 00000902 00000000
[  514.639942] 7fc0: 00010934 00000000 000105ac 00000142 00000000 00000000 b6f69000 be9edb44
[  514.648152] 7fe0: b6f34000 be9ed2d0 000106c4 b6eb5c84

user6259504:

补充一下,串口需要有数据才会出现这样的问题,如果没有数据,也是不出现卡死现象的,因我其他串口因暂时没有接数据,测试暂时没发现此现象。

,

Nancy Wang:

感谢您对TI产品的关注!为更加有效地解决您的问题,我需要询问更了解这款芯片的TI资深工程师,再为您解答,一旦得到回复会立即回复给您。

,

Nancy Wang:

请问是自制板吗?是否在EVM板上测试过?

,

user6259504:

是自制板卡,官方的EVM开发板串口没有引出了所以没有测试。

目前自己的板卡测试,暂时就接出来了ttyS1和ttyS5,测试就ttyS1会有

串口上需要一直有数据才会出现此现象,如果没有数据的话,也不会出现问题。

串口配置信息为:波特率为230400,数据位8位,停止位1位。

,

Nancy Wang:

如果不kill程序,程序运行一段时间,关闭uart并且退出,会出现类似的情况吗?
是否测试过Processor SDK v6.3.0.106?

,

user6259504:

因为SDK v6.3.0.106在显示方面存在bug,所以我们的项目使用的是06.01.00.08版本,SDK v6.3.0.106我没有测试。

只是使用的SDK v6.01.00.08里面的文件系统而已,uboot和kernel都是SDK v6.3.0.106里面的

刚经过正常close(fd)关闭串口退出程序,再次执行此程序这样多次循环也会出现同样的问题。

这个问题会和文件系统有关系么?

,

user6259504:

我尝试nfs挂载Processor SDK v6.3.0.106的文件系统,发现此问题同样存在。
现在程序的不同点就是内核了,内核也是基于Processor SDK v6.3.0.106中的内核来的,添加了几个自己编写的驱动,设备树是基于am437x-gp-evm.dts修改来的(配置了串口1及相关IO),官方的串口驱动我没有修改过,其他的几乎和Processor SDK v6.3.0.106中的是一样的

,

Nancy Wang:

AM437x GP EVM中 UART1_TX 和 UART1_RX连接到了J37,可以修改一下设备树中的pinmux,将DCAN1配置为UART1测试一下。

另外自己编写的驱动具体是什么驱动?

,

user6259504:

自己写的驱动就是:一个spi外设驱动,一个serio驱动,一个I2C外设驱动。修改了panel-simple.c(在里面增加了个我们自己显示屏的结构体),其他使用的驱动全是是内核中的驱动源码没有修改过。

然后我把自己的这增加的驱动全部去除掉(内核不编译),现象同样存在。

我现在尝试按你说的把GP EVM中串口1引出了试试。

,

user6259504:

经过测试,发现AM437x GP EVM存在同样的问题。

测试经过:

1、官方AM437x GP EVM开发板,去掉电阻R177和R178,从MCU端飞线将串口1引出来,再飞一根地线接usb转串口工具连接到电脑上。修改设备树文件,将can1配置删除,将IO口设置为串口功能,使能串口1.

2、电脑上打开串口调试助手,设置波特率为230400,数据位8位停止位1位,定时10ms发送一串数据。

3、开发板上运行我的串口测试程序uart_test,uart_test程序正常退出后再次启动uart_test程序,如此循环。

4、开发板是能正常接收数据的,当多次(5~6次)执行uart_test程序后,程序卡死,打印出的信息如我发帖所示。

5、现在我的程序是读取串口数据后正常close串口再退出的。

uart_test程序如下:

#include<stdio.h>
#include<stdlib.h>#include<unistd.h>#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>#include<termios.h>
#include<errno.h>intmain()
{int fd;int i;int len;int n = 0;char read_buf[256];char write_buf[256];struct termios opt;fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY |O_NONBLOCK);//默认为阻塞读方式if(fd == -1){perror("open serial 0\n");exit(0);}tcgetattr(fd, &opt);cfsetispeed(&opt, B230400);cfsetospeed(&opt, B230400);opt.c_cflag &= ~CSIZE;opt.c_cflag |= CS8;opt.c_cflag &= ~CSTOPB;opt.c_cflag &= ~PARENB;opt.c_cflag |= PARENB;opt.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);tcflush(fd, TCIOFLUSH);if(tcsetattr(fd, TCSANOW, &opt) != 0 ){perror("tcsetattr error");return -1;}n = 0;len = 0;printf("configure complete\n");printf("start send and receive data\n");while(1){memset(read_buf,0, sizeof(read_buf));len= read(fd, read_buf, sizeof(read_buf));if(len> 0){printf("over,len=%d\n",len);n++;if(n > 50)break;}else{printf("no data\n");sleep(2);}}printf("return\n",n);close(fd);return 0;
}

,

user6259504:

请问此问题有解决方法了么?

赞(0)
未经允许不得转载:TI中文支持网 » AM437x /dev/ttyS1卡死现象
分享到: 更多 (0)