danielappiagyei-bc opened a new issue, #10912: URL: https://github.com/apache/nuttx/issues/10912
## Bug description When using the LPUART serial driver with DMA for RX, I am seeing several dropped, missing, or otherwise incorrect bytes in the rxfifo (`g_lpuartXfifo`) the DMA places bytes in. ## Partial solution The major problem looks to be the `imxrt_dma_nextrx()` function [here](https://github.com/apache/nuttx/blob/master/arch/arm/src/imxrt/imxrt_serial.c#L1373 ) which can return one index past the end of the buffer when `dmaresidual` is 0 (all bytes in the dma transfer have been sent). The return value of this function is used without verifying that it's a valid index in the buffer. Correcting this bug causes missed bytes to occur less often (from several times a minute to only once or twice every few minutes) but does not fix the problem completely. The only permanent fix I found is placing the dma's [rxfifo](https://github.com/apache/nuttx/blob/master/arch/arm/src/imxrt/imxrt_serial.c#L711) inside the IMXRT's tightly coupled memory (TCM) region via `__attribute__((section("<tcm region>")))`, which is non-cacheable and super fast compared to SRAM. No incorrect bytes occur when I do this. This leads me to think there might be a caching issue. Aside from that, I tried disabling write through cache (`CONFIG_ARMV7M_DCACHE_WRITETHROUGH=n`) since [the chip's errata](https://www.nxp.com/docs/en/errata/IMXRT1064CE_A.pdf) mentions "_Cortex-M7: Write-Through stores and loads may return incorrect data_" but that did not solve the issue. ## Relevant Info I setup the IMXRT to receive the same ~36 byte message over UART from another processor. The first few bytes of the message are a header containing sync bytes, a length, and a CRC32 precalculated by the other processor. I log anytime there's a mismatch in expected data. When disabling DMA and using interrupts for each character received, there are no incorrect bytes. When using DMA, there are. I've confirmed bytes aren't being dropped by framing, parity, or noise errors. I've also confirmed that the upper layer of the serial driver isn't causing this. Other info: - sending the message every 10ms - 480600 baud rate -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org