Cannot read serial port when input buffer contains exactly 9 bytes

  • It is not possible to read data from serial port when input buffer contains exactly 9 bytes. The following code demonstrates the issue:

    Python
    1. from serial import Serial
    2. with Serial('/dev/ttymxc2', baudrate=115200, timeout=1) as serial:
    3. request = b'a' * 9
    4. serial.write(request)
    5. response = serial.read(9)
    6. assert request == response

    The number 9 is related to the length of the rx_fifo_trig in drivers/tty/serial/imx.c. For kernel 5.4.70, it was possible to set this value to 1 in the device tree, but for kernel 5.15.148, this didn't work for me anymore. The new work-around was to disable dma using the "no-dma" setting in device tree. Anyway, this seems like a bug in the serial port implementation which should be fixed.