My OpenWrt firmware image build guide
This method is NOT OFFICIALLY supported.
A native GNU/Linux environment is recommended.
Current supported OpenWrt releases are for 16/128 devices - at least 16Mbytes Flash and 128MBytes RAM.
Devices with ≤4MB Flash and/or ≤32MB RAM (so-called “4/32 devices”) sometimes can be made to work but they will be very limited (maybe no additional packages can be installed or ran, setting password or changing network settings might not be possible any more, device can get useless) because of low RAM/Flash space.
Build guide mainly based on an old revision of OpenWrt document "Quick Image Building Guide".
1. Prerequisites
A suitable case-sensitive file system.
Last tested on WSL2 (Windows Version 10.0.19044.1586) with Debian GNU/Linux 11 (bullseye).
Mind issue with path!
1.1 Download package information
Debian terminal command:
sudo apt update
1.2 Install required dependencies
See examples of package installations.
Verify link and required packages!
1.3 Leave privileged mode
Debian terminal command:
exit
2. Get OpenWrt source code
2.1 Clone repository
For OpenWrt 19.07 Debian terminal command: git clone -b openwrt-19.07 --single-branch https://git.openwrt.org/openwrt/openwrt.git openwrt_19.07 |
For OpenWrt 21.02 Debian terminal command: git clone -b openwrt-21.02 --single-branch https://git.openwrt.org/openwrt/openwrt.git openwrt_21.02 |
2.2 Change working directory
For OpenWrt 19.07 Debian terminal command: cd openwrt_19.07 |
For OpenWrt 21.02 Debian terminal command: cd openwrt_21.02 |
2.3 Update local branch
If there is a new release in the branch, update local branch repository with Debian terminal command:
git pull
2.4 Select version
For OpenWrt 19.07 Debian terminal command: git checkout v19.07.8 |
For OpenWrt 21.02 Debian terminal command: git checkout v21.02.3 |
2.5 Update and install feeds
Debian terminal command:
./scripts/feeds update -a && ./scripts/feeds install -a
3. OpenWrt Configuration
3.1 Configure target system
For router hardware select corresponding values in menu ( link to router hardware table):
- “Target System” ⇒ “Select” ⇒ <target system> ⇒ “Select”
- “Subtarget” ⇒ “Select” ⇒ <subtarget> ⇒ “Select”
- “Target Profile” ⇒ “Select” ⇒ <target profile> ⇒ “Select”
3.2 Options
Maybe add “LuCI”:
- “LuCI” ⇒ “Select” ⇒ “Collections” ⇒ “Select” ⇒ on “luci” press <Y> to include (= “*” built-in) ⇒ “Exit” ⇒ “Exit”
Maybe remove some packages to save space.
- remove “PPP daemon”:
- “Network” ⇒ “Select” ⇒ on “ppp” press <N> to exclude (= “ ” excluded) ⇒ “Exit”
- remove “IPv6 support”:
- “Global build settings” ⇒ “Select” ⇒ on “Enable IPv6 support in packages” press <N> to exclude (= “ ” excluded) ⇒ “Exit”
Maybe make WPA2 Enterprise with wpa_supplicant available by:
- remove “wpad-mini”:
For OpenWrt 19.07:
|
For OpenWrt 21.02:
|
- add “wpad”:
For OpenWrt 19.07:
|
For OpenWrt 21.02:
|
Maybe add load balancing/failover with multiple WAN interfaces.
- add “MAC-VLAN support”:
- “Kernel modules” ⇒ “Select” ⇒ “Network Devices” ⇒ “Select” ⇒ on “kmod-macvlan” press <Y> to include (= “*” built-in) ⇒ “Exit” ⇒ “Exit”
- add “LuCI support for the MWAN3 multiwan hotplug script”:
- “LuCI” ⇒ “Select” ⇒ “3. Applications” ⇒ “Select” ⇒ on “luci-app-mwan3” press <Y> to include (= “*” built-in) ⇒ “Exit” ⇒ “Exit”
- or without LuCI, add “Multiwan hotplug script with connection tracking support”:
- “Network” ⇒ “Select” ⇒ “Routing and Redirection” ⇒ “Select” ⇒ on “mwan3” press <Y> to include (= “*” built-in) ⇒ “Exit” ⇒ “Exit”
Maybe add network watchdog utility.
- add “LuCI Support for Watchcat”:
- “LuCI” ⇒ “Select” ⇒ “3. Applications” ⇒ “Select” ⇒ on “luci-app-watchcat” press <Y> to include (= “*” built-in) ⇒ “Exit” ⇒ “Exit”
- or without LuCI, add “Watchcat”:
- “Utilities” ⇒ “Select” ⇒ on “Watchcat” press <Y> to include (= “*” built-in) ⇒ “Exit”
3.3 Exit configuration
To exit OpenWrt Configuration and save target with options settings do following:
- “Exit” ⇒ “Yes”
4. Build image
Debian terminal command:
make V=s 2>&1 | tee build.log
Completion can take time. If successful, the images are in the directory ./bin/targets/<target directory>
- The *-factory.bin image file is for the first installation of OpenWrt on the target.
- The *-sysupgrade.bin image file is for updating an existing OpenWrt installation.
To recompile the images, remove files from directory ./bin/targets/<target directory> and build image (step 4) again.
What about cleaning up “make clean”, “make dirclean”, “make distclean”?
For faster compiling, use make -j N
, where N is the number of CPU cores + 1. Be aware that this method is prone to errors during compiling. In case you encounter compile errors, your very first step is to compile again without -j N
. Use of make download
prior to parallel compilation is recommended to prevent some of these errors (-jN
is generally safe for the download step for those with faster Internet connectivity.)
To build an OpenWrt firmware image for other hardware or with other options, use the OpenWrt Configuration (step 3) and then build image (step 4) again.
Also more hardware info on wikidevi.
Other OpenWrt pages: