Linux UART driver for 5475 loses data

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

Linux UART driver for 5475 loses data

1,950 Views
jurgen
Contributor I
Hi !

I am using the Linux 2.6.10 kernel and finding that the UART driver seems to lose data whenever the receive buffer (flip buffer) is full. The interrupt routine receive_chars() in drivers/serial/mcfserial.c had the following code:

Code:
static _INLINE_ void receive_chars(struct mcf_serial *info,
  volatile unsigned char *uartp)
{
  struct tty_struct *tty = info->tty;
  unsigned char  status, ch;
       
  if (!tty)
 return;

  while ((status = uartp[MCFUART_USR]) & MCFUART_USR_RXREADY) {
 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
   /*
   * can't take any more data.  Turn off receiver
   * so that the interrupt doesn't continually
   * occur.
   */
   info->imr &= ~MCFUART_UIR_RXREADY;        uartp[MCFUART_UIMR] = info->imr;
  break;
  }
 ....  //process the character
  }
  schedule_delayed_work(&tty->flip.work, 1);
  return;
}

 what I found is that the interrupts never get activated again so I changed it to:
Code:
if (tty->flip.count >= TTY_FLIPBUF_SIZE) {      break;}

When the interrupt completes it schedules the flipping of of the buffers  but  somehow even if I have RTS/CTS I still lose data.
I even  tried enabling low_latency for the driver and scheduling the work of flipping the buffers immediately using (at the end of the receive_chars() routine) :
Code:
schedule_work(&tty->flip.work);

 I have the following questions:
1. If the data is not read from the FIFO queue in the interrupt routine does it discard those characters?
2. Where would the interrupt be enabled again when the it is disabled in the interrupt handler?
3. Is there another suggestions of how to solve it?

Thanks.



 


Labels (1)
0 Kudos
4 Replies

483 Views
jurgen
Contributor I
Hi Georg,
 
I just wanted to let you know that I sent an invalid termio structure in my test app. to the uart which then gave me the framing errors. What gave rise to the tests was that I am losing LCP and check control packets that are sent from the l2tp daemon to the VPN server which then terminates my VPN session.  I probably need to look at the networking layer to figure out why this is happening. Thanks for your help.
 
regards,
 
Jurgen
 
 
0 Kudos

483 Views
jurgen
Contributor I
Hi Georg,
 
thanks. You were on the right track. I am getting framing errors in one of my serial comms tests.
 
In my test I am sending at 115200 bps (8N1) from the PC and only servicing the com port buffer at under 2400 Kbytes/s on the Coldfire. 
 
Why would I get framing errors?
When I am sending a 35K file across I only receive about 24K on the Coldfire the rest is discarded because of framing errors. Could there be a timing problem?
 
I am using RTS/CTS which seems to be working as I can see the lines being asserted/unasserted and the PC is holding back when the FIFO buffer is full on the Coldfire.
 
regards,
 
Jurgen  
0 Kudos

483 Views
taigbr
Contributor I
Hi Jurgen,

framing error probably means that the bitrates don't fit. Maybe the uart divider
isn't set up correct or your system clock is not what you expect it to be.
It would also explain why you lose data. You could send some 0x55 chars
and have a look whith a scope to see your actual bitrate.
Regards, Georg

0 Kudos

483 Views
taigbr
Contributor I
Hi Jurgen,

data will probably lost with an overrun error.
Interrupts could be reenabled by
- function that empties the flipbuffer
- timer event that checks if flipbuffer may take chars
Timer depends on your flipbuffer size and bitrate and will
probably be somewhere from 1ms to 10ms.
You might also have situations where the timer has to reenable
the tx int.
Regards, georg

0 Kudos