liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
b.liu | 575a0f1 | 2024-12-19 20:08:45 +0800 | [diff] [blame] | 3 | if [ ! -f config ];then |
| 4 | echo "Exec init.sh in the first." |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
b.liu | a35c333 | 2025-08-15 21:07:02 +0800 | [diff] [blame] | 8 | function mbtk_toolchain_download() |
| 9 | { |
| 10 | MBTK_TOOLCHAIN_DIR=~/openwrt_toolchains |
| 11 | |
| 12 | # git clone "ssh://b.liu@192.168.1.198:29418/ASR1803_openwrt_mbtk_source" mbtk_source && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg "mbtk_source/.git/hooks/" |
| 13 | GIT_URL=`grep "url" .git/config | cut -d " " -f 3 | \ |
| 14 | sed "s/ASR1803_openwrt_mbtk_source/mbtk_toolchains_for_asr_linux/"` |
| 15 | |
| 16 | GIT_IP=`echo $GIT_URL | cut -d ":" -f 2` |
| 17 | GIT_IP=${GIT_IP: 2} |
| 18 | GIT_PORT=`echo $GIT_URL | cut -d "/" -f 3 | cut -d ":" -f 2` |
| 19 | |
| 20 | if [ ! -d $MBTK_TOOLCHAIN_DIR ];then |
| 21 | echo "Start download toolchains." |
| 22 | # git clone "ssh://b.liu@192.168.1.198:29418/mbtk_toolchains_for_asr_linux" ~/openwrt_toolchains && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg ~/openwrt_toolchains/.git/hooks/ |
| 23 | git clone "$GIT_URL" $MBTK_TOOLCHAIN_DIR && scp -p -P $GIT_PORT $GIT_IP:hooks/commit-msg "$MBTK_TOOLCHAIN_DIR/.git/hooks/" |
| 24 | fi |
| 25 | } |
| 26 | |
| 27 | mbtk_toolchain_download |
b.liu | a6a2bd1 | 2025-08-14 12:14:58 +0800 | [diff] [blame] | 28 | |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 29 | # static / shared |
| 30 | export BUILD_LIB_TYPE=shared |
b.liu | 450e399 | 2024-10-10 10:59:29 +0800 | [diff] [blame] | 31 | |
| 32 | export STAGING_DIR= |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 33 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 34 | ROOT_DIR=`pwd` |
| 35 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 36 | BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2` |
| 37 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 38 | export BUILD_STD_LIBC=musl |
| 39 | else |
| 40 | export BUILD_STD_LIBC=glibc |
| 41 | fi |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 42 | |
b.liu | deb8e42 | 2024-12-14 17:36:56 +0800 | [diff] [blame] | 43 | export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2` |
| 44 | |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 45 | #export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2` |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 46 | export CONFIG_MBTK_5G_SUPPORT=`cat config | grep CONFIG_MBTK_5G_SUPPORT | cut -d '=' -f 2` |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 47 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 48 | if [ -n "$1" ] ;then |
| 49 | case "$1" in |
| 50 | v1) |
| 51 | export MBTK_SOURCE_VERSION=1 |
| 52 | ;; |
| 53 | v2) |
| 54 | export MBTK_SOURCE_VERSION=2 |
| 55 | ;; |
| 56 | *) |
| 57 | MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2` |
| 58 | if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then |
| 59 | export MBTK_SOURCE_VERSION=2 |
| 60 | else |
| 61 | export MBTK_SOURCE_VERSION=1 |
| 62 | fi |
| 63 | esac |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 64 | else |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 65 | MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2` |
| 66 | if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then |
| 67 | export MBTK_SOURCE_VERSION=2 |
| 68 | else |
| 69 | export MBTK_SOURCE_VERSION=1 |
| 70 | fi |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 71 | fi |
| 72 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 73 | function build() |
| 74 | { |
| 75 | cd mbtk |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 76 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 77 | if [ -n "$1" ] ;then |
| 78 | case "$1" in |
| 79 | clean) |
| 80 | make clean |
| 81 | ;; |
| 82 | *) |
b.liu | 8f67dfb | 2023-11-27 11:27:51 +0800 | [diff] [blame] | 83 | # exit 1;; |
| 84 | make -C $1 |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 85 | esac |
| 86 | else # 无参数 |
| 87 | make || exit 1 |
| 88 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 89 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 90 | cd $ROOT_DIR |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 91 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 92 | echo "Build MBTK success." |
| 93 | } |
| 94 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 95 | function copy_bin_and_lib() |
| 96 | { |
| 97 | # Copy All SO Files. |
b.liu | 883991f | 2024-11-29 19:44:56 +0800 | [diff] [blame] | 98 | # cp -f mbtk/libmbtk_lib/wifi/libs out/lib |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 99 | cp -f out/lib/* $1/lib |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 100 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 101 | # Copy All Bin Files. |
| 102 | #cp -f out/bin/* $1/bin |
| 103 | [ -f out/bin/at ] && cp -f out/bin/at $1/bin |
| 104 | [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin |
b.liu | fc2bdb8 | 2024-11-30 17:24:34 +0800 | [diff] [blame] | 105 | [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 106 | [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin |
| 107 | [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin |
| 108 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin |
| 109 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/.. |
| 110 | [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/.. |
| 111 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin |
| 112 | [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin |
| 113 | [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin |
| 114 | [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 115 | [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin |
b.liu | 047a21c | 2024-06-07 17:54:41 +0800 | [diff] [blame] | 116 | [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin |
b.liu | 717dc08 | 2024-06-20 10:51:49 +0800 | [diff] [blame] | 117 | [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 118 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
b.liu | 3bf26ca | 2024-12-23 19:03:57 +0800 | [diff] [blame] | 119 | [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin |
b.liu | a76c961 | 2025-03-28 13:58:09 +0800 | [diff] [blame] | 120 | [ -f out/bin/mbtk_otad ] && cp -f out/bin/mbtk_otad $1/bin |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 121 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 122 | # Copy GNSS(5311) bin files. |
| 123 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 124 | [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 125 | } |
| 126 | |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame] | 127 | function copy_factory_files() |
| 128 | { |
| 129 | # Copy All SO Files. |
| 130 | # cp -f mbtk/libmbtk_lib/wifi/libs out/lib |
| 131 | cp -f out/lib/* $1/lib |
| 132 | |
| 133 | # Copy All Bin Files. |
| 134 | #cp -f out/bin/* $1/bin |
| 135 | [ -f out/bin/at ] && cp -f out/bin/at $1/bin |
| 136 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/.. |
b.liu | 6339dca | 2025-02-20 17:47:23 +0800 | [diff] [blame] | 137 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin |
| 138 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame] | 139 | [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin |
| 140 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
| 141 | |
| 142 | # Copy GNSS(5311) bin files. |
| 143 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 144 | [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc |
| 145 | } |
| 146 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 147 | function file_copy() |
| 148 | { |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 149 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 150 | |
| 151 | if [ -d $ROOTFS_DIR ];then |
| 152 | echo "Copy MBTK out files..." |
| 153 | if [ ! -d $ROOTFS_DIR/bin ];then |
| 154 | mkdir $ROOTFS_DIR/bin |
| 155 | fi |
| 156 | if [ ! -d $ROOTFS_DIR/lib ];then |
| 157 | mkdir $ROOTFS_DIR/lib |
| 158 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 159 | |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame] | 160 | copy_factory_files $ROOTFS_DIR |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 161 | else |
| 162 | echo "No found rootfs : $ROOTFS_DIR" |
| 163 | fi |
| 164 | } |
| 165 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 166 | function temp_mbtk_copy() |
| 167 | { |
| 168 | TEMP_MBTK_DIR=$ROOT_DIR/../temp_open |
| 169 | if [ -d $TEMP_MBTK_DIR ];then |
| 170 | rm -rf $TEMP_MBTK_DIR |
| 171 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 172 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 173 | mkdir -p $TEMP_MBTK_DIR/mbtk/include |
| 174 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin |
| 175 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib |
b.liu | 76541c9 | 2024-07-02 11:37:37 +0800 | [diff] [blame] | 176 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 177 | mkdir -p $TEMP_MBTK_DIR/mbtk/test |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 178 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 179 | copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 180 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 181 | # Copy include file. |
| 182 | if [ -d mbtk/include ];then |
| 183 | cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include |
| 184 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 185 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 186 | # Copy test source. |
| 187 | if [ -d mbtk/test ];then |
| 188 | cope_file="mbtk/test/*" |
| 189 | files=$(ls $cope_file 2> /dev/null | wc -l) |
| 190 | if [ "$files" != "0" ] ;then #如果存在文件 |
| 191 | cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test |
| 192 | fi |
| 193 | fi |
| 194 | } |
| 195 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 196 | function print_arg() |
| 197 | { |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 198 | echo BUILD_STD_LIBC=$BUILD_STD_LIBC |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 199 | echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 200 | # echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 201 | } |
| 202 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 203 | function main() |
| 204 | { |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 205 | if [ ! -d out/lib ];then |
| 206 | mkdir -p out/lib |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 207 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 208 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 209 | if [ ! -d out/bin ];then |
| 210 | mkdir -p out/bin |
| 211 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 212 | |
b.liu | deb8e42 | 2024-12-14 17:36:56 +0800 | [diff] [blame] | 213 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 214 | [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so |
| 215 | else |
| 216 | [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so |
| 217 | fi |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 218 | |
| 219 | if [ -n "$1" ] ;then |
| 220 | if [ "$1" == "v1" -o "$1" == "v2" ];then |
| 221 | build clean |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 222 | |
| 223 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 224 | else |
| 225 | build $1 |
| 226 | exit 0 |
| 227 | fi |
| 228 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 229 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 230 | if [ ! -d out/lib ];then |
| 231 | mkdir -p out/lib |
| 232 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 233 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 234 | if [ ! -d out/bin ];then |
| 235 | mkdir -p out/bin |
| 236 | fi |
| 237 | |
| 238 | build |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 239 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 240 | print_arg |
| 241 | |
| 242 | file_copy |
| 243 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 244 | temp_mbtk_copy |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 245 | } |
| 246 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 247 | # exit 1 |
| 248 | print_arg |
| 249 | |
| 250 | main $1 |