-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_setup.sh
executable file
·122 lines (102 loc) · 3.74 KB
/
build_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
set -e
TOP_DIR=$(dirname "$0")
echo $TOP_DIR
echo "Start board build_setup ..."
TOOLCHAIN_PATH=$TOP_DIR/../tools
if [ ! -d "$TOOLCHAIN_PATH" ]; then
mkdir -p $TOOLCHAIN_PATH
echo "Toolchain $TOOLCHAIN_PATH not exist"
fi
TOOLCHAIN_NAME=$TOOLCHAIN_PATH/gcc-arm-none-eabi-10.3-2021.10
if [ -d "$TOOLCHAIN_NAME" ]; then
if [ -f "$TOOLCHAIN_NAME/bin/arm-none-eabi-gcc" ]; then
echo "Toolchain $TOOLCHAIN_NAME check Successful"
echo "Run build setup success ..."
exit 0
else
echo "Toolchain $TOOLCHAIN_NAME check Failed"
rm -rf $TOOLCHAIN_NAME
echo "Remove toolchain $TOOLCHAIN_NAME, download again"
fi
fi
echo "Start download toolchain"
# restult=$(curl -m 15 -s http://www.ip-api.com/json)
# country=$(echo $restult | sed 's/.*"country":"\([^"]*\)".*/\1/')
# echo "country: $country"
cd $TOOLCHAIN_PATH
HOST_MACHINE=$(uname -m)
case "$(uname -s)" in
Linux*)
SYSTEM_NAME="Linux"
if [ $HOST_MACHINE = "x86_64" ]; then
TOOLCHAIN_URL=https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
TOOLCHAIN_FILE=gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
TOOLCHAIN_SIZE=157089706
TOOLCHAIN_SHA256=97dbb4f019ad1650b732faffcc881689cedc14e2b7ee863d390e0a41ef16c9a3
elif [ $HOST_MACHINE = "aarch64" ]; then
TOOLCHAIN_URL=https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-aarch64-linux.tar.bz2
TOOLCHAIN_FILE=gcc-arm-none-eabi-10.3-2021.10-aarch64-linux.tar.bz2
TOOLCHAIN_SIZE=168772350
TOOLCHAIN_SHA256=f605b5f23ca898e9b8b665be208510a54a6e9fdd0fa5bfc9592002f6e7431208
else
echo "Toolchain not support, Please download toolchain from https://developer.arm.com/downloads/-/gnu-rm"
exit 1
fi
;;
Darwin*)
SYSTEM_NAME="Apple"
if [ $HOST_MACHINE = "x86_64" ]; then
TOOLCHAIN_URL=https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2
TOOLCHAIN_FILE=gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2
TOOLCHAIN_SIZE=158961466
TOOLCHAIN_SHA256=fb613dacb25149f140f73fe9ff6c380bb43328e6bf813473986e9127e2bc283b
else
echo "Toolchain not support, Please download toolchain from https://developer.arm.com/downloads/-/gnu-rm"
exit 1
fi
;;
MINGW* | CYGWIN* | MSYS*)
SYSTEM_NAME="Windows"
TOOLCHAIN_URL=https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.zip
TOOLCHAIN_FILE=gcc-arm-none-eabi-10.3-2021.10-win32.zip
TOOLCHAIN_SIZE=200578763
TOOLCHAIN_SHA256=d287439b3090843f3f4e29c7c41f81d958a5323aecefcf705c203bfd8ae3f2e7
;;
*)
SYSTEM_NAME="Unknown"
exit 1
;;
esac
echo "Running on [$SYSTEM_NAME]"
if [ ! -f $TOOLCHAIN_FILE ]; then
wget $TOOLCHAIN_URL -O $TOOLCHAIN_FILE
if [ $? -ne 0 ]; then
echo "Download toolchain failed"
rm -rf $TOOLCHAIN_FILE
exit 1
fi
fi
if [ $TOOLCHAIN_SHA256 != $(sha256sum $TOOLCHAIN_FILE | awk '{print $1}') ]; then
echo "Toolchain file checksum error"
rm -rf $TOOLCHAIN_FILE
exit 1
fi
if [ $TOOLCHAIN_SIZE != $(stat -c %s $TOOLCHAIN_FILE) ]; then
echo "Toolchain file size error"
rm -rf $TOOLCHAIN_FILE
exit 1
fi
FILE_EXTENSION=${TOOLCHAIN_FILE##*.}
echo "start decompression"
echo "FILE_EXTENSION: ${FILE_EXTENSION}"
if [ $FILE_EXTENSION = "bz2" ]; then
tar -xvf $TOOLCHAIN_FILE -C $TOOLCHAIN_PATH
elif [ $FILE_EXTENSION = "zip" ]; then
mkdir -p $TOOLCHAIN_NAME
unzip $TOOLCHAIN_FILE -d $TOOLCHAIN_NAME
else
echo "File not support"
exit 1
fi
echo "Run build setup success ..."