Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active March 28, 2025 14:50
Show Gist options
  • Save danpawlik/c62c5772b181e9ab8c1cc57e15d00a13 to your computer and use it in GitHub Desktop.
Save danpawlik/c62c5772b181e9ab8c1cc57e15d00a13 to your computer and use it in GitHub Desktop.
build image for BPI-R4 with Mediatek feed
#!/bin/bash
## NOTE: Remember to disable firewall rules that blocks
## port 53, 853 and 5353 on wireguard server router.
OPENWRT_BRANCH=openwrt-24.10
OPENWRT_DIR=$(pwd)/openwrt-mediatek
MEDIATEK_FEED_BRANCH=master
git clone https://github.com/openwrt/openwrt $OPENWRT_DIR -b $OPENWRT_BRANCH
cd $OPENWRT_DIR/
./scripts/feeds update -a && ./scripts/feeds install -a
git clone https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds $OPENWRT_DIR/mtk-openwrt-feeds
ln -s $OPENWRT_DIR/mtk-openwrt-feeds ../mtk-openwrt-feeds || true
cd mtk-openwrt-feeds
git checkout $MEDIATEK_FEED_BRANCH
cd $OPENWRT_DIR
git clone https://github.com/danpawlik/bpi-r4-mtk
# important
cp bpi-r4-mtk/my_files/rules mtk-openwrt-feeds/autobuild/unified/rules
sed -i 's/CONFIG_PACKAGE_perf=y/# CONFIG_PACKAGE_perf is not set/' \
./mtk-openwrt-feeds/autobuild/unified/filogic/mac80211/24.10/defconfig \
./mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release/mt7988_wifi7_mac80211_mlo/.config \
./mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release/mt7986_mac80211/.config
sed -i 's/CONFIG_PACKAGE_kmod-thermal=y/# CONFIG_PACKAGE_kmod-thermal is not set/' \
./mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release/mt7988_wifi7_mac80211_mlo/.config \
./mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release/mt7981_mac80211/.config \
./mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release/mt7986_mac80211/.config
cp bpi-r4-mtk/my_files/ethtool/Makefile package/network/utils/ethtool/Makefile
rm -f ./mtk-openwrt-feeds/autobuild/unified/global/24.10/patches-base/0007-package-network-ethtool-downgrade-to-version-6.7.patch || true
bash ../mtk-openwrt-feeds/autobuild/unified/autobuild.sh filogic-mac80211-mt7988_rfb-mt7996 prepare log_file=make
# cp bpi-r4-mtk/workarounds/0076-Comment-temporary-problematic-code.patch package/kernel/mt76/patches/
sed -i 's@/sbin/smp-mt76.sh@#/sbin/smp-mt76.sh@g' package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
sed -i 's@echo "Setup SMP Affinity"@#echo "Setup SMP Affinity"@g' package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
# curl -SL https://github.com/openwrt/mt76/commit/8088940ffd047a6d282a95af829562e8038f5b2d.patch | tee package/kernel/mt76/patches/0077-Yukariin-fix-wifi-power.patch
# curl -SL https://github.com/pmarques/openwrt/commit/47008eabacd48602d94ea0f3ba01fe2c79d70f81.patch | tee package/kernel/mt76/patches/0077-Yukariin-fix-wifi-power.patch
### another patch that will not ignore eeprom value
curl -SL https://github.com/openwrt/mt76/pull/968/commits/aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f.patch | tee package/kernel/mt76/patches/0077-im-0-fix-wifi-power.patch
#exit 1
git checkout package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 > .config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> .config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/snapshot >> .config
sed -i '/CONFIG_PACKAGE_wpad-mbedtls=y/d' .config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/openssl >> .config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/snapshot-mtk-feed >> .config
make defconfig
sed -i 's/CONFIG_PACKAGE_kmod-crypto-eip=y/# CONFIG_PACKAGE_kmod-crypto-eip is not set/g' .config
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
# workaround
# rm /home/user/openwrt-builder/openwrt-mediatek/target/linux/mediatek/patches-6.6/733-11-net-phy-add-driver-for-built-in-2.5G-ethernet-PHY-on.patch
# workaround
echo 'CONFIG_PINCTRL_MT7987=y' >> target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_COMMON_CLK_MT7987=y' >> target/linux/mediatek/filogic/config-6.6
make -j $(nproc) defconfig download world || true
make -j $(nproc) defconfig download world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment