![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
Early output runs before the normal **rt_serial_device** / **rt_hw_serial_register** path: a minimal putc hook is installed from FDT **/chosen** **stdout-path** and/or **earlycon=** in **bootargs**.
Sources:
components/drivers/serial/device/8250/early.ccomponents/drivers/serial/device/serial-early-hvc.cBaud/format/base parsing: **serial_cfg_from_args**, **serial_base_from_args** in **serial_dm.c** — see UART device model (DM).
**RT_FDT_EARLYCON_EXPORT** entries (examples):
| Symbol | earlycon name | Example compatible |
|---|---|---|
ns16550 | uart8250 | ns16550, ns16550a |
dw8250 | uart8250 | snps,dw-apb-uart |
tegra20 | uart8250 | nvidia,tegra20-uart |
bcm2835aux | uart8250 | brcm,bcm2835-aux-uart |
Bootargs example:
The FDT earlycon core passes **options** into **serial8250_early_fdt_setup**, which calls **serial8250_config** then maps MMIO with **rt_ioremap_early**.
Polls UART LSR (TEMT | THRE) after writing UART_TX**—safe with interrupts masked. Installed as **con->console_putc.
why | Action |
|---|---|
FDT_EARLYCON_KICK_UPDATE | **rt_ioremap** full mapping when switching from early to runtime map |
FDT_EARLYCON_KICK_COMPLETED | **rt_iounmap** early mapping after the platform driver owns the port |
If **config.baud_rate** is zero at setup, firmware already programmed the UART; the code only clears IER.
When **serial->freq** is set, **init_serial** programs DLL/DLM from **freq / (16 * baud_rate)**.
hvc_early_setup** calls **rt_hv_version**; on success **console_putc** → **rt_hv_console(c)**.reg**—hypervisor console path.rt_kprintf** / **console_putc**.8250-ofw**) maps the same UART, **serial_dev_set_name**, **rt_hw_serial_register** → **uartN** for apps.FDT_EARLYCON_KICK_COMPLETED** when the serial core finishes transition.Do not leave early putc and the full driver writing the same UART without the kick handshake.
reg-shift**: early defaults may differ from DT **reg-shift** in probe—keep them consistent for your IP.serial_cfg_from_args** may modify the string ( **OFW** suffix).chosen**, **stdout-path**components/drivers/serial/device/8250/core.c, 8250-ofw.c