UART(4)
UART(4) π β¨
okay bestie, welcome to the uart page from the Kernel Interfaces Manual β this is the Universal Asynchronous Receiver/Transmitter serial driver, and she is genuinely iconic. grab a strawberry drink π, because this one has layers.
πΈ NAME πΈ
uart β Universal Asynchronous Receiver/Transmitter serial driver π
π SYNOPSIS π
okay so you can bring uart into your kernel config in a few different ways, depending on the vibe of your hardware:
device uart
device puc
device uart
device scc
device uart
and if you're doing the /boot/device.hints thing, it looks like this:
hint.uart.0.disabled="1"
hint.uart.0.baud="38400"
hint.uart.0.port="0x3f8"
hint.uart.0.flags="0x10"
With flags encoded as:
0x00010β device is potential system console π0x00080β use this port for remote kernel debugging π0x00100β set RX FIFO trigger level tolow(NS8250 only)0x00200β set RX FIFO trigger level tomedium low(NS8250 only)0x00400β set RX FIFO trigger level tomedium high(default, NS8250 only) β¨0x00800β set RX FIFO trigger level tohigh(NS8250 only)
π DESCRIPTION π
The uart device driver provides support for various classes of UARTs implementing the EIA RS-232C (CCITT V.24) serial communications interface. Each such interface is controlled by a separate and independent instance of the uart driver. fr fr, every interface gets her own main character energy. π
The primary support for devices that contain multiple serial interfaces, or that contain other functionality besides one or more serial interfaces, is provided by the puc(4) or scc(4) device drivers. But here's the tea: the serial interfaces of those devices that are managed by the puc(4) or scc(4) driver are each independently controlled by the uart driver. So puc(4) or scc(4) is basically giving umbrella functionality for the uart driver and hiding the complexities that are inherent when elementary components are packaged together. iykyk π«Ά
The uart driver has a modular design to allow it to be used on differing hardware and for various purposes. In the following sections the components are discussed in detail. Options are described in the section that covers the component to which each option applies. no cap, she's organized.
π§ CORE COMPONENT π§
At the heart of the uart driver is the core component. It contains the bus attachments and the low-level interrupt handler. literally the core core. π
π¦ HARDWARE DRIVERS π¦
The core component and the kernel interfaces talk to the hardware through the hardware interface. This interface serves as an abstraction of the hardware and allows varying UARTs to be used for serial communications. it's giving translator, but make it hardware. β¨
π SYSTEM DEVICES π
System devices are UARTs that have a special purpose by way of hardware design or software setup. For example, Sun UltraSparc machines use UARTs as their keyboard interface. Such a UART cannot be used for general purpose communications. Likewise, when the kernel is configured for a serial console, the corresponding UART will in turn be a system device so that the kernel can output boot messages early on in the boot process. periodt. π
π« KERNEL INTERFACES π«
The last but not least of the components is the kernel interface. This component ultimately determines how the UART is made visible to the kernel in particular and to users in general. The default kernel interface is the TTY interface. This allows the UART to be used for terminals, modems and serial line IP applications. System devices, with the notable exception of serial consoles, generally have specialized kernel interfaces. very "different lanes for different vibes." π
π₯ HARDWARE π₯
The uart driver supports the following classes of UARTs:
- NS8250: standard hardware based on the
8250,16450,16550,16650,16750or the16950UARTs. π - SCC: serial communications controllers supported by the
scc(4)device driver. π¦
β±οΈ Pulse Per Second (PPS) Timing Interface β±οΈ
The uart driver can capture PPS timing information as defined in RFC 2783. The API, accessed via ioctl(2), is available on the tty device. To use the PPS capture feature with ntpd(8), symlink the tty callout device /dev/cuau? to /dev/pps0. cute little symlink, big timing energy. π«Ά
The hw.uart.pps_mode tunable configures the PPS capture mode for all uart devices; it can be set in loader.conf(5). The dev.uart.0.pps_mode sysctl configures the PPS capture mode for a specific uart device; it can be set in loader.conf(5) or sysctl.conf(5).
The following capture modes are available:
0x00β Capture disabled. π0x01β Capture pulses on the CTS line.0x02β Capture pulses on the DCD line.
The following values may be ORed with the capture mode to configure capture processing options:
0x10β Invert the pulse (RS-232logic low =ASSERT, high =CLEAR). π0x20β Attempt to capture narrow pulses. π§
Add the narrow pulse option when the incoming PPS pulse width is small enough to prevent reliable capture in normal mode. In narrow mode the driver uses the hardware's ability to latch a line state change; not all hardware has this capability. The hardware latch provides a reliable indication that a pulse occurred, but prevents distinguishing between the CLEAR and ASSERT edges of the pulse. For each detected pulse, the driver synthesizes both an ASSERT and a CLEAR event, using the same timestamp for each. To prevent spurious events when the hardware is intermittently able to see both edges of a pulse, the driver will not generate a new pair of events within a half second of the prior pair. Both normal and narrow pulse modes work with ntpd(8). π°οΈ
Add the invert option when the connection to the uart device uses TTL level signals, or when the PPS source emits inverted pulses. RFC 2783 defines an ASSERT event as a higher-voltage line level, and a CLEAR event as a lower-voltage line level, in the context of the RS-232 protocol. The modem control signals on a TTL-level connection are typically inverted from the RS-232 levels. For example, carrier presence is indicated by a high signal on an RS-232 DCD line, and by a low signal on a TTL DCD line. This is due to the use of inverting line driver buffers to convert between TTL and RS-232 line levels in most hardware designs. Generally speaking, a connection to a DB-9 style connector is an RS-232 level signal at up to 12 volts. A connection to header pins or an edge-connector on an embedded board is typically a TTL signal at 3.3 or 5 volts. β‘
π Special Devices π
The uart driver also supports an initial-state and a lock-state control device for each of the callin and the callout "data" devices. The termios settings of a data device are copied from those of the corresponding initial-state device on first opens and are not inherited from previous opens. Use stty(1) in the normal way on the initial-state devices to program initial termios states suitable for your setup. π
The lock termios state acts as flags to disable changing the termios state. E.g., to lock a flag variable such as CRTSCTS, use stty crtscts on the lock-state device. Speeds and special characters may be locked by setting the corresponding value in the lock-state device to any nonzero value. E.g., to lock a speed to 115200, use stty 115200 on the initial-state device and stty 1 on the lock-state device. π
Correct programs talking to correctly wired external devices work with almost arbitrary initial states and almost no locking, but other setups may benefit from changing some of the default initial state and locking the state. In particular, the initial states for non (POSIX) standard flags should be set to suit the devices attached and may need to be locked to prevent buggy programs from changing them. E.g., CRTSCTS should be locked on for devices that support RTS/CTS handshaking at all times and off for devices that do not support it at all. CLOCAL should be locked on for devices that do not support carrier. HUPCL may be locked off if you do not want to hang up for some reason. In general, very bad things happen if something is locked to the wrong state, and things should not be locked for devices that support more than one setting. The CLOCAL flag on callin ports should be locked off for logins to avoid certain security holes, but this needs to be done by getty if the callin port is used for anything else. π
ποΈ Console Tuneable ποΈ
The uart driver can be designated as a system console. Yes bestie, your serial port can literally be the main character of your boot process β¨
hw.uart.console
This one holds a bunch of /etc/remote-style tag:value pairs, all separated by commas. Think of it as a little comma-separated group chat for your console settings π¬
bdβ Busy Detect. Turns on the so-called "Busy Detect" quirk for the device. For NS 16550-compatible devices this uses heuristics to make sure the UART isn't still busy before it messes with line control. DesignWare-based UARTs need this because of a design flaw in the UART. Not optional-vibes for those ones, it's a whole thing πbrβ Baudrate. The data rate (bits per second) used for communications on the serial port. When the device clock rate (seexobelow) is set to0, then the baud rate gets used together with the divisor to compute the device clock rate the very first time the device is initialized. Only the traditional baud rates are allowed, so listen up:- Rates larger than
19200must be a multiple of19200. - Baud rates between
1200and19200must be a multiple of1200. - Otherwise the baud rate must be a multiple of
75.
- Rates larger than
A value of '0' instructs the uart driver to not program the baud rate divisor and just use the hardware as-is. Chaotic, but valid π
chβ Channel. Defaults to0. Has no effect on UARTs with only one channel (so, most of them, lowkey).dbβ Data bits. Defaults to8.dtβ Device type. Specifies the uart class to use for this device.ns8250β Traditional PC UART National Semiconductor 16550 and compatible devices.pl011β Common ARM UART, based on ARM Limited designs.
ioβ I/O port address. Specifies the address of a UART in an Intel processor's I/O space. Mutually exclusive with'mm'β pick one, bestie, you can't have both π«Άmmβ Memory mapped I/O address. Specifies the physical address of a memory-mapped UART. Mutually exclusive with'io'. Same deal, opposite direction.paβ Parity. The type of parity to use when sending data to the host. This may be one ofeven,odd,none,zero(always set bit 8 to zero),one(always set bit 8 to 1). The default is even parity.rsβ Register shift. Number of bits to shift left the base register offset.rwβ Register width. Size of operations to read and write the registers of the device.sbβ Stopbits. Defaults to1.xoβ Device clock (xtal oscillator). Base frequency of the oscillator to use for the device. When set to0, and the baud rate is also set, the UART's initialization code will compute this the first time and use that after. Heads up though: automatically computed values can be as large as 5% off when the base frequency is a poor match to the traditional baud rates. So likeβ¦ close enough is not always close enough π
π FILES π
/dev/ttyu?β for callin ports/dev/ttyu?.init/dev/ttyu?.lockβ corresponding callin initial-state and lock-state devices/dev/cuau?β for callout ports/dev/cuau?.init/dev/cuau?.lockβ corresponding callout initial-state and lock-state devices
πΈ EXAMPLES πΈ
hw.uart.console="io:0x2f8,br=115200"
When the kernel is using a serial console port, it should use COM2 instead of COM1 and set the baud rate to 115200. Slay, COM2 supremacy π₯
π SEE ALSO π
cu(1), puc(4), scc(4), ttys(5)
Go read them, iykyk π
π¦ HISTORY π¦
The uart device driver first appeared in FreeBSD 5.2. An icon, honestly π
π AUTHORS π
The uart device driver and this manual page were written by Marcel Moolenaar <marcel@xcllnt.net>. Thank you Marcel, you ate π«Ά
and that's the whole page, bestie!! πβ¨ This lil beauty is the Debian build, dated December 5, 2024, and it's the UART(4) page β go forth and console with confidence π
π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- π the page's license: BSD-2-Clause
- Copyright (c) 2003 Marcel Moolenaar
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms