forked from libhal/SJSU-Dev2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·260 lines (247 loc) · 19.3 KB
/
setup
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
# Make sure only non-root users can run our script
if [[ $EUID -eq 0 ]]
then
echo "SJSU-DEV installer script must NOT be run as root! " 1>&2
exit 1
fi
echo " ──────────────────────────────────────────────────┐"
echo " List of global software installed: "
echo " 1) Python "
echo " 2) Python pip "
echo " 3) Curl "
echo " 4) Git CLI "
echo " 5) Perl "
echo " 6) Valgrind "
echo " 7) G++ 7 "
echo " 8) Gcovr-7 "
echo " 9) clang "
echo " 9) clang-format "
echo " 9) clang-tidy "
echo " 10) OpenOCD (Debian/Ubuntu Only) "
echo " 11) XCode CLI tools (MacOS Only) "
echo " 12) Homebrew (MacOS Only) "
echo " 13) Build Essential tools (Debian/Ubuntu Only) "
echo "└────────────────────────────────────────────────── "
echo " Acquiring sudo privileges "
echo "└────────────────────────────────────────────────── "
sudo echo "" || exit 1
# Stash the tool directory
TOOLDIR=$(dirname "$0")/tools
# Get System Architecture
ARCH=$(uname -m)
# Get System Operating System
OS=$(uname -s)
# Get base path
BASE=$(pwd)
# Define name of the arm version we are downloading
ARM_GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4/"
ARM_GCC_COMMON="gcc-arm-none-eabi-7-2017-q4-major"
ARM_GCC_ARCHIVE_FILE_LINUX="$ARM_GCC_COMMON-linux.tar.bz"
ARM_GCC_ARCHIVE_FILE_MAC="$ARM_GCC_COMMON-mac.tar.bz"
ARM_GCC_ARCHIVE_LINUX_URL="$ARM_GCC_URL$ARM_GCC_ARCHIVE_FILE_LINUX"
ARM_GCC_ARCHIVE_MAC_URL="$ARM_GCC_URL$ARM_GCC_ARCHIVE_FILE_MAC"
echo " ──────────────────────────────────────────────────┐"
echo ""
echo " Starting SJSU-DEV-Linux Environment Setup Script "
echo ""
echo "└────────────────────────────────────────────────── "
sleep 1
echo " ──────────────────────────────────────────────────┐"
echo " Detecting your platform "
echo "└────────────────────────────────────────────────── "
if [[ "$ARCH" != 'x86_64' || "$ARCH" == "amd64" ]]
then
echo 'Only 64-bit architecture systems are supported!'
exit 1
fi
echo " ──────────────────────────────────────────────────┐"
echo " System Dependent Setup "
echo "└────────────────────────────────────────────────── "
cd $TOOLDIR
case "$OS" in
Linux) # Linux & Windows WSL Case
echo "Operating System: Linux"
SJSUONEDEV=/dev/ttyUSB0
echo " ───────────────────────────────────────────────────┐"
echo " Updating Apt listings "
echo "└─────────────────────────────────────────────────── "
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository -y "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main"
sudo apt-add-repository -y "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
sudo apt-add-repository -y "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
echo " ───────────────────────────────────────────────────┐"
echo " Installing Clang 6.0 "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install clang-6.0 lldb-6.0 lld-6.0
echo " ───────────────────────────────────────────────────┐"
echo " Installing Clang Format 6.0 "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install clang-format-6.0
echo " ───────────────────────────────────────────────────┐"
echo " Installing Clang Tidy 6.0 "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install clang-tidy-6.0
echo " ───────────────────────────────────────────────────┐"
echo " Installing OpenOCD "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install openocd
echo " ───────────────────────────────────────────────────┐"
echo " Installing build-essentials (GCC, make) "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install build-essential
echo " ───────────────────────────────────────────────────┐"
echo " Installing GCC Version 7 "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install -qq g++-7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
echo " ───────────────────────────────────────────────────┐"
echo " Installing Git, Python, PIP, Curl and Perl "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install git python python-pip curl perl
echo " ───────────────────────────────────────────────────┐"
echo " Installing Testing Tools (Valgrind) "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install valgrind
echo " ───────────────────────────────────────────────────┐"
echo " Installing OpenOCD "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install openocd
echo " ──────────────────────────────────────────────────┐"
echo " Adding current user to '$GROUP' group"
echo "└────────────────────────────────────────────────── "
THE_GROUP=$(getent group | grep 'dial' | cut -d: -f1)
sudo adduser $USER $THE_GROUP
echo " ──────────────────────────────────────────────────┐"
echo " Downloading gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
curl -C - -LO $ARM_GCC_ARCHIVE_LINUX_URL
GCC_PKG=$ARM_GCC_ARCHIVE_FILE_LINUX
;;
Darwin) # OS X Case
echo "Operating System: Mac OSX Darvin"
SJSUONEDEV=/dev/tty.usbserial-A503JOLS
echo " ───────────────────────────────────────────────────┐"
echo " Install XCode Command Line Tools (GCC, make) "
echo "└─────────────────────────────────────────────────── "
xcode-select --install &> /dev/null # Install Command Line tools (make etc...)
sudo xcodebuild -license accept # Accept User Agreement
echo " ───────────────────────────────────────────────────┐"
echo " Prompt Git installer by invoking it "
echo "└─────────────────────────────────────────────────── "
git --version
echo " ───────────────────────────────────────────────────┐"
echo " Installing Homebrew "
echo "└─────────────────────────────────────────────────── "
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo " ───────────────────────────────────────────────────┐"
echo " Updating Homebrew "
echo "└─────────────────────────────────────────────────── "
brew update
echo " ───────────────────────────────────────────────────┐"
echo " Installing GCC Version 7 "
echo "└─────────────────────────────────────────────────── "
brew install gcc@7
echo " ───────────────────────────────────────────────────┐"
echo " Installing LLVM (clang, clang-format, clang-tidy) "
echo "└─────────────────────────────────────────────────── "
brew install llvm@6
echo " ───────────────────────────────────────────────────┐"
echo " Installing Testing Tools (Valgrind) "
echo "└─────────────────────────────────────────────────── "
brew install --HEAD valgrind
echo " ───────────────────────────────────────────────────┐"
echo " Using EASY_INSTALL to install PIP "
echo "└─────────────────────────────────────────────────── "
sudo easy_install pip
echo " ──────────────────────────────────────────────────┐"
echo " Downloading gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
curl -C - -LO $ARM_GCC_ARCHIVE_MAC_URL
GCC_PKG=$ARM_GCC_ARCHIVE_FILE_MAC
;;
*) #Default if Operating System other than Mac or Linux
echo "Only Linux, OSX, and WSL (Windows Subsystem Linux) systems are supported! Exiting..."
exit 1
;;
esac
echo " ──────────────────────────────────────────────────┐"
echo " Extracting gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
tar --extract \
--verbose \
--bzip2 \
--file="$GCC_PKG"\
--exclude='share/doc' 2> /dev/null
cd "$BASE"
echo " ───────────────────────────────────────────────────┐"
echo " Upgrading PIP "
echo "└─────────────────────────────────────────────────── "
sudo -H pip install --upgrade pip
echo " ───────────────────────────────────────────────────┐"
echo " Installing Gcovr "
echo "└─────────────────────────────────────────────────── "
sudo -H pip install gcovr
echo " ───────────────────────────────────────────────────┐"
echo " Upgrading Python's Virtualenv "
echo "└─────────────────────────────────────────────────── "
sudo -H pip install --upgrade virtualenv
echo " ───────────────────────────────────────────────────┐"
echo " Setting Up Hyperload "
echo "└─────────────────────────────────────────────────── "
rm -rf "$TOOLDIR/Hyperload/"
git clone --depth=1 https://github.com/kammce/Hyperload.git "$TOOLDIR/Hyperload/"
cd "$TOOLDIR/Hyperload/" && ./setup
cd "$BASE"
echo " ───────────────────────────────────────────────────┐"
echo " Setting Up Telemetry "
echo "└─────────────────────────────────────────────────── "
rm -rf cd $TOOLDIR/Telemetry/
git clone --depth=1 https://github.com/kammce/Telemetry.git "$TOOLDIR/Telemetry"
cd "$TOOLDIR/Telemetry/" && ./setup
cd "$BASE"
echo " ───────────────────────────────────────────────────┐"
echo " Generating Environment Variables File "
echo "└─────────────────────────────────────────────────── "
cat > env.sh <<EOL
#!/bin/bash
# Setup a base directory:
SJBASE="$BASE"
# SJSUOne Board Settings:
SJDEV="$SJSUONEDEV" # Set this to your board ID
SJBAUD=38400
# Project Target Settings:
# Sets the binary name, defaults to "firmware" (Optional)
SJPROJ=firmware
# Sets which DBC to generate, defaults to "DBG"
ENTITY=DBG
# Compiler and library settings:
# Selects compiler version to use
PATH=\$(printf %q "\$PATH:\$SJBASE/tools/$ARM_GCC_COMMON/bin")
SJLIBDIR="\$SJBASE/firmware/library"
# Export everything to the environment
export SJBASE
export SJDEV
export SJBAUD
export SJPROJ
export ENTITY
export PATH
export SJLIBDIR
EOL
echo " ───────────────────────────────────────────────────┐"
echo " Loading Environment Variables File "
echo "└─────────────────────────────────────────────────── "
source env.sh
echo " ───────────────────────────────────────────────────┐"
echo " Linking Files to Firmware Project Folder "
echo "└─────────────────────────────────────────────────── "
./tools/link_projects.sh
echo " ───────────────────────────────────────────────────┐"
echo " SETUP COMPLETE! "
echo " "
echo " IF THIS IS YOUR FIRST TIME RUNNING THE SETUP SCRIPT "
echo " PLEASE RESTART YOUR SYSTEM "
echo " TO LOAD CODE INTO YOUR SJONE BOARD "
echo "└─────────────────────────────────────────────────── "