my uart lost data while receiving data with platform IMX6Q

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

my uart lost data while receiving data with platform IMX6Q

2,423 Views
如新顾
Contributor I

Dear all,

       when I test the UART port, I found it lost data while receiving data. the test process is like this:

1. On PC side I send 100 bytes from the UART port.

2. On IMX6Q side, I start a test process to test UART, This process will read data with block state, when it receives

    data, it just print the data. from the printed data I found some data lost.

3. I try to add some log in function imx_rxint() in file imx.c, the added log is like this:

static irqreturn_t imx_rxint(int irq, void *dev_id)

{

  struct imx_port *sport = dev_id;

  unsigned int rx,flg,ignored = 0;

  struct tty_struct *tty = sport->port.state->port.tty;

  unsigned long flags, temp;

  spin_lock_irqsave(&sport->port.lock,flags);

  while (readl(sport->port.membase + USR2) & USR2_RDR) {

  flg = TTY_NORMAL;

  sport->port.icount.rx++;

  rx = readl(sport->port.membase + URXD0);

  temp = readl(sport->port.membase + USR2);

  if (temp & USR2_BRCD) {

  writel(USR2_BRCD, sport->port.membase + USR2);

  if (uart_handle_break(&sport->port))

  continue;

  }

  if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))

  continue;

  if (unlikely(rx & URXD_ERR)) {

  if (rx & URXD_BRK)

  sport->port.icount.brk++;

  else if (rx & URXD_PRERR)

  sport->port.icount.parity++;

  else if (rx & URXD_FRMERR)

  sport->port.icount.frame++;

  if (rx & URXD_OVRRUN)

  sport->port.icount.overrun++;

  if (rx & sport->port.ignore_status_mask) {

  if (++ignored > 100)

  goto out;

  continue;

  }

  rx &= sport->port.read_status_mask;

  if (rx & URXD_BRK)

  flg = TTY_BREAK;

  else if (rx & URXD_PRERR)

  flg = TTY_PARITY;

  else if (rx & URXD_FRMERR)

  flg = TTY_FRAME;

  if (rx & URXD_OVRRUN)

  flg = TTY_OVERRUN;

#ifdef SUPPORT_SYSRQ

  sport->port.sysrq = 0;

#endif

  }

  /*add by aaron, 2015.7.29*/

  if(sport->port.line == 1)

  {

  pr_err("[AARON] ttymxc1 :%d, %d", rx, sport->port.icount.rx);

  }

  /*end by aaron*/

  tty_insert_flip_char(tty, rx, flg);

  }

out:

  spin_unlock_irqrestore(&sport->port.lock,flags);

  tty_flip_buffer_push(tty);

  return IRQ_HANDLED;

}

from the log , I found it also not receive the whole data. which means data was lost at this driver layer.

since The amount of data transfered is not so much, why this happened? if some configuration error?

Please help me.  It critical to me

Thanks!

Labels (3)
0 Kudos
Reply
5 Replies

1,232 Views
igorpadykov
NXP Employee
NXP Employee

HI 如新

data may be lost due to uart buffer overruns conditions,

one can try to decrease baudrate or use flow control

as described below

RTS/CTS handshake confusion

i.MX6 UART Driver and RS485 Support

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,232 Views
如新顾
Contributor I

Dear igorpadykov

       I even use 9600 baudrate, which seems lost data again,  

      during debug I find if only send 30 bytes to IMX6, it will much better, and I chek the SPEC, find the RXFIFO is 32 bytes, if the problem is Related to the FIFO?

      

       I tested much times with 100 bytes, and the log is always like this:

130|root@sabresd_6dq:/system/bin # ./test5_io

[aaron] start test_io: Success

[AARON] dma_rx_work, data :1, count :3       //first time to send 100 bytes

[AARON] dma_rx_work, data :97, count :3

[AARON] dma_rx_work, data :3, count :3

[AARON] dma_rx_work, data :4, count :31

[AARON] dma_rx_work, data :5, count :31

[AARON] dma_rx_work, data :6, count :31

[AARON] dma_rx_work, data :7, count :31

[AARON] dma_rx_work, data :8, count :31

[AARON] dma_rx_work, data :9, count :31

[AARON] dma_rx_work, data :10, count :31

[AARON] dma_rx_work, data :11, count :31

[AARON] dma_rx_work, data :12, count :31

[AARON] dma_rx_work, data :13, count :31

[AARON] dma_rx_work, data :14, count :31

[AARON] dma_rx_work, data :15, count :31

[AARON] dma_rx_work, data :16, count :31

[AARON] dma_rx_work, data :17, count :31

[AARON] dma_rx_work, data :18, count :31

[AARON] dma_rx_work, data :19, count :31

[AARON] dma_rx_work, data :20, count :31

[AARON] dma_rx_work, data :21, count :31

[AARON] dma_rx_work, data :22, count :31

[AARON] dma_rx_work, data :23, count :31

[AARON] dma_rx_work, data :24, count :31

[AARON] dma_rx_work, data :25, count :31

[AARON] dma_rx_work, data :26, count :31

[AARON] dma_rx_work, data :27, count :31

[AARON] dma_rx_work, data :28, count :31

[AARON] dma_rx_work, data :29, count :31

[AARON] dma_rx_work, data :30, count :31

[AARON] dma_rx_work, data :31, count :31

[AARON] dma_rx_work, data :32, count :31

[AARON] dma_rx_work, data :33, count :31

[AARON] dma_rx_work, data :34, count :31

[AARON] dma_rx_work, data :1, count :1   //second time to send 100 bytes

[AARON] dma_rx_work, data :97, count :31

[AARON] dma_rx_work, data :3, count :31

[AARON] dma_rx_work, data :4, count :31

[AARON] dma_rx_work, data :5, count :31

[AARON] dma_rx_work, data :6, count :31

[AARON] dma_rx_work, data :7, count :31

[AARON] dma_rx_work, data :8, count :31

[AARON] dma_rx_work, data :9, count :31

[AARON] dma_rx_work, data :10, count :31

[AARON] dma_rx_work, data :11, count :31

[AARON] dma_rx_work, data :12, count :31

[AARON] dma_rx_work, data :13, count :31

[AARON] dma_rx_work, data :14, count :31

[AARON] dma_rx_work, data :15, count :31

[AARON] dma_rx_work, data :16, count :31

[AARON] dma_rx_work, data :17, count :31

[AARON] dma_rx_work, data :18, count :31

[AARON] dma_rx_work, data :19, count :31

[AARON] dma_rx_work, data :20, count :31

[AARON] dma_rx_work, data :21, count :31

[AARON] dma_rx_work, data :22, count :31

[AARON] dma_rx_work, data :23, count :31

[AARON] dma_rx_work, data :24, count :31

[AARON] dma_rx_work, data :25, count :31

[AARON] dma_rx_work, data :26, count :31

[AARON] dma_rx_work, data :27, count :31

[AARON] dma_rx_work, data :28, count :31

[AARON] dma_rx_work, data :29, count :31

[AARON] dma_rx_work, data :30, count :31

[AARON] dma_rx_work, data :31, count :31

[AARON] dma_rx_work, data :32, count :31

[AARON] dma_rx_work, data :50, count :31

[AARON] dma_rx_work, data :51, count :31

[AARON] dma_rx_work, data :52, count :31

[AARON] dma_rx_work, data :53, count :31

[AARON] dma_rx_work, data :54, count :31

[AARON] dma_rx_work, data :55, count :31

[AARON] dma_rx_work, data :56, count :31

[AARON] dma_rx_work, data :57, count :31

[AARON] dma_rx_work, data :58, count :31

[AARON] dma_rx_work, data :59, count :31

[AARON] dma_rx_work, data :60, count :31

[AARON] dma_rx_work, data :61, count :31

[AARON] dma_rx_work, data :62, count :31

[AARON] dma_rx_work, data :63, count :31

[AARON] dma_rx_work, data :64, count :31

[AARON] dma_rx_work, data :65, count :31

[AARON] dma_rx_work, data :66, count :31

[AARON] dma_rx_work, data :67, count :31

[AARON] dma_rx_work, data :68, count :31

[AARON] dma_rx_work, data :69, count :31

[AARON] dma_rx_work, data :70, count :31

[AARON] dma_rx_work, data :71, count :31

[AARON] dma_rx_work, data :72, count :31

[AARON] dma_rx_work, data :73, count :31

[AARON] dma_rx_work, data :74, count :31

[AARON] dma_rx_work, data :75, count :31

[AARON] dma_rx_work, data :76, count :31

[AARON] dma_rx_work, data :77, count :31

[AARON] dma_rx_work, data :78, count :31

[AARON] dma_rx_work, data :79, count :31

[AARON] dma_rx_work, data :80, count :31

Thanks!

0 Kudos
Reply

1,232 Views
igorpadykov
NXP Employee
NXP Employee

you should use uart data flow control

(as suggested in first answer) to correctly use dma

~igor

0 Kudos
Reply

1,232 Views
如新顾
Contributor I

Dear igorpadykov,

      I just send 100 bytes, and from log it seems lost much data. why?

      I test to send 30 bytes, and still may lost data,  some of data lost

     is in the middle of data flow like this:

[AARON] dma_rx_work, data :1, count :3       //first time to send 100 bytes

[AARON] dma_rx_work, data :97, count :3

[AARON] dma_rx_work, data :4, count :31    //data 3 lost

[AARON] dma_rx_work, data :5, count :31

[AARON] dma_rx_work, data :6, count :31

[AARON] dma_rx_work, data :7, count :31

[AARON] dma_rx_work, data :9, count :31      //data 8 lost

[AARON] dma_rx_work, data :10, count :31

[AARON] dma_rx_work, data :11, count :31

[AARON] dma_rx_work, data :12, count :31

[AARON] dma_rx_work, data :13, count :31

[AARON] dma_rx_work, data :14, count :31

[AARON] dma_rx_work, data :15, count :31

[AARON] dma_rx_work, data :16, count :31

[AARON] dma_rx_work, data :17, count :31

[AARON] dma_rx_work, data :18, count :31

[AARON] dma_rx_work, data :19, count :31

[AARON] dma_rx_work, data :20, count :31

[AARON] dma_rx_work, data :21, count :31

[AARON] dma_rx_work, data :22, count :31

[AARON] dma_rx_work, data :23, count :31

[AARON] dma_rx_work, data :24, count :31

[AARON] dma_rx_work, data :25, count :31

[AARON] dma_rx_work, data :26, count :31

[AARON] dma_rx_work, data :27, count :31

[AARON] dma_rx_work, data :28, count :31

[AARON] dma_rx_work, data :29, count :31

[AARON] dma_rx_work, data :30, count :31

[AARON] dma_rx_work, data :31, count :31

[AARON] dma_rx_work, data :32, count :31

[AARON] dma_rx_work, data :33, count :31

[AARON] dma_rx_work, data :34, count :31

..... //data all lost

0 Kudos
Reply

1,232 Views
Emloxu
Contributor I

HI 如新:

You mentioned the problem solved now?

0 Kudos
Reply