Home
How to reduce serial port latency on Embedded Linux Systems

Image

In embedded Linux systems, most often we come across serial communication protocols which have to respect tight response times.

Given these requirements, Engineers willing to use Embedded Linux on their product are faced with the choice of using the standard TTY Linux layer to manage serial communication. However, the TTY layer introduces unpredictable delays which leads to longer response time (computed as the time which passes between the reception of the character on the microcontroller and the processing of the same character in the user space application).

For this reason, Evidence proposes a modification to the standard TTY layer that is able to reduce the delay experienced on the serial communication.

This application note describes in detail the changes that can be done to the standard Linux Kernel to obtain a better serial line response time.

Technical Summary: To reduce serial delay, sh4 Linux kernel serial driver was patched by setting tty->low_latency and implementing a tasklet to move tty_flip_buffer_push outside the IRQ context for immediate execution, else residing inside the IRQ context the tty_flip_buffer_push blocks the kernel.

Setup: To calculate serial response time, we wrote a simple program in C which echoes the received character. The console was connected using minicom for sending and receiving and the oscilloscope was connected with 2 probes on the serial interface for measuring time.

Testing: The system for tested for no. of times for following 3 conditions, with and without applying patch and only max. delay time were recorded-
(a) Idle system.
(b) System with an infinite cycle writing 'yes'to /dev/null (i.e. busybox command yes > /dev/null &).
(c) System downloading an image of 300 Mb on a filesystem (mounted as NFS) using wget.

Results without patch:
(a) Idle system: max. delay = 4 msec.
(b) System with cycle for: max. delay = 5 msec.
(c) System while downloading from network: max. delay = 10 msec.

Results with patch:
(a) Idle system: max. delay = 0.2 msec.
(b) System with cycle for: max. delay = 0.4 msec.
(c) System while downloading from network: max. delay = 0.8 msec.

Conclusion: Our modification by means of a patch to the kernel helps to reduce the serial delay by a factor of 10.

Availability of the patch: This patch is released under the GPL license. To obtain the source code and the needed service to apply the patch to your embedded device, please This e-mail address is being protected from spam bots, you need JavaScript enabled to view it .

 

Authors 

  •  Michael Trimarchi (Evidence Srl)

Hardware

  •  Renesas MigoR SH7722 evaluation board.
  •  Oscilloscope.
 

Software

  •  Linux kernel Ver. 2.6.29 as firmware, mounted as NFS filesystem.
  •  Minicom serial communication program.
  •  C compliler.
 

Download

 

External links

None.

 
Evidence S.r.l.
PIVA: 01638690501
HOME  |  COMPANY  |  PRODUCTS  |  SERVICES  |  DOWNLOAD  |  STORE  |  PRIVACY POLICY