This article is based on the official OpenWrt documentation, with additional explanations for beginners. Never flash an image built for one model onto another model without checking the target, profile, and recovery method.
When should you build OpenWrt from source?
A source build is useful when you want to customize the kernel, packages, patches, default configuration, or firmware for a specific target. If you only need to add packages to an existing image, ImageBuilder is usually faster and simpler.
OpenWrt's build system creates the cross-compilation toolchain, kernel, root filesystem, and image components for the selected target.
Prepare a Linux build environment
Use a 64-bit Linux computer with enough disk space and RAM. On Debian or Ubuntu, install the basic build tools:
| |
Package names differ between distributions. If a package is unavailable, find the equivalent for your distribution rather than skipping the dependency.
Download the OpenWrt source
The OpenWrt documentation recommends using the official repository or a project mirror:
| |
Use a dedicated directory such as ~/src/openwrt instead of a system directory so that multiple branches and build caches are easier to manage.
Select a branch or tag
Use main for the newest development changes. For a router used in production, select a stable branch or tag supported by the device and read the release notes first.
| |
Replace the placeholder with a version tested for your router. Do not copy the command and flash the result without checking the target.
Update feeds
Feeds provide packages used during the build:
| |
If a feed fails, read the URL and error in the terminal before trying again. Do not delete .config blindly, because that can remove the selected target.
Select the target with menuconfig
Open the configuration interface:
| |
Important options include:
Target System: SoC or platform family.Subtarget: hardware branch within the target.Target Profile: exact router model.LuCI: web interface, if needed.Base systemandNetwork: core packages.
Compare the router with the supported-device list and image profile. A wrong target can produce an image that does not boot or cannot be flashed.
Save the configuration and generate defaults if needed:
| |
Back up .config:
| |
Download package sources before compiling
Detect download problems early:
| |
If a mirror is slow or fails, check the URL, proxy, DNS, and network before starting the compile.
Build the firmware
Normal build:
| |
If the computer has limited RAM, reduce parallelism:
| |
For detailed output from one failing step:
| |
Firmware and packages are normally placed under bin/targets/. The exact filenames depend on the target, subtarget, profile, and .config choices.
Check the image before flashing
- Verify the target and profile in
bin/targets/. - Check the checksum when available.
- Back up the original firmware and configuration.
- Prepare UART, TFTP, or web-recovery access. For UART boot logs, a USB-to-TTL adapter such as this FT232 adapter can be used; connect only GND, RX, and TX at the correct voltage.
- Ensure stable power.
- Read the flashing guide for the exact router model.
Tool selection summary
| Need | Tool |
|---|---|
| Deep kernel, package, or patch customization | Source build system |
| Add packages and configuration files to an existing image | ImageBuilder |
| Compile an individual package | SDK |
| Develop a complete firmware image | Build system + toolchain |
Official sources
- OpenWrt — Build system setup
- OpenWrt — Build system usage
- OpenWrt — Build system essentials
- OpenWrt source repository


Góp Ý / Bình Luận / Đánh giá