developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # There are 2 env-variables set for you, you can use it in your script. |
| 4 | # ${BUILD_DIR} , working dir of this script, eg: openwrt/lede/ |
| 5 | # ${INSTALL_DIR}, where to install your build result, including: image, build log. |
| 6 | # |
| 7 | |
| 8 | #Global variable |
| 9 | BUILD_TIME=`date +%Y%m%d%H%M%S` |
| 10 | build_flag=0 |
| 11 | |
| 12 | if [ -z ${BUILD_DIR} ]; then |
| 13 | LOCAL=1 |
| 14 | BUILD_DIR=`pwd` |
| 15 | fi |
| 16 | |
| 17 | MTK_FEED_DIR=${BUILD_DIR}/feeds/mtk_openwrt_feed |
developer | 7273f5f | 2022-12-12 17:18:16 +0800 | [diff] [blame] | 18 | MTK_MANIFEST_FEED=${BUILD_DIR}/../mtk-openwrt-feeds |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 19 | |
| 20 | if [ -z ${INSTALL_DIR} ]; then |
| 21 | INSTALL_DIR=autobuild_release |
| 22 | mkdir -p ${INSTALL_DIR} |
| 23 | if [ ! -d target/linux ]; then |
| 24 | echo "You should call this scripts from openwrt's root directory." |
| 25 | fi |
| 26 | fi |
| 27 | |
| 28 | OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git packages" | awk -F ";openwrt" '{print $2}'` |
developer | 068e1a4 | 2022-08-29 17:24:20 +0800 | [diff] [blame] | 29 | if [ -z ${OPENWRT_VER} ]; then |
| 30 | OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git-full packages" | awk -F ";openwrt" '{print $2}'` |
| 31 | fi |
| 32 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 33 | cp ${BUILD_DIR}/feeds.conf.default ${BUILD_DIR}/feeds.conf.default_ori |
| 34 | |
| 35 | clean() { |
| 36 | echo "clean start!" |
| 37 | echo "It will take some time ......" |
| 38 | make distclean |
| 39 | rm -rf ${INSTALL_DIR} |
| 40 | echo "clean done!" |
| 41 | } |
| 42 | |
| 43 | do_patch(){ |
| 44 | files=`find $1 -name "*.patch" | sort` |
| 45 | for file in $files |
| 46 | do |
| 47 | patch -f -p1 -i ${file} || exit 1 |
| 48 | done |
| 49 | } |
| 50 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 51 | change_config_before_defconfig() { |
| 52 | return 0 |
| 53 | } |
| 54 | |
| 55 | change_config_after_defconfig() { |
| 56 | return 0 |
| 57 | } |
| 58 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 59 | prepare() { |
| 60 | echo "Preparing...." |
| 61 | #FIXME : workaround HOST PC build issue |
| 62 | #cd package/mtk/applications/luci-app-mtk/;git checkout Makefile;cd - |
| 63 | #mv package/mtk package/mtk_soc/ ./ |
| 64 | #rm -rf tmp/ feeds/ target/ package/ scripts/ tools/ include/ toolchain/ rules.mk |
| 65 | #git checkout target/ package/ scripts/ tools/ include/ toolchain/ rules.mk |
| 66 | #mv ./mtk ./mtk_soc/ package/ |
| 67 | cp ${BUILD_DIR}/autobuild/feeds.conf.default${OPENWRT_VER} ${BUILD_DIR}/feeds.conf.default |
| 68 | |
| 69 | #update feed |
| 70 | ${BUILD_DIR}/scripts/feeds update -a |
| 71 | |
| 72 | #check if manifest mtk_feed exist,if yes,overwrite and update it in feeds/ |
| 73 | if [ -d ${MTK_MANIFEST_FEED} ]; then |
| 74 | rm -rf ${MTK_FEED_DIR} |
| 75 | ln -s ${MTK_MANIFEST_FEED} ${MTK_FEED_DIR} |
| 76 | ${BUILD_DIR}/scripts/feeds update -a |
| 77 | fi |
| 78 | |
| 79 | #do mtk_feed prepare_sdk.sh |
| 80 | cp ${MTK_FEED_DIR}/prepare_sdk.sh ${BUILD_DIR} |
| 81 | |
| 82 | #if $1 exist(mt76), keep origin openwrt patches and remove mtk local eth driver |
| 83 | if [ -z ${1} ]; then |
| 84 | ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} || exit 1 |
| 85 | else |
| 86 | ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} ${1} || exit 1 |
| 87 | rm -rf ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/ |
| 88 | fi |
| 89 | #install feed |
| 90 | ${BUILD_DIR}/scripts/feeds install -a |
| 91 | ${BUILD_DIR}/scripts/feeds install -a luci |
| 92 | |
| 93 | #do mtk_soc openwrt patch |
| 94 | do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_soc || exit 1 |
| 95 | } |
| 96 | |
| 97 | add_proprietary_kernel_files() { |
| 98 | #cp mtk proprietary ko_module source to mtk target |
| 99 | #and also need to be done in release mtk target |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 100 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 101 | # mean it is old process for possible build issue and should delete it gradually in the furture. |
| 102 | if [ ! -d ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless/wifi_utility ]; then |
| 103 | mkdir -p ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless |
| 104 | cp -rf ${BUILD_DIR}/../ko_module/gateway/proprietary_driver/drivers/wifi_utility/ ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless |
| 105 | fi |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 106 | |
| 107 | cp -fpR ${BUILD_DIR}/autobuild/target/ ${BUILD_DIR} |
| 108 | } |
| 109 | |
| 110 | prepare_mtwifi() { |
| 111 | #remove officail OpenWRT wifi script |
| 112 | #wifi-profile pkg will install wifi_jedi instead |
| 113 | rm -rf ${BUILD_DIR}/package/base-files/files/sbin/wifi |
| 114 | |
| 115 | add_proprietary_kernel_files |
| 116 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 117 | #add common patch |
| 118 | cp -rfa ${BUILD_DIR}/autobuild/package ${BUILD_DIR} |
| 119 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 120 | #do mtk_wifi openwrt patch |
| 121 | do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_wifi || exit 1 |
| 122 | } |
| 123 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 124 | prepare_flowoffload() { |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 125 | #cp bridger and related utilities from master |
| 126 | cp -fpR ${BUILD_DIR}/./../mac80211_package/include/bpf.mk ${BUILD_DIR}/include |
| 127 | |
| 128 | cp -fpR ${BUILD_DIR}/./../mac80211_package/include/kernel-5.15 ${BUILD_DIR}/include |
| 129 | |
| 130 | cp -fpR ${BUILD_DIR}/./../mac80211_package/target/llvm-bpf ${BUILD_DIR}/target |
| 131 | |
| 132 | cp -fpR ${BUILD_DIR}/./../mac80211_package/tools/llvm-bpf ${BUILD_DIR}/tools |
| 133 | |
| 134 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/bpf-headers ${BUILD_DIR}/package/kernel |
| 135 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 136 | rm -rf ${BUILD_DIR}/package/network/utils/bpftool* |
| 137 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/bpftool ${BUILD_DIR}/package/network/utils |
| 138 | |
| 139 | rm -rf ${BUILD_DIR}/package/libs/libbpf |
| 140 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libbpf ${BUILD_DIR}/package/libs |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 141 | |
developer | 0d88998 | 2023-03-06 20:09:24 +0800 | [diff] [blame] | 142 | rm -rf ${BUILD_DIR}/package/network/utils/iproute2 |
| 143 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iproute2 ${BUILD_DIR}/package/network/utils |
| 144 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 145 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/bridger ${BUILD_DIR}/package/network/services |
| 146 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 147 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0010-add-llvm_bpf-toolchain.patch || exit 1 |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 148 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 149 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0004-2102-netfilter-remove-nf_flow_table_hw.patch || exit 1 |
| 150 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0005-add-netfilter-netlink-ftnl-package.patch || exit 1 |
developer | b809571 | 2023-03-25 08:27:43 +0800 | [diff] [blame] | 151 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 152 | #rm patches for flowblock |
| 153 | rm -rf ./target/linux/generic/pending-5.4/64*.patch |
| 154 | rm -rf ./target/linux/generic/hack-5.4/647-netfilter-flow-acct.patch |
| 155 | rm -rf ./target/linux/generic/hack-5.4/650-netfilter-add-xt_OFFLOAD-target.patch |
developer | ddea6d9 | 2023-06-05 10:57:49 +0800 | [diff] [blame] | 156 | rm -rf ./target/linux/mediatek/patches-5.4/999-2708-mtkhnat-add-support-for-virtual-interface-acceleration.patch |
developer | 14e96da | 2023-06-09 15:59:19 +0800 | [diff] [blame] | 157 | rm -rf ./target/linux/mediatek/patches-5.4/999-2726-mtkhnat-tnl-interface-offload-check.patch |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 158 | |
developer | c665c47 | 2023-08-25 15:29:31 +0800 | [diff] [blame] | 159 | # remove patches and packages of tops and ipsec |
developer | fc38914 | 2023-08-18 11:06:37 +0800 | [diff] [blame] | 160 | rm -rf ./target/linux/mediatek/patches-5.4/*mtk-tops*.patch |
developer | c665c47 | 2023-08-25 15:29:31 +0800 | [diff] [blame] | 161 | rm -rf ./target/linux/mediatek/patches-5.4/999-*xfrm*.patch |
| 162 | rm -rf ./target/linux/mediatek/patches-5.4/999-41*.patch |
| 163 | rm -rf ./target/linux/mediatek/patches-5.4/999-45*.patch |
developer | fc38914 | 2023-08-18 11:06:37 +0800 | [diff] [blame] | 164 | rm -rf ${BUILD_DIR}/package/kernel/tops |
developer | c665c47 | 2023-08-25 15:29:31 +0800 | [diff] [blame] | 165 | rm -rf ${BUILD_DIR}/package/kernel/crypto-eip |
| 166 | rm -rf ${BUILD_DIR}/package/kernel/pce |
developer | fc38914 | 2023-08-18 11:06:37 +0800 | [diff] [blame] | 167 | rm -rf ${BUILD_DIR}/package/feeds/mtk_openwrt_feed/tops-tool |
| 168 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 169 | #hack mt7988 config5.4 |
| 170 | echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 171 | echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 172 | echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 173 | echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 174 | echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 175 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 176 | #hack mt7986 config5.4 |
| 177 | echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 178 | echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 179 | echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 180 | echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 181 | echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 182 | |
developer | ee9d308 | 2023-11-14 06:07:42 +0800 | [diff] [blame] | 183 | #hack mt7981 config5.4 |
| 184 | echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 185 | echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 186 | echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 187 | echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 188 | echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 189 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 190 | #hack mt7622 config5.4 |
| 191 | echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
| 192 | echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
| 193 | echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 194 | echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
| 195 | echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 196 | } |
| 197 | |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 198 | prepare_mac80211() { |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 199 | rm -rf ${BUILD_DIR}/package/network/services/hostapd |
developer | 0443cd3 | 2023-09-19 14:11:49 +0800 | [diff] [blame] | 200 | if [ "$2" = "1" ]; then |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 201 | echo "========================Hostapd NEW===================" |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 202 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/hostapd ${BUILD_DIR}/package/network/services |
| 203 | rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd |
developer | 93607dd | 2023-08-30 04:53:00 +0800 | [diff] [blame] | 204 | cp -fpR ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd_new ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd |
| 205 | do_patch ${MTK_FEED_DIR}/autobuild_mac80211_release/openwrt_patches${OPENWRT_VER}/hostapd || exit 1 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 206 | else |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 207 | echo "========================Hostapd OLD===================" |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 208 | tar xvf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd/hostapd_v2.10_07730ff3.tar.gz -C ${BUILD_DIR}/package/network/services/ |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 209 | fi |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 210 | |
| 211 | rm -rf ${BUILD_DIR}/package/libs/libnl-tiny |
| 212 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libnl-tiny ${BUILD_DIR}/package/libs |
| 213 | |
| 214 | rm -rf ${BUILD_DIR}/package/network/utils/iw |
developer | bd32d6d | 2022-06-14 13:19:41 +0800 | [diff] [blame] | 215 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iw ${BUILD_DIR}/package/network/utils |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 216 | |
| 217 | rm -rf ${BUILD_DIR}/package/network/utils/iwinfo |
| 218 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iwinfo ${BUILD_DIR}/package/network/utils |
| 219 | |
developer | 3e0400f | 2023-02-10 08:32:03 +0800 | [diff] [blame] | 220 | rm -rf ${BUILD_DIR}/package/network/config/netifd |
developer | 0443cd3 | 2023-09-19 14:11:49 +0800 | [diff] [blame] | 221 | if [ "$2" = "1" ]; then |
developer | b31fa0a | 2023-09-19 06:32:06 +0800 | [diff] [blame] | 222 | echo "=========================Netifd NEW=====================" |
| 223 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/config/netifd ${BUILD_DIR}/package/network/config |
| 224 | rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/config/netifd |
| 225 | cp -fpR ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/config/netifd_new ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/config/netifd |
| 226 | else |
| 227 | echo "=========================Netifd OLD=====================" |
| 228 | fi |
| 229 | |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 230 | rm -rf ${BUILD_DIR}/package/utils/ucode |
| 231 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/utils/ucode ${BUILD_DIR}/package/utils |
| 232 | rm -rf ${BUILD_DIR}/package/libs/libubox |
| 233 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libubox ${BUILD_DIR}/package/libs |
| 234 | rm -rf ${BUILD_DIR}/package/system/rpcd |
| 235 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/rpcd ${BUILD_DIR}/package/system |
| 236 | rm -rf ${BUILD_DIR}/package/system/procd |
| 237 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/procd ${BUILD_DIR}/package/system |
developer | 3e0400f | 2023-02-10 08:32:03 +0800 | [diff] [blame] | 238 | |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 239 | rm -rf ${BUILD_DIR}/package/kernel/mac80211 |
developer | 0443cd3 | 2023-09-19 14:11:49 +0800 | [diff] [blame] | 240 | if [ "$1" = "1" ]; then |
developer | 7273f5f | 2022-12-12 17:18:16 +0800 | [diff] [blame] | 241 | echo "=========================MAC80211 v6.1===================" |
| 242 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mac80211 ${BUILD_DIR}/package/kernel |
| 243 | rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211 |
developer | 93607dd | 2023-08-30 04:53:00 +0800 | [diff] [blame] | 244 | cp -fpR ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211_dev ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211 |
developer | 7273f5f | 2022-12-12 17:18:16 +0800 | [diff] [blame] | 245 | else |
| 246 | echo "=========================MAC80211 v5.15==================" |
| 247 | tar xvf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211/mac80211_v5.15.81_077622a1.tar.gz -C ${BUILD_DIR}/package/kernel/ |
| 248 | fi |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 249 | |
| 250 | rm -rf ${BUILD_DIR}/package/firmware/wireless-regdb |
developer | bd32d6d | 2022-06-14 13:19:41 +0800 | [diff] [blame] | 251 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/firmware/wireless-regdb ${BUILD_DIR}/package/firmware |
developer | 7b9aeab | 2022-06-13 11:31:33 +0800 | [diff] [blame] | 252 | |
developer | a18966d | 2022-12-22 14:26:02 +0800 | [diff] [blame] | 253 | # do not directly remove mt76 folder, since the firmware folder will also be removed and enter an unsync state |
developer | 3e0400f | 2023-02-10 08:32:03 +0800 | [diff] [blame] | 254 | rm -rf ${BUILD_DIR}/package/kernel/mt76/Makefile |
| 255 | rm -rf ${BUILD_DIR}/package/kernel/mt76/patches |
| 256 | rm -rf ${BUILD_DIR}/package/kernel/mt76/src |
| 257 | cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mt76 ${BUILD_DIR}/package/kernel |
developer | f0de14b | 2022-12-14 23:07:34 +0800 | [diff] [blame] | 258 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 259 | # hack hostapd config |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 260 | echo "CONFIG_MBO=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 261 | echo "CONFIG_SAE_PK=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 262 | echo "CONFIG_TESTING_OPTIONS=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 263 | echo "CONFIG_HS20=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 264 | echo "CONFIG_P2P_MANAGER=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 265 | echo "CONFIG_WPS_UPNP=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 266 | echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 267 | echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 268 | echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/hostapd-full.config |
| 269 | echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config |
| 270 | echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config |
| 271 | echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 272 | # add configuration for STA wireless mode setting |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 273 | echo "CONFIG_HE_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config |
| 274 | echo "CONFIG_EHT_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 275 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 276 | # hack mt7988 config5.4 |
| 277 | echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 278 | echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 279 | echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 280 | echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 281 | echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 282 | echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 283 | echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 284 | echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 285 | echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7988/config-5.4 |
| 286 | |
| 287 | # hack mt7986 config5.4 |
| 288 | echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 289 | echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 290 | echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 291 | echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 292 | echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 293 | echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 294 | echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 295 | echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 296 | echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7986/config-5.4 |
| 297 | |
developer | e3cb300 | 2023-11-13 09:59:22 +0800 | [diff] [blame] | 298 | # hack mt7981 config5.4 |
| 299 | echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 300 | echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 301 | echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 302 | echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 303 | echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 304 | echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 305 | echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 306 | echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 307 | echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7981/config-5.4 |
| 308 | |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 309 | # hack mt7622 config5.4 |
| 310 | echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7622/config-5.4 |
| 311 | |
developer | 2468486 | 2023-08-02 08:10:38 +0800 | [diff] [blame] | 312 | # MAC80211/Hostapd Script |
developer | 0443cd3 | 2023-09-19 14:11:49 +0800 | [diff] [blame] | 313 | if [ "$1" = "1" ]; then |
developer | 2468486 | 2023-08-02 08:10:38 +0800 | [diff] [blame] | 314 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1 |
| 315 | else |
| 316 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1 |
| 317 | fi |
| 318 | |
| 319 | # Hostapd Makefile |
developer | 0443cd3 | 2023-09-19 14:11:49 +0800 | [diff] [blame] | 320 | if [ "$2" = "1" ]; then |
developer | 2468486 | 2023-08-02 08:10:38 +0800 | [diff] [blame] | 321 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0002-wifi7-hostapd-makefile-for-utils.patch || exit 1 |
| 322 | else |
| 323 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0002-wifi6-hostapd-makefile-for-utils.patch || exit 1 |
| 324 | fi |
| 325 | |
| 326 | # MT76 Makefile |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 327 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0003-master-mt76-makefile-for-new-chip.patch || exit 1 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 328 | cp -rfa ${MTK_FEED_DIR}/autobuild_mac80211_release/package/ ${BUILD_DIR} |
developer | 73b9312 | 2022-04-19 23:16:58 +0800 | [diff] [blame] | 329 | cp -rfa ${MTK_FEED_DIR}/autobuild_mac80211_release/target/ ${BUILD_DIR} |
developer | 6a02762 | 2023-08-29 06:38:24 +0800 | [diff] [blame] | 330 | |
| 331 | # Bridge Default Setting |
| 332 | patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0006-network-enable-bridge-igmp_snooping-by-default.patch || exit 1 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 333 | } |
| 334 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 335 | copy_main_Config() { |
| 336 | echo cp -rfa autobuild/$1/.config ./.config |
| 337 | cp -rfa autobuild/$1/.config ./.config |
| 338 | } |
| 339 | |
| 340 | install_output_Image() { |
| 341 | mkdir -p ${INSTALL_DIR}/$1 |
| 342 | |
| 343 | files=`find bin/targets/$3/*${2}* -name "*.bin" -o -name "*.img"` |
| 344 | file_count=0 |
| 345 | |
| 346 | for file in $files |
| 347 | do |
| 348 | tmp=${file%.*} |
| 349 | cp -rf $file ${INSTALL_DIR}/$1/${tmp##*/}-${BUILD_TIME}.${file##*.} |
| 350 | ((file_count++)) |
| 351 | done |
| 352 | |
| 353 | if [ ${file_count} = 0 ]; then |
| 354 | if [ ${build_flag} -eq 0 ]; then |
| 355 | let build_flag+=1 |
| 356 | echo " Restart to debug-build with "make V=s -j1", starting......" |
| 357 | build $1 -j1 || [ "$LOCAL" != "1" ] |
| 358 | else |
| 359 | echo " **********Failed to build $1, bin missing.**********" |
| 360 | fi |
| 361 | else |
| 362 | echo "Install image OK!!!" |
| 363 | echo "Build $1 successfully!" |
| 364 | fi |
| 365 | } |
| 366 | |
| 367 | install_output_Config() { |
| 368 | echo cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config |
| 369 | cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config |
| 370 | [ -f tmp/kernel.config ] && cp tmp/kernel.config ${INSTALL_DIR}/$1/kernel.config |
| 371 | } |
| 372 | |
| 373 | install_output_KernelDebugFile() { |
| 374 | KernelDebugFile=bin/targets/$3/mt${2}*/kernel-debug.tar.bz2 |
| 375 | if [ -f ${KernelDebugFile} ]; then |
| 376 | echo cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.bz2 |
| 377 | cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.bz2 |
| 378 | fi |
| 379 | } |
| 380 | |
| 381 | install_output_RootfsDebugFile() { |
| 382 | STAGING_DIR_ROOT=$(make -f "autobuild/get_stagingdir_root.mk" get-staging-dir-root) |
| 383 | if [ -d ${STAGING_DIR_ROOT} ]; then |
| 384 | STAGING_DIR_ROOT_PREFIX=$(dirname ${STAGING_DIR_ROOT}) |
| 385 | STAGING_DIR_ROOT_NAME=$(basename ${STAGING_DIR_ROOT}) |
| 386 | echo "tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C \"$STAGING_DIR_ROOT_PREFIX\" \"$STAGING_DIR_ROOT_NAME\"" |
| 387 | tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C "$STAGING_DIR_ROOT_PREFIX" "$STAGING_DIR_ROOT_NAME" |
| 388 | fi |
| 389 | } |
| 390 | |
| 391 | install_output_feeds_buildinfo() { |
| 392 | feeds_buildinfo=$(find bin/targets/$3/*${2}*/ -name "feeds.buildinfo") |
| 393 | echo "feeds_buildinfo=$feeds_buildinfo" |
| 394 | if [ -f ${feeds_buildinfo} ]; then |
| 395 | cp -rf $feeds_buildinfo ${INSTALL_DIR}/$1/feeds.buildinfo |
| 396 | else |
| 397 | echo "feeds.buildinfo is not found!!!" |
| 398 | fi |
| 399 | } |
| 400 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 401 | install_output_at() { |
developer | 3e0400f | 2023-02-10 08:32:03 +0800 | [diff] [blame] | 402 | tar -zcvf to_at.tgz -C ${INSTALL_DIR}/$1 . |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 403 | mv to_at.tgz ${INSTALL_DIR}/ |
| 404 | } |
| 405 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 406 | install_release() { |
| 407 | temp=${1#*mt} |
developer | dbcd2cb | 2023-06-06 13:28:00 +0800 | [diff] [blame] | 408 | if [ -z ${chip_name} ]; then |
| 409 | chip_name=${temp:0:4} |
| 410 | fi |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 411 | temp1=`grep "CONFIG_TARGET_ramips=y" autobuild/$1/.config` |
| 412 | |
| 413 | if [ "${temp1}" == "CONFIG_TARGET_ramips=y" ]; then |
| 414 | arch_name="ramips" |
| 415 | else |
| 416 | arch_name="mediatek" |
| 417 | fi |
| 418 | |
| 419 | #install output image |
| 420 | install_output_Image $1 ${chip_name} ${arch_name} |
| 421 | |
| 422 | #install output config |
| 423 | install_output_Config $1 |
| 424 | |
| 425 | #install output Kernel-Debug-File |
| 426 | install_output_KernelDebugFile $1 ${chip_name} ${arch_name} |
| 427 | |
| 428 | #tar unstripped rootfs for debug symbols |
| 429 | install_output_RootfsDebugFile $1 |
| 430 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 431 | #install output feeds buildinfo |
| 432 | install_output_feeds_buildinfo $1 ${chip_name} ${arch_name} |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | prepare_final() { |
| 436 | #cp customized autobuild SDK patches |
| 437 | cp -fpR ${BUILD_DIR}/autobuild/$1/target/ ${BUILD_DIR} |
| 438 | cp -fpR ${BUILD_DIR}/autobuild/$1/package/ ${BUILD_DIR} |
developer | 7273f5f | 2022-12-12 17:18:16 +0800 | [diff] [blame] | 439 | cp -fpR ${BUILD_DIR}/autobuild/$1/tools/ ${BUILD_DIR} |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 440 | |
| 441 | |
| 442 | #cp special subtarget patches |
| 443 | case $1 in |
| 444 | mt7986*) |
| 445 | cp -rf ${BUILD_DIR}/autobuild/mt7986-AX6000/target/linux/mediatek/patches-5.4/*.* ${BUILD_DIR}/target/linux/mediatek/patches-5.4 |
| 446 | ;; |
| 447 | *) |
| 448 | ;; |
| 449 | esac |
| 450 | |
| 451 | #rm old legacy patch, ex old nfi nand driver |
| 452 | case $1 in |
| 453 | mt7986*|\ |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 454 | mt7981*|\ |
| 455 | mt7988*) |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 456 | rm -rf ${BUILD_DIR}/target/linux/mediatek/patches-5.4/0303-mtd-spinand-disable-on-die-ECC.patch |
| 457 | ;; |
| 458 | *) |
| 459 | ;; |
| 460 | esac |
| 461 | |
| 462 | cd ${BUILD_DIR} |
| 463 | [ -f autobuild/$1/.config ] || { |
| 464 | echo "unable to locate autobuild/$1/.config !" |
| 465 | return |
| 466 | } |
| 467 | |
| 468 | rm -rf ./tmp |
| 469 | #copy main test config(.config) |
| 470 | copy_main_Config $1 |
| 471 | |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 472 | change_config_before_defconfig |
| 473 | |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 474 | echo make defconfig |
| 475 | make defconfig |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame] | 476 | |
| 477 | change_config_after_defconfig |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | build() { |
| 481 | echo "###############################################################################" |
| 482 | echo "# $1" |
| 483 | echo "###############################################################################" |
| 484 | echo "build $1" |
| 485 | |
| 486 | cd ${BUILD_DIR} |
| 487 | |
developer | 9b3248d | 2022-07-06 00:44:05 +0800 | [diff] [blame] | 488 | #make |
| 489 | |
| 490 | echo "make V=s -j $(($(nproc) + 1)) download world" |
| 491 | make V=s -j $(($(nproc) + 1)) download world || exit 1 |
| 492 | |
| 493 | #tar unstripped rootfs for debug symbols |
| 494 | install_release $1 |
| 495 | } |
| 496 | |
| 497 | build_log() { |
| 498 | echo "###############################################################################" |
| 499 | echo "# $1" |
| 500 | echo "###############################################################################" |
| 501 | echo "build $1" |
| 502 | |
| 503 | cd ${BUILD_DIR} |
| 504 | |
| 505 | #make |
| 506 | |
| 507 | echo "make V=s -j $(($(nproc) + 1)) download world" |
| 508 | make V=s -j $(($(nproc) + 1)) download world || make V=s -j1 || exit 1 |
developer | 20d6771 | 2022-03-02 14:09:32 +0800 | [diff] [blame] | 509 | |
| 510 | #tar unstripped rootfs for debug symbols |
| 511 | install_release $1 |
| 512 | } |