7.11.6. 常见问题

7.11.6.1. 端口非tty设备

7.11.6.1.1. 现象

[aic@] # aic_uart -N /dev/ttyS1 /detv/ttySw2 1145200
[2022-01-26 16:23:43]  Test Mode: 0:Normal Test
[2022-01-26 16:23:43]  Send Device     : /dev/ttyS1
[2022-01-26 16:23:43]  Receive Device  : /dev/ttyS2
[2022-01-26 16:23:43]  m_Baudrate      : 115200
[2022-01-26 16:23:43]  standard input is not a terminal device for /dev/ttyS1
[2022-01-26 16:23:43]  tcgetattr: Bad file descriptor
[2022-01-26 16:23:43]  standard input is not a terminal device for /dev/ttyS2
[2022-01-26 16:23:43]  tcgetattr: Bad file descriptor

[aic@] # echo 111 > /dev/ttyS1
write error: Input/output error

7.11.6.1.2. 原因

新版IC系统修改了 UART Clk 的地址,dts 中未同步修改,导致设备虽然进行了初始化,但模块无数据读写

[aic@] # devmem 0x18711000 32
[2022-02-07 09:23:06]  0x00000000            //uart的所有寄存器读不到数据,clk未工作

7.11.6.2. 长包卡死

7.11.6.2.1. 现象

发送128字节以内的短包,模块可正常收发,发送超过128字节的长包,会卡死

7.11.6.2.2. 原因

M4 RX DMA 要求严格设置 DMA RX size,如果该 size 设置不对,则会有如下问题:

  • 如果 fifo 中有数据150,而设置 rx size 为120,则丢失30数据

  • 如果 fifo 中有数据150,而设置 rx size 为160, 则永远无法填充满,则永远收不回数据,卡死

目前默认的8250驱动中,设置的 rx size 为1000,但 fifo 的大小只有256,因此永远无法填充完成,故导致系统卡死。

7.11.6.3. 初始化乱码

7.11.6.3.1. 现象

reboot 测试中发现 Linux 初始化 UART 时输出乱码 0xFF,导致接收端 Python脚本 断开

7.11.6.3.2. 原因

8250驱动因为要兼容很多 IC,因此初始化时有一个自动 try 的机制:autoconfig,通过对硬件模块的测试来确认 IP 类型和特殊功能,此自动 try 工作会频繁操作寄存器,既可能造成不确定的影响(输出上述乱码),也会增加系统开销,而我们 UART 模块特性固定,可以预先进行配置,不进行 try。

autoconfig 的核心是设置了 port->type 为 PORT_16550A,我们直接设置 type 后即可不使用 autoconfig 流程。

关闭 autoconfig 的流程为:

aic8250_probe:
    p->type = PORT_16550A;
    p->flags = UPF_FIXED_TYPE;
uart_configure_port:
    if (!(port->flags & UPF_FIXED_TYPE)) {
        port->type = PORT_UNKNOWN;
        flags |= UART_CONFIG_TYPE;
    }
serial8250_config_port:
    if (flags & UART_CONFIG_TYPE)
        autoconfig(up);