Skip to content

TTY and UART Subsystem

The TTY subsystem provides the standard Linux serial-device abstraction. UART hardware drivers expose serial ports through the TTY layer, and user space usually accesses them through device nodes such as /dev/ttyAMA0, /dev/ttyS0, or USB serial nodes.

What Problem It Solves

Serial communication needs more than raw byte transfer. It also needs baud rate configuration, parity, stop bits, flow control, canonical or raw input modes, buffering, and terminal semantics. Linux handles these through the TTY layer and termios configuration.

Core Concepts

Concept Description
UART driver Hardware-specific serial controller driver.
TTY core Common serial/terminal framework.
Line discipline Processing layer between user space and the driver.
termios User-space serial configuration interface.
/dev/tty* User-space serial device node.

End-to-End Flow

User application
    ↓ read() / write() / termios
/dev/tty*
TTY core
line discipline
UART driver
UART hardware

Common User-Space Tasks

  • Open the serial node with open().
  • Configure baud rate and raw mode through termios.
  • Use read() and write() for byte transfer.
  • Use poll() or epoll() for event-driven serial handling.

Design Notes

  • UART is usually not implemented as a custom character driver by application developers.
  • For most products, the driver is provided by the SoC or USB-serial stack.
  • Firmware and test tools usually interact with UART through /dev/tty* and termios.
  • Debugging often involves checking pinmux, device tree, baud rate, and permissions.