UART(4)
π UART(4) π β the Kernel Interfaces Manual, but make it make sense
okay bestie, sit down, hydrate, because we're about to talk about the Universal Asynchronous Receiver/Transmitter β yeah it's the uart driver, and yeah it's a whole vibe. This is from the Kernel Interfaces Manual, so we're in the kernel's group chat now. π«Ά
β¨ NAME β¨
uart β driver for Universal Asynchronous Receiver/Transmitter (UART) devices. that's it, that's the name, slay. π
πΈ SYNOPSIS πΈ
so if you wanna just have a plain UART, you drop this in your kernel config:
device uart
wanna get fancy and go through puc? say less:
device puc
device uart
or through scc? iconic, same energy:
device scc
device uart
and now the /boot/device.hints girlies:
hint.uart.0.disabled="1"
hint.uart.0.baud="38400"
hint.uart.0.port="0x3f8"
hint.uart.0.flags="0x10"
and the flags are encoded like this, no cap, every bit matters:
0x00010 device is potential system console
0x00080 use this port for remote kernel debugging
0x00100 set RX FIFO trigger level to ``low'' (NS8250 only)
0x00200 set RX FIFO trigger level to ``medium low'' (NS8250 only)
0x00400 set RX FIFO trigger level to ``medium high'' (default, NS8250
only)
0x00800 set RX FIFO trigger level to ``high'' (NS8250 only)
note that 0x00400 is the default and yes it's NS8250-only like its little siblings. π
π¦ DESCRIPTION π¦
so the uart device driver is the main character for a bunch of classes of UARTs that implement the EIA RS-232C (CCITT V.24) serial communications interface. every single one of those interfaces gets its own separate and independent instance of the uart driver β they're all individual queens, no sharing. π
now, if your device has multiple serial interfaces, or it has other functionality besides one or more serial interfaces, the primary support comes from the puc(4) or scc(4) device drivers. however (and this is the important part) the serial interfaces of those devices that are managed by the puc(4) or scc(4) driver are each still independently controlled by the uart driver. so basically puc(4) or scc(4) is the umbrella friend group that provides umbrella functionality for the uart driver and hides all the complexities that are inherent when elementary components are packaged together. they're doing the emotional labor so you don't have to. π«Ά
the uart driver has a modular design to allow it to be used on differing hardware and for various purposes. in the sections below we're going through the components in detail. options are described in the section that covers the component to which each option applies β so like, read the whole thing, bestie, don't skip. π
π CORE COMPONENT
at the heart of the uart driver is the core component. it contains the bus attachments and the low-level interrupt handler. that's the engine, the rest is decoration. β¨
π 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. basically it's the translator between the kernel and your weird little chip. π§
π 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 β it's booked and busy, it has a job. 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. main character energy, literally. π
π KERNEL INTERFACES
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. so if it's weird, it's probably specialized, iykyk. π
π 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. β¨
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-232 logic 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. periodt. π
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.
okay so this is the part where I have to be real with you: 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. theCLOCALflag on callin ports should be locked off for logins to avoid certain security holes, but this needs to be done bygettyif the callin port is used for anything else. ππ
π DEPRECATION NOTICE π
the PC Card attachment of this driver is scheduled for removal prior to the release of FreeBSD 13.0. it's giving end of an era. if you're still on PC Card, bestie, this is your sign. π
π 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
π SEE ALSO π
π¦ HISTORY π¦
the uart device driver first appeared in FreeBSD 5.2. a legend was born. β¨
π AUTHORS π
the uart device driver and this manual page were written by Marcel Moolenaar <marcel@xcllnt.net>. thank you for your service, king. π«Ά
and that's the whole thing! this page came out of the Debian corner on April 26, 2017, and it's UART(4) forever and always. go forth, configure your serial ports, and stay hydrated. ππ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2003 Marcel Moolenaar
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms