Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active November 12, 2025 10:48
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=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/
./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
cd $OPENWRT_DIR
git clone https://github.com/danpawlik/bpi-r4-mtk
# important
# Probably same as
# sed -i 's/apply_autobuild_script_patch modify_feeds_conf update_feeds/apply_autobuild_script_patch update_feeds/g' mtk-openwrt-feeds/autobuild/unified/rules
cp bpi-r4-mtk/my_files/rules mtk-openwrt-feeds/autobuild/unified/rules
bash ../mtk-openwrt-feeds/autobuild/unified/autobuild.sh filogic-mac80211-mt7988_rfb-mt7996 prepare log_file=make
# do not create example wireless
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
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/sfp >>.config
sed -i '/CONFIG_PACKAGE_wpad-mbedtls=y/d' .config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/snapshot-mtk-feed >>.config
# There is HW QoS so no need to set sqm or qosify
sed -i '/CONFIG_PACKAGE_qosify=y/d' .config
sed -i '/CONFIG_PACKAGE_sqm-scripts=y/d' .config
# workaround for kernel compilation
# 6.6
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
echo 'CONFIG_VIRTIO_BLK=n' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_VIRTIO_NET=n' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_REMOTEPROC_CDEV=n' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_MTK_SCP=n' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_MEDIATEK_2P5GE_PHY=y' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_MEDIATEK_NETSYS_V2=y' >>target/linux/mediatek/filogic/config-6.6
echo 'CONFIG_MEDIATEK_NETSYS_V3=y' >>target/linux/mediatek/filogic/config-6.6
# 6.12
echo 'CONFIG_PINCTRL_MT7987=y' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_COMMON_CLK_MT7987=y' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_VIRTIO_BLK=n' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_VIRTIO_NET=n' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_REMOTEPROC_CDEV=n' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_MTK_SCP=n' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_MEDIATEK_2P5GE_PHY=y' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_MEDIATEK_NETSYS_V2=y' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_MEDIATEK_NETSYS_V3=y' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_NSM=n' >>target/linux/mediatek/filogic/config-6.12
echo 'CONFIG_VIRTIO_DEBUG=n' >>target/linux/mediatek/filogic/config-6.12
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
#sed -i '/CONFIG_EXTRA_FIRMWARE/d' target/linux/mediatek/filogic/config-6.6
#sed -i '/CONFIG_EXTRA_FIRMWARE_DIR/d' target/linux/mediatek/filogic/config-6.6
#sed -i 's/# CONFIG_PACKAGE_kmod-phy-airoha-en8811h is not set/CONFIG_PACKAGE_kmod-phy-airoha-en8811h=y/g' .config
# golang/node issue workaround
# curl -SL https://raw.githubusercontent.com/openwrt/packages/refs/heads/master/lang/golang/golang/Makefile > package/feeds/packages/golang/Makefile
# curl -SL https://raw.githubusercontent.com/openwrt/packages/0a512e8f0eeb474d8b7f93a5eb73792ce7f4247a/lang/node/Makefile > package/feeds/packages/node/Makefile
make -j $(nproc) defconfig download world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment