Build OpenWRT system image
Container image to build Openwrt image based on https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem To build own container image:
sudo yum install -y git podman
git clone https://github.com/danpawlik/openwrt-builder
cd openwrt-builder
podman build -t openwrt-builder -f Dockerfile
How to use:
mkdir -p openwrt-builder && chmod 0777 openwrt-builder
podman run --name openwrt -it -u user -v $(pwd)/openwrt-builder:/home/user/openwrt-builder:z,rw quay.io/dpawlik/openwrt:f40 bash
Then inside the container (from https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem):
git clone https://git.openwrt.org/openwrt/openwrt.git ~/openwrt-builder/openwrt && cd ~/openwrt-builder/openwrt
Optionally add MediaTek feed (onlt for 21.02):
cat << EOF >> feeds.conf.default
src-git mtksdk https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds
EOF
git add feeds.conf.default ; git commit -m 'Add MediaTek feed'
Update the feeds:
./scripts/feeds update -a && ./scripts/feeds install -a
Use device config:
# BPI-R4
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 > ~/openwrt-builder/openwrt/.config
# AX3200
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7622/ax3200 > ~/openwrt-builder/openwrt/.config
# AX3600
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/qualcommax/ax3600 > ~/openwrt-builder/openwrt/.config
# Xiaomi 4A Giga Edition
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ramips/mt7621/4a-giga > ~/openwrt-builder/openwrt/.config
# Ubiquiti U6 Lite
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ramips/mt7621/u6-lite > ~/openwrt-builder/openwrt/.config
# Ubuquti UAP-AC-LR
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ath79/generic/uap-ac-lr > ~/openwrt-builder/openwrt/.config
# Mikrotik hAP AC
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ath79/mikrotik/962uigs-5hact2hnt > ~/openwrt-builder/openwrt/.config
NOTE: If device got additional hardware installed, for example: Banana Pi R4 got wireless card, it is also included in the config file.
then add the required packages that I use for the router/AP function:
- Main router:
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> ~/openwrt-builder/openwrt/.config
- Dumb AP:
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/dumb_ap >> ~/openwrt-builder/openwrt/.config
- Basic config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/basic >> ~/openwrt-builder/openwrt/.config
Configure the firmware image and the kernel:
make menuconfig
# or
./scripts/diffconfig.sh > diffconfig
cp diffconfig .config
make defconfig
Optional: comment modules:
for m in $(grep "=m" .config | grep -v 'CONFIG_PACKAGE_libustream-mbedtls=m'); do module=$(echo $m| cut -f1 -d'='); sed -i "s/$m/\# $module is not set/g" .config; done
# or
grep "=m" .config | grep -v 'CONFIG_PACKAGE_libustream-mbedtls=m' | while read -r line; do module=$(echo "$line" | cut -f1 -d'='); sed -i "s/^$line$/# $module is not set/" .config; done
Then:
make -j$(nproc) kernel_menuconfig
Build the firmware image:
make -j $(nproc) defconfig download clean world
To get more verbosity:
make -j1 V=s defconfig download clean world
# Banana Pi R4 as main router
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 > ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> ~/openwrt-builder/openwrt/.config
./scripts/diffconfig.sh > diffconfig
cp diffconfig .config
make defconfig
make -j$(nproc) kernel_menuconfig
make -j $(nproc) defconfig download clean world
# AX3200 as dumb AP
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7622/ax3200 > ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/dumb_ap >> ~/openwrt-builder/openwrt/.config
./scripts/diffconfig.sh > diffconfig
cp diffconfig .config
make defconfig
make -j$(nproc) kernel_menuconfig
make -j $(nproc) defconfig download clean world
# AX3600 as main router with Qualcomm NSS framework
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/qualcommax/ax3600 > ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/nss >> ~/openwrt-builder/openwrt/.config
./scripts/diffconfig.sh > diffconfig
cp diffconfig .config
make defconfig
make -j$(nproc) kernel_menuconfig
make -j $(nproc) defconfig download clean world
- Install Ansible:
sudo dnf install -y ansible-core git
- Clone builder project
git clone https://github.com/danpawlik/openwrt-builder && cd openwrt-builder
- Run Ansible playbook
ansible-playbook -i ansible/inventory.yaml ansible/openwrt-build.yaml