AM2612: UART_procLineStatusErr() moves readBuf before original rx buffer when line status error

Part Number: AM2612

We are using the UART LLD driver and have encountered an exception during UART_lld_read().

While debugging, we found that the exception is triggered inside UART_procLineStatusErr().

The following code restores the receive buffer pointer:

/* Reset the read buffer and read count so we can pass it back */
hUart->readBuf = hUart->readBuf - hUart->readCount;

When a line-status error (FE/PE/BI/OE) occurs, UART_procLineStatusErr() empties the RX FIFO and then adjusts readBuf using readCount.

However, in our environment, this operation causes hUart->readBuf to point to an address lower than the original rxBuf passed to UART_lld_read(). After that, the driver accesses an invalid memory region and an exception occurs.

Questions:

  1. Is this a known issue in the UART LLD driver?
  2. Under what conditions can readBuf become inconsistent with readCount?
  3. Is there an official workaround or patch available?
  4. Is it not necessary to clear `readCount` after executing the code below?
    hUart->readBuf = hUart->readBuf - hUart->readCount;
    

Environment:

  • Device: AM261x
  • MCU+ SDK: 26.01.00.08
  • Driver file: uart_v0_lld.c
  • API: UART_lld_read()

Any guidance or recommended fix would be appreciated.

Best Regards

  • Hi Ichikawa-san,
    Thank you for the detailed report and for the thorough debugging you have performed. Identifying the specific pointer adjustment within UART_procLineStatusErr() as the cause of the memory access exception is very helpful.
    Regarding your specific questions:
    1. Is this a known issue in the UART LLD driver? I have checked our current documentation and available records for the AM26x MCU+ SDK, and I have not found a specific known issue or official patch logged for this exact behavior in uart_v0_lld.c.
    2. Under what conditions can readBuf become inconsistent with readCount? While I cannot confirm the exact internal state without further investigation, inconsistency typically occurs if the relationship between the pointer and the offset is not handled atomically or if an interrupt occurs between the FIFO clearing and the pointer adjustment. If readBuf is adjusted backward but readCount is not reset to zero, the driver's internal tracking of how much data remains to be processed will be incorrect, likely leading to the invalid memory access you are seeing.
    3. Is there an official workaround or patch available?
    If possible, please provide a small code snippet showing the values of hUart->readBuf and hUart->readCount immediately before the line-status error occurs.
    4. Is it not necessary to clear readCount after executing the code below?
    hUart->readBuf = hUart->readBuf - hUart->readCount;
    In standard driver implementations, if you are resetting the readBuf pointer back to the start of the original buffer, you generally must also reset readCount to zero. If the pointer is moved but the count remains unchanged, the driver will still believe it has "read" that many bytes, which leads to the inconsistent state and subsequent exceptions you are observing.
    Best Regards,
    Zackary Fleenor