System Layers
Hardware
The physical device: CPU, flash storage, RAM, network interfaces, and peripherals. OpenWrt targets a wide range of architectures including ARM, MIPS, x86, and RISC-V.
Bootloader
Typically U-Boot. Responsible for initializing hardware, loading the kernel from flash into RAM, and passing device tree information to the kernel.
Linux Kernel
A cross-compiled Linux kernel tuned for the target device. Handles hardware abstraction, networking, filesystems, and device drivers (loaded via
kmodloader).Core Libraries
musl libc — a lightweight, standards-compliant C library used instead of glibc to minimize footprint on constrained devices. Supplemented by libubox, a core utility library used by most OpenWrt daemons.
OpenWrt Daemons
The essential userspace layer:
- procd — PID 1, service supervisor, and watchdog
- ubusd — the inter-process communication (IPC) bus daemon
- uci — the Unified Configuration Interface
Packages
Additional software installed via opkg (or apk). This includes network daemons (netifd, dnsmasq, firewall4), VPN clients, monitoring tools, and any user-installed software.
Boot Sequence
After the bootloader hands off to the kernel, the following sequence occurs:START variable in each /etc/init.d/ script. Lower numbers start earlier. The rcS script walks /etc/rc.d/S* symlinks created by enable.
Build System vs. Runtime
OpenWrt has two distinct operational modes:| Context | Description |
|---|---|
| Build system | Runs on a Linux/macOS host. Uses make menuconfig, cross-compiles the kernel and packages, and produces flashable firmware images (.bin, .img). |
| Runtime | Runs on the target device. Uses opkg to install/remove packages, uci to configure services, and /etc/init.d/ scripts to manage running daemons. |
Core Subsystems
Package Manager (opkg)
Install, remove, and query software packages with opkg.
UCI — Unified Configuration Interface
Centralized configuration system for all OpenWrt services.
Init System (procd)
PID 1, service supervision, and hotplug event handling.
Filesystem Layout
OverlayFS, directory structure, and firmware upgrades.