This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 6b0f85b768fb154136d2ffed9fb64f14aa7f1f1f
Author: Jukka Laitinen <[email protected]>
AuthorDate: Fri Sep 11 10:29:11 2026 +0300

    arch/arm/imxrt: LPUART DMA fixes
    
    - Only submit and account for a wrapped second TX segment when 
scatter/gather descriptors
      are available. Without in-memory TCDs, submitting the second segment 
overwrites the
      active hardware descriptor and incorrectly advances the serial buffer 
past unsent data.
    - Invalidate DMA RX buffer initially
    
    Signed-off-by: Jukka Laitinen <[email protected]>
---
 arch/arm/src/imxrt/imxrt_serial.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/imxrt/imxrt_serial.c 
b/arch/arm/src/imxrt/imxrt_serial.c
index 37b4543086c..2f4a0872c3f 100644
--- a/arch/arm/src/imxrt/imxrt_serial.c
+++ b/arch/arm/src/imxrt/imxrt_serial.c
@@ -2465,7 +2465,13 @@ static int imxrt_dma_setup(struct uart_dev_s *dev)
        */
 
       priv->rxdmanext = 0;
+
 #ifdef CONFIG_ARMV7M_DCACHE
+
+      /* Make sure the rx buffer area is all invalid or clean */
+
+      up_invalidate_dcache((uintptr_t)priv->rxfifo,
+                           (uintptr_t)priv->rxfifo + RXDMA_BUFFER_SIZE);
       priv->rxdmaavail = 0;
 #endif
 
@@ -3509,7 +3515,10 @@ static void imxrt_dma_txcallback(DMACH_HANDLE handle, 
void *arg, bool done,
    * This is important to free TX buffer space by 'uart_xmitchars_done'.
    */
 
-  priv->dev.dmatx.nbytes = priv->dev.dmatx.length + priv->dev.dmatx.nlength;
+  priv->dev.dmatx.nbytes = priv->dev.dmatx.length;
+#if CONFIG_IMXRT_EDMA_NTCD > 1
+  priv->dev.dmatx.nbytes += priv->dev.dmatx.nlength;
+#endif
 
   /* Adjust the pointers and unblock writers */
 
@@ -3592,6 +3601,7 @@ static void imxrt_dma_send(struct uart_dev_s *dev)
 
   imxrt_dmach_xfrsetup(priv->txdma, &config);
 
+#if CONFIG_IMXRT_EDMA_NTCD > 1
   /* Is this a split transfer? */
 
   if (dev->dmatx.nbuffer)
@@ -3606,6 +3616,7 @@ static void imxrt_dma_send(struct uart_dev_s *dev)
 
       imxrt_dmach_xfrsetup(priv->txdma, &config);
     }
+#endif
 
   /* Start transmission with the callback on DMA completion */
 

Reply via email to