Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active January 1, 2026 17:11
Show Gist options
  • Select an option

  • Save danpawlik/c62c5772b181e9ab8c1cc57e15d00a13 to your computer and use it in GitHub Desktop.

Select an option

Save danpawlik/c62c5772b181e9ab8c1cc57e15d00a13 to your computer and use it in GitHub Desktop.
build image for BPI-R4 with Mediatek feed
#!/bin/bash
CURRENT_DIR=$(pwd)
# for 6.12 -> main, for 6.6 -> openwrt-24.10
# OPENWRT_BRANCH=openwrt-24.10
# If main, than: d6397aaf69fbb442f913b2853cac2991962ef905
OPENWRT_BRANCH=main
OPENWRT_DIR=$(pwd)/openwrt-mediatek
MEDIATEK_FEED_BRANCH=master
git clone https://github.com/openwrt/openwrt $OPENWRT_DIR -b $OPENWRT_BRANCH
cd $OPENWRT_DIR/
# Checkout for commit when 25.12; sometimes checkout also main branch when patch is in conflict
git checkout 8b93c563add283612700a5fac8191e1d79895143
./scripts/feeds update -a && ./scripts/feeds install -a
if [ -d "$CURRENT_DIR/mtk-openwrt-feeds-repo" ]; then
cp -a $CURRENT_DIR/mtk-openwrt-feeds-repo $OPENWRT_DIR/mtk-openwrt-feeds
cd $OPENWRT_DIR/mtk-openwrt-feeds
git reset --hard
git pull
cd $CURRENT_DIR
else
git clone https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds $OPENWRT_DIR/mtk-openwrt-feeds
fi
ln -s $OPENWRT_DIR/mtk-openwrt-feeds $CURRENT_DIR/mtk-openwrt-feeds || true
cd mtk-openwrt-feeds
git checkout $MEDIATEK_FEED_BRANCH
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 >> my-config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> my-config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/snapshot >> my-config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/sfp >> my-config
# add important packages
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/snapshot-mtk-feed >> my-config
sed -i '/CONFIG_PACKAGE_wpad-mbedtls=y/d' my-config
sed -i '/CONFIG_PACKAGE_qosify=y/d' my-config
sed -i '/CONFIG_PACKAGE_sqm-scripts=y/d' my-config
grep '^CONFIG_PACKAGE*' my-config >> autobuild/unified/filogic/master/defconfig
grep '^CONFIG_PACKAGE*' my-config >> autobuild/unified/filogic/25.12/defconfig
grep '^CONFIG_PACKAGE*' my-config >> autobuild/unified/filogic/24.10/defconfig
# NOTE: consider to uninstall nf-flow-netlink package before start like:
# + /home/user/openwrt-builder/openwrt-mediatek/scripts/feeds uninstall crypto-eip pce tops-tool
# That would fail because of nf-flow-netlink package, ignore. I want to have image with my packages
cd $OPENWRT_DIR
# keep openwrt bootloader; build image with BE14 support
# more: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/refs/heads/master/autobuild/unified/doc/MediaTek_OpenWrt_2512_User_Guide.md
bash ../mtk-openwrt-feeds/autobuild/unified/autobuild.sh filogic-mac80211-mt7988_rfb-mt7996 bootloader=0 log_file=make || true
# make a backup of a bin dir
mv bin/targets/mediatek bin/targets/mediatek-old || true
# it might fail because of missing nf-flow-netlink package, so remove it from requirements
find feeds -type f -exec sed -i 's/\+kmod-nf-flow-netlink//g' {} \;
sed -i 's/+kmod-nf-flow-netlink//g' feeds/mtk_openwrt_feed/feed/app/flowtable/Makefile
make -j$(nproc) world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment