Serial TTY line discipline

Revision as of 09:41, 25 July 2019 by Registered User (→‎Framework Purpose)

SUMMARY
This article gives information about the Linux® TTY framework. It explains how to activate the UART interface with line disciplines, and how to access it from user and kernel spaces.

1. Framework purpose[edit source]

The article Serial TTY overview describes the TTY framework. Please refers to this article. UART is the common interface for several devices, such as Bluetooth, NFC, FM Radio and GPS devices.
Since kernel 4.12 version, the serial device bus (also called Serdev) has been introduced in TTY framework to improve the interface offered to devices attached to a serial port . Nevertheless it's still possible (even if not recommended) to use line disciplines "drivers". This article focuses on the line discipline interface offered to devices attached to a serial port.

2. System overview[edit source]

Serial TTY Line Discipline overview.png


2.1. Components description[edit source]

From client application to hardware

  • Application: customer application to read/write data from the peripheral connected on the serial port.
  • TTY tools: tools provided by Linux community, such as stty, ldattach, inputattach, tty, ttys, agetty, mingetty, kermit and minicom.
  • Termios: API which offers an interface to develop an application using serial drivers.
  • Client subsystem: kernel subsystem client of TTY core (Example: a Bluetooth device)
  • USART driver: stm32-usart low-level serial driver for all stm32 family devices.
  • STM32 USART: STM32 frontend IP connected to the external devices through a serial port

2.2. APIs description[edit source]

The TTY provides only character device interface (named /dev/ttyX) to user space. The main API for user space TTY client applications is provided by the portable POSIX terminal interface termios, which relies on /dev/ttyX interface for TTY link configuration.

The termios API [1] is a user land API, and its functions describe a general terminal interface that is provided to control asynchronous communications ports.

The POSIX termios API abstracts the low-level details of the hardware, and provides a simple yet complete programming interface that can be used for advanced projects. It is a wrapper on character device API [2] ioctl operations.

Note: If a serial interface is needed at kernel level (to control an external device through U(S)ART by a kernel driver for example), customer can use a line discipline.

  • The line discipline will be responsible for:
    • creating this new kernel API
    • routing data flow between serial core and new kernel API

3. References[edit source]

  1. termios API, Linux Programmer's Manual termios API Documentation (user land API with serial devices)
  2. Character device API overview, Accessing hardware from userspace training, Bootlin documentation


Template:ArticleMainWriter Template:ArticleApprovedVersion