This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM4378: AM437x /dev/ttyS1 get stuck

Part Number: AM4378
Other Parts Discussed in Thread: ISO1050

Hi,

CPU:AM437x

SDK:06.01.00.08

kernel:4.19.94

Customer tests a simple uart1 program. The function of this program is reading data from UART1. After executing the program for a short time and then kill it. After repeating this procedure several times, the whole system will be stuck and he uses strace to locate and finds it stuck when open uart.

Below is the log:

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_preempt     R  running task        0    10      2 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_test       R  running task        0   781    778 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



  • Hi Nancy,

    Is this test done on TI EVM? If not, does it happen on TI EVM too?

  • Hi,

    It's custom board. He didn't test on EVM board, because there is no uart lead out on this EVM.

    UART configuration:

    Baud rate:230400

    Data bits: 8

    stop bits:1

  • Nancy,

    Nancy Wang said:
    After executing the program for a short time and then kill it.

    Instead of kill the program, if the program runs for a short time then closes the UART port and exits, does the issue still happens?

  • Also does the issue happen on Processor SDK v6.3.0.106 too?

  • Bin Liu said:

    Nancy,

    Nancy Wang
    After executing the program for a short time and then kill it.

    Instead of kill the program, if the program runs for a short time then closes the UART port and exits, does the issue still happens?

    Yes. And the issue still happen in Processor SDK v6.3.0.106

    The difference is the kernel. The kernel is also based on the kernel in the processor SDK v6.3.0.106. Customer has add some customize drivers, the uart1 configuration is based on am437x-gp-evm.dts.

  • Nancy,

    Nancy Wang said:
    Yes. And the issue still happen in Processor SDK v6.3.0.106

    Does it happen only when manually "kill' the program or it also happens when let the program close the UART and exit?

    Nancy Wang said:
    Customer has add some customize drivers, the uart1 configuration is based on am437x-gp-evm.dts.

    Please provide more details, what are the customized drivers?

    BTY, the AM437x GP EVM has UART1_TX and UART1_RX singals routed to the DB9 connector J37. I think you can test it on the EVM. You would have to modify the pinmux of these two signals, which are set for DCAN1 in device tree.

  • Yes ,it also happens when let the program close the UART and exit.

  • Okay. Thanks for the update.

    Can you please ask the customer to test on the AM437x GP EVM using the J37 DB9 connector?

  • Hi,

    The customer has test on AM437x GP EVM.

    The EVM can receive data normally. After executing the uart_test program several times (5~6 times), the issue still happens. And It is confirmed that it has nothing to do with the customized drivers.

    Below is uart_test code.

    #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>
    int   
    main()
    {
        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;
    }
  • Nancy,

    Thanks for providing the test code, I will have a setup to run the test.

    What is connected to the AM437x UART1 to send data? How the data are send?

  • Hi,

    Thanks!

    Tera term or putty.

  • Sorry Nancy, I just noticed that there is CAN transceiver (ISO1050) is in between AM437x UART1 and DB9 connector J37 on AM437x GP EVM, so I don't think J37 connector can be directly used to test UART1. Can you please explain how the customer tested on the AM437x GP EVM? Have they modified the EVM to bring out UART1 TX/RX signals?

  • Hi,

    He removed R177 and R178, and connected UART1 with jump wire.

  • Nancy,

    Thanks for the update. I am requesting my board to have the similar modification so that I can run the test. The process for the modification will be slow due to pandemic. I will update once I made progress.

  • Hi:

    I am the author of this question.

    The computer connects to the AM437x GP EVM through USB to serial port tool, and sends data to the AM437x GP EVM through serial port assistant.

    Is there any solution to this problem?

  • Hi,

    Sorry for my late response. I don't have access to my AM437x GP EVM in the next couple days. I will provide an update later this week.

  • Hi,

    Sorry for the delay. I finally got a chance to test your use case on my modified AM437x GP EVM. I initially was able to reproduce the issue with a Linux PC sending data to AM437x UART1. Then I realized the termios settings between the AM437x UART1 and the PC uart port are different, for example, the parity.

    After I changed to termios settings on the Linux PC to match the EVM settings changed by your test program, and used command 'stty -F <port> -a' on both the EVM and PC to ensure the termios are the same, the issue is resolved.

    Please check the termios setttings in your setup.

  • Hi:

    I set up the same configuration on both sides and checked, but again, there will be a problem

  • I connected to EVM using the computer of Win7 system. The configuration of data bit, check bit and stop bit is the same.The data is sent and received normally and correctly, the test still has this problem.

  • Hi,

    The tty termios settings have more attributes than just parity or stop bits. Please ensure all of them are the same on both sides of the UART connection. I am not sure how to check the settings on Windows system, but on Linux, you can use command 'stty -F /dev/ttyS1 -a' to check the settings for UART1.

    root@am437x-evm:~# stty -F /dev/ttyS1 -a
    speed 230400 baud;stty: /dev/ttyS1
     line = 0;
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>;
    start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
    parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
    -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel
    -iutf8
    opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
    -isig -icanon iexten -echo -echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho
    -extproc
    

    You can also run the tool serialstats from https://github.com/nsekhar/serialcheck on the AM437x board to check if there is any line error on its UART1 port, when the lockup happens.

  • Hi,Thank you for answering!

    I did as you asked,Linux is used on both sides and the same serial configuration is set up on both sides(Confirm the configuration information for both sides using stty -F /dev/ttyS1 -a),The problem is still there.But I've noticed some patterns.

    the code run on board:

    #include     <stdio.h> 
    #include     <stdlib.h>  
    #include     <unistd.h>   
    #include     <string.h>   
    #include     <sys/types.h> 
    #include     <sys/stat.h> 
    #include     <fcntl.h>  
    #include     <termios.h> 
    #include     <errno.h> 
        
    int main() 
    { 
        int fd; 
        int fd1; 
        int i,j; 
        int len; 
        int n = 0;       
        char read_buf[1024]; 
        char write_buf[1024]; 
        struct termios opt;  
         
        fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY|O_NONBLOCK );    //默认为阻塞读方>式 
    
        tcgetattr(fd, &opt);  
     
        printf("ttyS1\n"); 
        printf("c_iflag=%x\n", opt.c_iflag); 
        printf("c_oflag=%x\n", opt.c_oflag); 
        printf("c_cflag=%x\n", opt.c_cflag); 
        printf("c_lflag=%x\n", opt.c_lflag); 
        printf("c_line=%x\n", opt.c_line); 
     
     
        cfsetispeed(&opt, B230400); 
        cfsetospeed(&opt, B230400); 
         
        if(tcsetattr(fd, TCSANOW, &opt) != 0 ) 
        { 
           perror("tcsetattr error"); 
           return -1; 
        } 
      
     #if 0    
        opt.c_cflag &= ~CSIZE;    
        opt.c_cflag |= CS8;    
        opt.c_cflag &= ~CSTOPB;  
        opt.c_cflag &= ~PARENB;     
        opt.c_cflag |= (CLOCAL | CREAD);   
        opt.c_oflag &= ~OPOST;      
        opt.c_oflag &= ~(ONLCR | OCRNL);    //添加的        
        opt.c_iflag &= ~(ICRNL | INLCR);      
        opt.c_iflag &= ~(IXON | IXOFF | IXANY);    //添加的           
        opt.c_cc[VTIME] = 0;      
        opt.c_cc[VMIN] = 0;   
             
        opt.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);   
    #else 
            opt.c_iflag=0; 
            opt.c_iflag=0; 
            opt.c_oflag=0; 
            opt.c_cflag=0x1cb3; 
            opt.c_lflag=0x8a20; 
            opt.c_line=0 ; 
    #endif 
     
        tcflush(fd, TCIOFLUSH);        
        printf("configure complete\n");           
        if(tcsetattr(fd, TCSANOW, &opt) != 0)      
        {          
            perror("serial error");          
            return -1;      
        }      
        printf("start send and receive data\n");       
        j = 0;   
        while(1)      
        {              
            n = 0;          
            len = 0;          
            memset(read_buf, 0,sizeof(read_buf));    //类似于memset          
            memset(write_buf,0, sizeof(write_buf));            
            if( (n = read(fd, read_buf, sizeof(read_buf))) > 0 )         
            {              
                for(i = len; i < (len + n); i++)              
                {  
                    write_buf[i] = read_buf[i - len]; 
                }  
                len += n;  
     
                write_buf[len] = '\0'; 
                write_buf[len] = '\0'; 
                printf("\nstr=%s \n", write_buf);        
                sleep(1); 
            } 
     
            if(n > 0) 
            { 
                j++; 
                if(j > 10) 
                { 
                    close(fd); 
                    return 0; 
                } 
            } 
     
        }  
     
        return 0; 
    }
    
    

    the code run on Ubuntu:

    #include     <stdio.h>
    #include     <stdlib.h>  
    #include     <string.h> 
    #include     <unistd.h>   
    #include     <sys/types.h> 
    #include     <sys/stat.h> 
    #include     <fcntl.h>  
    #include     <termios.h> 
    #include     <errno.h> 
     
    #define BUF_SIZE 512 
        
    int main() 
    { 
        int fd1,fd2; 
        int i; 
        int len; 
        int n = 0;       
        char read_buf[BUF_SIZE]; 
        char write_buf[BUF_SIZE]; 
        struct termios opt;  
        fd1 = open("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK );//| O_NOCTTY);    //默认为阻塞读方式 
        if(fd1 < 0) 
        { 
            perror("open serial 0\n"); 
            exit(0); 
        } 
     
        tcgetattr(fd1, &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 |= (CLOCAL | CREAD);   
        opt.c_oflag &= ~OPOST;      
        opt.c_oflag &= ~(ONLCR | OCRNL);    //添加的        
        opt.c_iflag &= ~(ICRNL | INLCR);      
        opt.c_iflag &= ~(IXON | IXOFF | IXANY);    //添加的    
        opt.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 
     
        printf("c_iflag=%x\n", opt.c_iflag); 
        printf("c_oflag=%x\n", opt.c_oflag); 
        printf("c_cflag=%x\n", opt.c_cflag); 
        printf("c_lflag=%x\n", opt.c_lflag); 
        printf("c_line=%x\n", opt.c_line); 
        tcflush(fd1, TCIOFLUSH); 
        if(tcsetattr(fd1, TCSANOW, &opt) != 0)      
        {          
            perror("serial error");          
            return -1;      
        } 
     
        printf("start\n"); 
     
        for(i=0;i<sizeof(write_buf)-1;i++) 
        { 
            write_buf[i] = 65; 
        } 
        write_buf[BUF_SIZE-1]=0; 
        while(1)      
        {                 
            memset(read_buf,0, sizeof(read_buf));    //类似于memset  
            len = write(fd1,write_buf,sizeof(write_buf)); 
            if(len != sizeof(write_buf) || len < 0) 
            { 
                printf("write date error\n"); 
    		}
            //sleep(1); 
            usleep(500000);}  
        printf("return\n"); 
        close(fd1); 
     
        return 0; 
    } 
    
    When you sleep time long enough(Such as sleep(1)), it's almost never a problem,but When sleep time is short(such as use usleep(500000),Make sure the write operation works); Problems are more likely to arise.

  • Hi,Thank you for answering! I did as you asked, using Linux on both sides to ensure the same configuration on both sides, but the problem still exists. But I did post a few rules, and when the PC sends a large amount of data frequently, the problem is easier to repeat.When the PC sends a small amount of data and infrequent, this problem will not occur.

  • Hi,

    The program you used on the Ubuntu PC sending UART data in an ifinite loop. Do you stop it when re-run the program on AM437x? or the PC was constantly sending data while re-run the program on AM437x?

    Did you run the serialstats tool I mentioned in my previous response and does it report any line error on AM437x?

  • Hi,

    Yes,The PC has been sending data without stopping,the PC was constantly sending data while re-run the program on AM437x.

    you ask to  check if there is any line error on its UART1 port when the lockup happens.but when the lockup happens,The system is stuck and can't do anything except reboot.

    When the system on the board is normal, the board runs serialstats tool, the PC sends data all the time, and serialstats tool shows no error only overrun.The serial port may not be able to handle the resulting deadlock.

    I'm sure there will be problems with both sides using the same serial port configuration, so you can test and repeat the problem several times.