b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | red='\e[0;31m' # 红色 |
| 4 | green='\e[0;32m' # 绿色 |
| 5 | NC='\e[0m' # 没有颜色 |
| 6 | |
| 7 | export STAGING_DIR= |
| 8 | DECONFIG_FILE= |
| 9 | |
| 10 | # glibc / musl |
b.liu | 5a480bd | 2025-05-26 11:32:52 +0800 | [diff] [blame] | 11 | GLIBC_NAME=glibc |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 12 | ASR_PROJECT_NAME= |
| 13 | ASR_PROJECT_PATCH= |
| 14 | |
| 15 | DIR_BUILD_TARGET=build_dir/target-arm_cortex-a7+neon-vfpv4_"$GLIBC_NAME"_eabi |
| 16 | DIR_STAGING_TARGET=staging_dir/target-arm_cortex-a7+neon-vfpv4_"$GLIBC_NAME"_eabi |
| 17 | DIR_BIN= |
| 18 | |
| 19 | versionFile='mbtk/include/mbtk_device_info.h' |
| 20 | version=`cat $versionFile | grep -w 'MBTK_DEVICES_REVISION' | cut -d '"' -f 2 ` |
| 21 | |
| 22 | usage() |
| 23 | { |
| 24 | echo "Usage : ./build.sh <clean/path>" |
| 25 | } |
| 26 | |
| 27 | function excmd() |
| 28 | { |
| 29 | echo -e "${green}Excmd:${NC} $@ ..." |
| 30 | # && sleep 1 |
| 31 | $@ |
| 32 | } |
| 33 | |
| 34 | function timediff() { |
| 35 | # time format:date +"%s.%N", such as 1502758855.907197692 |
| 36 | start_time=$1 |
| 37 | end_time=$2 |
| 38 | |
| 39 | start_s=${start_time%.*} |
| 40 | start_nanos=${start_time#*.} |
| 41 | end_s=${end_time%.*} |
| 42 | end_nanos=${end_time#*.} |
| 43 | |
| 44 | # end_nanos > start_nanos? |
| 45 | # Another way, the time part may start with 0, which means |
| 46 | # it will be regarded as oct format, use "10#" to ensure |
| 47 | # calculateing with decimal |
| 48 | |
| 49 | if [ "$end_nanos" -lt "$start_nanos" ];then |
| 50 | end_s=$(( 10#$end_s - 1 )) |
| 51 | end_nanos=$(( 10#$end_nanos + 10**9 )) |
| 52 | fi |
| 53 | |
| 54 | # get timediff |
| 55 | time=$(( 10#$end_s - 10#$start_s )).`printf "%03ds" $(( (10#$end_nanos - 10#$start_nanos)/10**6 ))` |
| 56 | time_min=$(((end_s - start_s)/60 + 1)) |
| 57 | echo -e "${green}*${NC} Spend time: "$time \(\~ ${time_min}min\) ${green}***${NC} |
| 58 | } |
| 59 | |
| 60 | init_check() |
| 61 | { |
| 62 | |
| 63 | if [ ! -f "config/$DECONFIG_FILE" ]; then |
| 64 | echo 'Must exec "init.sh" in the first.' |
| 65 | exit 1 |
| 66 | fi |
| 67 | |
| 68 | # if [ ! -f "../pack.sh" ]; then |
| 69 | # echo 'Must exec "init.sh" in the first.' |
| 70 | # exit 1 |
| 71 | # fi |
| 72 | |
| 73 | } |
| 74 | |
| 75 | build_init() |
| 76 | { |
| 77 | init_check |
| 78 | |
| 79 | if [ ! -d "feeds/" ]; then |
| 80 | echo "Start build inti..." |
| 81 | excmd ./scripts/feeds update -a |
| 82 | excmd ./scripts/feeds install -a |
| 83 | |
| 84 | echo "$DECONFIG_FILE" |
| 85 | |
| 86 | # if [ "$DECONFIG_FILE" == "defconfig_asr1803p401" ];then |
| 87 | # excmd make prereq |
| 88 | # fi |
| 89 | |
| 90 | #excmd make $DECONFIG_FILE |
| 91 | fi |
| 92 | |
| 93 | if [ -f .config ];then |
| 94 | rm .config |
| 95 | fi |
| 96 | |
| 97 | excmd make $DECONFIG_FILE |
| 98 | } |
| 99 | |
| 100 | copy_bin() |
| 101 | { |
| 102 | echo "Start copy bin..." |
| 103 | # [ -f $MBTK_DIR/out/bin/mbtk_audio_set ] && cp -f $MBTK_DIR/out/bin/mbtk_audio_set $MBTK_DIR/bin |
| 104 | [ -f $MBTK_DIR/../out/bin/device_info ] && cp -f $MBTK_DIR/../out/bin/device_info $MBTK_DIR/bin |
| 105 | } |
| 106 | |
| 107 | copy_lib() |
| 108 | { |
| 109 | echo "Start copy lib..." |
| 110 | [ -f $MBTK_DIR/../out/lib/liblynq_lib.so ] && cp -f $MBTK_DIR/../out/lib/liblynq_lib.so $MBTK_DIR/lib |
| 111 | # [ -f $MBTK_DIR/../out/lib/libql_lib.so.* ] && cp -f $MBTK_DIR/../out/lib/libql_lib.so.* $MBTK_DIR/lib |
| 112 | |
| 113 | ls $MBTK_DIR/../out/lib/libql_lib.so.* |
| 114 | if [ $? -eq 0 ];then |
| 115 | cp -f $MBTK_DIR/../out/lib/libql_lib.so.* $MBTK_DIR/lib |
| 116 | fi |
| 117 | |
| 118 | } |
| 119 | |
| 120 | ln_lib() |
| 121 | { |
| 122 | PWD_TEMP=`pwd` |
| 123 | |
| 124 | cd $ROOTFS_DIR/lib |
| 125 | if [ -f liblynq_lib.so ];then |
| 126 | [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so |
| 127 | [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so |
| 128 | [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so |
| 129 | [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so |
| 130 | [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so |
| 131 | [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so |
| 132 | [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so |
| 133 | [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so |
| 134 | [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so |
| 135 | [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so |
| 136 | [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so |
| 137 | [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so |
| 138 | [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so |
| 139 | [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so |
| 140 | [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so |
| 141 | [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so |
| 142 | fi |
| 143 | |
| 144 | cd $PWD_TEMP |
| 145 | } |
| 146 | |
| 147 | build_mbtk() |
| 148 | { |
| 149 | copy_toolchain |
| 150 | make -C mbtk/ || exit 1 |
| 151 | |
| 152 | ROOTFS_DIR=$DIR_BUILD_TARGET/root-mmp |
| 153 | MBTK_DIR=mbtk/rootfs |
| 154 | |
| 155 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 156 | # copy_lib |
| 157 | if [ -d $ROOTFS_DIR ];then |
| 158 | echo "Start build optee_test..." |
| 159 | [ -d mbtk/optee_test ] && make clean -C mbtk/optee_test && make -C mbtk/optee_test |
| 160 | echo "Should copy to mbtk/rootfs and build.sh if necessary." |
| 161 | fi |
| 162 | else |
| 163 | if [ -f staging_dir/host/bin/sstrip ];then |
| 164 | STRIP_FILE=./staging_dir/host/bin/sstrip |
| 165 | else |
| 166 | STRIP_FILE=./host/linux64/bin/sstrip |
| 167 | fi |
| 168 | |
| 169 | if [ ! -d $ROOTFS_DIR ];then |
| 170 | mkdir -p $ROOTFS_DIR |
| 171 | fi |
| 172 | |
| 173 | excmd cp -rf $MBTK_DIR/* $ROOTFS_DIR/ |
| 174 | |
| 175 | CUR_PWD=`pwd` |
| 176 | cd $ROOTFS_DIR/etc/rc.d |
| 177 | if [ ! -f S15mbtk_boot_normal -a -f ../init.d/mbtk_boot_normal ];then |
| 178 | ln -s ../init.d/mbtk_boot_normal S15mbtk_boot_normal |
| 179 | fi |
| 180 | if [ ! -f S98mbtk_boot_last -a -f ../init.d/mbtk_boot_last ];then |
| 181 | ln -s ../init.d/mbtk_boot_last S98mbtk_boot_last |
| 182 | fi |
| 183 | if [ ! -f S13mbtk_logd -a -f ../init.d/mbtk_logd ];then |
| 184 | ln -s ../init.d/mbtk_logd S13mbtk_logd |
| 185 | fi |
| 186 | |
hong.liu | fa3dc0a | 2025-06-30 17:30:59 +0800 | [diff] [blame] | 187 | if [ ! -f S12gsw_start -a -f ../init.d/gsw_start ];then |
| 188 | ln -s ../init.d/gsw_start S12gsw_start |
hong.liu | f024a69 | 2025-06-11 02:40:53 -0700 | [diff] [blame] | 189 | fi |
hong.liu | fa3dc0a | 2025-06-30 17:30:59 +0800 | [diff] [blame] | 190 | mv S10adbd S13adbd |
| 191 | mv S10dnsmasq S13dnsmasq |
| 192 | mv S10sdcard_mount S20sdcard_mount |
hong.liu | f024a69 | 2025-06-11 02:40:53 -0700 | [diff] [blame] | 193 | |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 194 | cd $CUR_PWD |
| 195 | |
| 196 | if [ -d $MBTK_DIR/lib_tmp ];then |
| 197 | rm -rf $MBTK_DIR/lib_tmp |
| 198 | fi |
| 199 | |
| 200 | if [ -d $MBTK_DIR/bin_tmp ];then |
| 201 | rm -rf $MBTK_DIR/bin_tmp |
| 202 | fi |
| 203 | |
| 204 | # copy_lib |
| 205 | |
| 206 | copy_bin |
| 207 | |
| 208 | cp -r $MBTK_DIR/lib $MBTK_DIR/lib_tmp |
| 209 | cp -r $MBTK_DIR/bin $MBTK_DIR/bin_tmp |
| 210 | |
| 211 | CROSS="arm-openwrt-linux-uclibcgnueabi-" NO_RENAME=1 ; NM="arm-openwrt-linux-uclibcgnueabi-nm" STRIP="$STRIP_FILE" STRIP_KMOD="./scripts/strip-kmod.sh" ./scripts/rstrip.sh $MBTK_DIR/lib_tmp |
| 212 | CROSS="arm-openwrt-linux-uclibcgnueabi-" NO_RENAME=1 ; NM="arm-openwrt-linux-uclibcgnueabi-nm" STRIP="$STRIP_FILE" STRIP_KMOD="./scripts/strip-kmod.sh" ./scripts/rstrip.sh $MBTK_DIR/bin_tmp |
| 213 | |
| 214 | cp $MBTK_DIR/lib_tmp/* $ROOTFS_DIR/lib |
| 215 | cp $MBTK_DIR/bin_tmp/* $ROOTFS_DIR/bin |
| 216 | rm -rf $MBTK_DIR/lib_tmp |
| 217 | rm -rf $MBTK_DIR/bin_tmp |
| 218 | |
| 219 | [ -f $ROOTFS_DIR/etc/init.d/wpad ] && rm $ROOTFS_DIR/etc/init.d/wpad |
| 220 | ln_lib |
| 221 | fi |
| 222 | } |
| 223 | |
| 224 | |
| 225 | build_mbtk_clean() |
| 226 | { |
| 227 | cd mbtk |
| 228 | make clean |
| 229 | cd .. |
| 230 | } |
| 231 | |
| 232 | build_rootfs() |
| 233 | { |
| 234 | if [ -f ./staging_dir/host/bin/mksquashfs4 ];then |
| 235 | EXEC=./staging_dir/host/bin/mksquashfs4 |
| 236 | else |
| 237 | EXEC=./host/linux64/bin/mksquashfs4 |
| 238 | fi |
| 239 | |
| 240 | $EXEC $DIR_BUILD_TARGET/root-mmp $DIR_BUILD_TARGET/linux-mmp_"$ASR_PROJECT_NAME"/root.squashfs -nopad -noappend -root-owned -comp xz -Xpreset 8 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -Xbcj arm -b 64k -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1' -processors 1 |
| 241 | excmd dd if=$DIR_BUILD_TARGET/linux-mmp_"$ASR_PROJECT_NAME"/root.squashfs of=$DIR_BIN/swd/openwrt-mmp-"$ASR_PROJECT_NAME"-root.squashfs |
| 242 | } |
| 243 | |
| 244 | copy_toolchain() |
| 245 | { |
| 246 | # 1806 |
| 247 | if [ ! -d mbtk/toolchain ];then |
| 248 | if [ ! -d owtoolchain/linux64 ];then |
| 249 | "Build all in the first." |
| 250 | exit 1 |
| 251 | fi |
| 252 | echo "Start Copy Build Toolchain..." |
| 253 | mkdir -p mbtk/toolchain |
| 254 | cp -r owtoolchain/linux64 mbtk/toolchain/ |
| 255 | cp -r mbtk/toolchain/linux64/include/* mbtk/toolchain/linux64/usr/include/ |
| 256 | cp -r $DIR_STAGING_TARGET/usr/* mbtk/toolchain/linux64/usr/ |
| 257 | cp -r mbtk/toolchain/linux64/usr/include/* mbtk/toolchain/linux64/include/ |
| 258 | cp -drf $DIR_BUILD_TARGET/audio/obj/olibs/* mbtk/toolchain/linux64/usr/lib/ |
| 259 | cp -r marvell/services/audio_if/include/* mbtk/toolchain/linux64/include/ |
b.liu | f7f2d6d | 2025-05-20 15:10:18 +0800 | [diff] [blame] | 260 | cp -r mbtk/rootfs/usr/lib/* mbtk/toolchain/linux64/usr/lib/ |
b.liu | de66b44 | 2025-05-15 15:17:48 +0800 | [diff] [blame] | 261 | |
| 262 | cp -r marvell/services/ril/include/* mbtk/toolchain/linux64/include/ |
| 263 | cp -r marvell/services/audio/include/* mbtk/toolchain/linux64/include/ |
| 264 | cp -r marvell/services/audio/include/stub/* mbtk/toolchain/linux64/include/ |
| 265 | cp -r marvell/services/audio/tinyalsa/include/* mbtk/toolchain/linux64/include/ |
| 266 | cp -r marvell/services/audio/libaudio-apu/*.h mbtk/toolchain/linux64/include/ |
| 267 | cp -r marvell/lte-telephony/apps/aud_sw/vcm_ipc/*.h mbtk/toolchain/linux64/include/ |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 268 | fi |
| 269 | |
| 270 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 271 | if [ -f mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -a ! -d mbtk/toolchain/gcc-arm-arm-none-linux-gnueabihf ];then |
| 272 | echo "Dec file : gcc-arm-none-linux-gnueabihf.tar.gz to mbtk/toolchain." |
| 273 | tar zxf mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -C mbtk/toolchain |
| 274 | fi |
| 275 | fi |
| 276 | } |
| 277 | |
| 278 | build_oem() |
| 279 | { |
| 280 | excmd mkdir -p $DIR_BUILD_TARGET/root-mmp/NVM/oem_data |
| 281 | excmd rm -rf $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs |
| 282 | excmd mkdir -p $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs |
| 283 | excmd cp -fpR target/linux/mmp/$ASR_PROJECT_NAME/oem_fs/* $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs/ |
| 284 | excmd staging_dir/host/bin/mkfs.ubifs -m 2048 -e 126976 -c 156 -F --space-fixup --compr=zlib -o $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubifs -d $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs |
| 285 | excmd mkdir -p $DIR_BIN/swd/ |
| 286 | if [ -e ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg ]; then |
| 287 | excmd cp -fpR ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg; |
| 288 | else |
| 289 | excmd cp -fpR ./target/linux/mmp/image/ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg; |
| 290 | fi |
| 291 | excmd cd $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME; |
| 292 | excmd sed -i 's/vol_size=.*KiB/vol_size=19344KiB/g' ubinize-oem.cfg; ../../../staging_dir/host/bin/ubinize -m 2048 -p 131072 -s 2048 -o ../../../$DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubi ubinize-oem.cfg |
| 293 | excmd cd ../../.. |
| 294 | excmd cp -fpR $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubi $DIR_BIN/swd/openwrt-mmp-$ASR_PROJECT_NAME-oem_data.ubi |
| 295 | } |
| 296 | |
| 297 | build_busybox() |
| 298 | { |
| 299 | if [ -d mbtk/busybox-1.36.1 ];then |
| 300 | CUR_PWD=`pwd` |
| 301 | cd mbtk/busybox-1.36.1 |
| 302 | [ -f busybox.config ] && cp busybox.config .config |
| 303 | make install |
| 304 | |
| 305 | if [ ! -d ../rootfs/bin ];then |
| 306 | mkdir ../rootfs/bin |
| 307 | fi |
| 308 | |
| 309 | if [ -f _install/bin/busybox ]; |
| 310 | then |
| 311 | cp -f _install/bin/busybox ../rootfs/bin |
| 312 | fi |
| 313 | |
| 314 | cd $CUR_PWD |
| 315 | fi |
| 316 | } |
| 317 | |
| 318 | build() |
| 319 | { |
| 320 | # 1806 |
| 321 | # if [ "$DECONFIG_FILE" == "defconfig_asr1806p301" ];then |
| 322 | excmd make $1/{clean,compile} V=99 2>&1 | tee build.log |
| 323 | # else |
| 324 | # excmd make $1/{clean,compile,install} V=99 2>&1 | tee build.log |
| 325 | # fi |
| 326 | } |
| 327 | |
| 328 | mbtk_version_update() |
| 329 | { |
| 330 | # SDK |
| 331 | if [ -f mbtk/mbtk_version ];then |
| 332 | PATCH_INDEX=`cat mbtk/mbtk_version | grep PATCH_INDEX | cut -d '=' -f 2` |
| 333 | if [ -z $PATCH_INDEX ];then |
| 334 | PATCH_INDEX=0 |
| 335 | fi |
| 336 | if [ $PATCH_INDEX -lt 10 ];then |
| 337 | PATCH_INDEX=00"$PATCH_INDEX" |
| 338 | else |
| 339 | if [ $PATCH_INDEX -lt 100 ];then |
| 340 | PATCH_INDEX=0"$PATCH_INDEX" |
| 341 | fi |
| 342 | fi |
| 343 | |
| 344 | # T108v05.02b01_YX.00 |
| 345 | MBTK_VERSION=${version#*:= } |
| 346 | MBTK_VERSION_1=`echo $MBTK_VERSION | cut -d '.' -f 1` |
| 347 | MBTK_VERSION_2=`echo $MBTK_VERSION | cut -d '.' -f 2` |
| 348 | MBTK_VERSION_3=`echo $MBTK_VERSION | cut -d '.' -f 3` |
| 349 | if [[ $MBTK_VERSION_3 == *_* ]];then # 有 '_' |
| 350 | MBTK_VERSION_3_1=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 1` |
| 351 | MBTK_VERSION_3_2=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 2` |
| 352 | |
| 353 | MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2."$PATCH_INDEX"_$MBTK_VERSION_3_2 |
| 354 | else |
| 355 | MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2.$PATCH_INDEX |
| 356 | fi |
| 357 | |
| 358 | echo "Version : $MBTK_VERSION" |
| 359 | sed -i "s/$version/$MBTK_VERSION/" $versionFile |
| 360 | fi |
| 361 | } |
| 362 | |
| 363 | build_menuconfig() |
| 364 | { |
| 365 | build_init |
| 366 | make menuconfig |
| 367 | |
| 368 | cp -f .config config/$DECONFIG_FILE |
| 369 | } |
| 370 | |
| 371 | config_init() |
| 372 | { |
| 373 | PROJECT=`cat build_version | grep -w 'PROJECT' | cut -d '=' -f 2` |
| 374 | # PYTHON_SUPPORT=`cat build_version | grep -w 'PYTHON_SUPPORT' | cut -d '=' -f 2` |
| 375 | SEC_SUPPORT=`cat build_version | grep -w 'SEC_SUPPORT' | cut -d '=' -f 2` |
| 376 | echo "PROJECT = $PROJECT" |
| 377 | # echo "PYTHON_SUPPORT = $PYTHON_SUPPORT" |
| 378 | echo "SEC_SUPPORT = $SEC_SUPPORT" |
| 379 | if [ "$PROJECT" == "L901CD-L" ];then |
| 380 | ASR_PROJECT_NAME=asr1903 |
| 381 | ASR_PROJECT_PATCH=p501 |
| 382 | elif [ "$PROJECT" == "T108" -o "$PROJECT" == "T108-2" -o "$PROJECT" == "L508_X6" ];then |
| 383 | ASR_PROJECT_NAME=asr1806 |
| 384 | ASR_PROJECT_PATCH=p301 |
| 385 | else |
| 386 | ASR_PROJECT_NAME=asr1803 |
| 387 | ASR_PROJECT_PATCH=p401 |
| 388 | fi |
| 389 | |
| 390 | DECONFIG_FILE=defconfig_$ASR_PROJECT_NAME$ASR_PROJECT_PATCH |
| 391 | |
| 392 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 393 | if [ "$GLIBC_NAME" == "glibc" ];then |
| 394 | DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec_glibc |
| 395 | else |
| 396 | DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec |
| 397 | fi |
| 398 | sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\CONFIG_PACKAGE_mbtk-rootfs=y" config/$DECONFIG_FILE |
| 399 | else |
| 400 | if [ "$GLIBC_NAME" == "glibc" ];then |
hong.liu | 0d54259 | 2025-06-05 16:21:58 +0800 | [diff] [blame] | 401 | DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"-glibc |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 402 | else |
| 403 | DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH" |
| 404 | fi |
| 405 | sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\# CONFIG_PACKAGE_mbtk-rootfs is not set" config/$DECONFIG_FILE |
| 406 | fi |
| 407 | } |
b.liu | de66b44 | 2025-05-15 15:17:48 +0800 | [diff] [blame] | 408 | |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 409 | toolchain_generate() |
| 410 | { |
| 411 | MBTK_TOOLCHAIN_DIR=mbtk_toolchain |
| 412 | |
| 413 | if [ ! -d mbtk/toolchain/linux64 ];then |
| 414 | echo "Build in the first." |
| 415 | exit 1 |
| 416 | fi |
| 417 | |
| 418 | [ -d $MBTK_TOOLCHAIN_DIR ] && rm -rf $MBTK_TOOLCHAIN_DIR |
| 419 | [ ! -d $MBTK_TOOLCHAIN_DIR ] && mkdir -p $MBTK_TOOLCHAIN_DIR |
| 420 | |
| 421 | echo "Start copy toolchain..." |
| 422 | cp -r mbtk/toolchain/linux64 $MBTK_TOOLCHAIN_DIR/toolchain |
| 423 | |
| 424 | echo "Start copy mbtk header files and libs..." |
| 425 | mkdir $MBTK_TOOLCHAIN_DIR/mbtk |
| 426 | cp -r mbtk/include $MBTK_TOOLCHAIN_DIR/mbtk |
| 427 | cp -r mbtk/rootfs/lib $MBTK_TOOLCHAIN_DIR/mbtk |
| 428 | |
| 429 | echo "Start copy mbtk config files..." |
| 430 | cp -r mbtk/mbtk_toolchain_config/* $MBTK_TOOLCHAIN_DIR |
| 431 | |
| 432 | echo "Delete unnecessary files..." |
| 433 | # rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/usr |
b.liu | f7f2d6d | 2025-05-20 15:10:18 +0800 | [diff] [blame] | 434 | [ -d $MBTK_TOOLCHAIN_DIR/toolchain/initial ] && rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/initial |
| 435 | [ -f $MBTK_TOOLCHAIN_DIR/toolchain/include.zip ] && rm $MBTK_TOOLCHAIN_DIR/toolchain/include.zip |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 436 | |
| 437 | echo "Start packaging toolchain..." |
| 438 | tar -zcf mbtk_toolchain.tar.gz mbtk_toolchain/ |
| 439 | |
| 440 | echo "Toolchain generate complete." |
| 441 | } |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 442 | |
| 443 | ################################################################ |
| 444 | ### Start ######## |
| 445 | ################################################################ |
| 446 | if [ ! -f build_version ];then |
| 447 | echo "No found file: build_version" |
| 448 | exit 1 |
| 449 | else |
| 450 | config_init |
| 451 | fi |
| 452 | |
| 453 | start=$(date +"%s.%N") |
| 454 | starttime=`date +"%Y-%m-%d %H:%M:%S"` |
| 455 | |
| 456 | ROOTFS_DIR="mbtk/rootfs" |
| 457 | ln_lib |
| 458 | |
| 459 | if [ -n "$1" ] ;then #有参数 |
| 460 | if [ ! -d "feeds/" -a "$1" != "menuconfig" ]; then |
| 461 | echo "Must make all in the first." |
| 462 | exit 1 |
| 463 | fi |
| 464 | |
| 465 | case "$1" in |
| 466 | clean) |
| 467 | # Can not remove toolchain. |
| 468 | # [ -d mbtk/toolchain ] && rm -rf mbtk/toolchain |
| 469 | excmd make distclean |
| 470 | ;; |
| 471 | kernel) |
| 472 | build target/linux |
| 473 | ;; |
| 474 | oem) |
| 475 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 476 | echo "No support." |
| 477 | else |
| 478 | build_oem |
| 479 | fi |
| 480 | ;; |
| 481 | obm) |
| 482 | excmd make package/boot/obm-mmp/{clean,compile} V=99 2>&1 | tee build.log |
| 483 | excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND.bin $DIR_BIN/swd |
| 484 | excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND_ProductBuild.bin $DIR_BIN/swd |
| 485 | ;; |
| 486 | uboot) |
| 487 | excmd make package/boot/uboot-mmp/{clean,compile} V=99 2>&1 | tee build.log |
| 488 | excmd cp -f $DIR_BIN/openwrt-mmp-"$ASR_PROJECT_NAME"-u-boot.bin $DIR_BIN/swd |
| 489 | ;; |
| 490 | ffmpeg) |
| 491 | build package/feeds/packages/ffmpeg |
| 492 | ;; |
| 493 | mbtk-rootfs) |
| 494 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 495 | excmd make package/$1/{clean,compile} V=99 2>&1 | tee build.log |
| 496 | else |
| 497 | echo "No support." |
| 498 | fi |
| 499 | ;; |
| 500 | openssl) |
| 501 | excmd make package/libs/$1/{clean,compile} V=99 2>&1 | tee build.log |
| 502 | ;; |
| 503 | mbtk) |
| 504 | build_mbtk |
| 505 | ;; |
| 506 | mbtk_clean) |
| 507 | build_mbtk_clean |
| 508 | ;; |
| 509 | rootfs) |
| 510 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 511 | echo "No support." |
| 512 | else |
| 513 | build_mbtk |
| 514 | build_rootfs |
| 515 | fi |
| 516 | ;; |
| 517 | lte) |
| 518 | build package/network/services/lte-telephony |
| 519 | ;; |
| 520 | audio) |
| 521 | build package/services/audio_if |
| 522 | ;; |
| 523 | fstools) |
| 524 | build package/system/fstools |
| 525 | ;; |
| 526 | ril) |
| 527 | build package/services/ril |
| 528 | ;; |
| 529 | gnss) |
| 530 | build package/services/gnss |
| 531 | ;; |
| 532 | libprop2uci) |
| 533 | build package/libs/libprop2uci |
| 534 | ;; |
| 535 | con_mgr) |
| 536 | build package/services/con_mgr |
| 537 | ;; |
| 538 | ecall) |
| 539 | build package/services/ecall_daemon |
| 540 | ;; |
| 541 | adbd) |
| 542 | build package/utils/adbd |
| 543 | ;; |
| 544 | menuconfig) |
| 545 | build_menuconfig |
| 546 | ;; |
| 547 | openssl) |
| 548 | excmd make package/libs/openssl/{clean,compile,install} V=99 2>&1 | tee build.log |
| 549 | ;; |
| 550 | busybox) |
| 551 | build_busybox |
| 552 | ;; |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 553 | toolchain) |
| 554 | toolchain_generate |
| 555 | ;; |
| 556 | optee) |
| 557 | build package/services/optee_app |
| 558 | ;; |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 559 | *) |
| 560 | SUB_DIR=`find package/ -type d -name "$1" | sed -n '1,1p'` |
| 561 | if [ x$SUB_DIR = x ] |
| 562 | then |
| 563 | echo -e "${red}==Have No module: $1==${NC}" |
| 564 | exit 1 |
| 565 | fi |
| 566 | echo -e "Build: ${green}${1}${NC} ${red}${SUB_DIR}${NC}" |
| 567 | build $SUB_DIR |
| 568 | ;; |
| 569 | esac |
| 570 | else # 全编 |
| 571 | |
| 572 | cp $versionFile $versionFile.backup |
| 573 | # Change version |
| 574 | mbtk_version_update |
| 575 | |
| 576 | # Start build. |
| 577 | excmd build_init |
| 578 | #if [ -d mbtk/toolchain ];then |
| 579 | # build_mbtk |
| 580 | #fi |
| 581 | # OPT_SEC=y |
| 582 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 583 | # build mbtk lib in the first. |
| 584 | build_mbtk |
lichengzhang | ac8cb00 | 2025-07-07 17:14:34 +0800 | [diff] [blame] | 585 | excmd make -j8 V=99 2>&1 | tee build.log |
| 586 | # excmd make OPT_SEC=y -j1 V=99 2>&1 | tee build.log |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 587 | else |
| 588 | excmd make -j8 V=99 2>&1 | tee build.log |
| 589 | fi |
| 590 | |
| 591 | mv $versionFile.backup $versionFile |
| 592 | |
| 593 | tail -n1 build.log | grep Error |
| 594 | if [ $? -eq "0" ]; then |
| 595 | echo "********************Build Fail*****************" |
| 596 | else |
| 597 | if [ "$SEC_SUPPORT" == "Y" ];then |
| 598 | echo "********************Build Success*****************" |
| 599 | else |
| 600 | echo "********************Build Success*****************" |
| 601 | copy_toolchain |
| 602 | build_busybox |
| 603 | build_mbtk |
| 604 | build_rootfs |
| 605 | fi |
| 606 | |
| 607 | # ./pack.sh all |
| 608 | fi |
| 609 | fi |
| 610 | excmd date >> build.log |
| 611 | end=$(date +"%s.%N") |
| 612 | endtime=`date +"%Y-%m-%d %H:%M:%S"` |
| 613 | |
| 614 | echo -e "${green}***********************************${NC}" |
| 615 | echo -e "${green}* ${NC}Start time: "$starttime ${green}*${NC} |
| 616 | echo -e "${green}* ${NC}End time: "$endtime ${green}*${NC} |
| 617 | timediff $start $end |
| 618 | echo -e "${green}***********************************${NC}" |