forked from kammce/SJSU-Dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·199 lines (170 loc) · 9.93 KB
/
setup
File metadata and controls
executable file
·199 lines (170 loc) · 9.93 KB
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
#!/bin/bash
#
# Utils
#
#Checks for installed programs on machine
function programInstalled {
local returning=1
type $1 >/dev/null 2>&1 || { local returning=0; }
echo "$returning"
}
#Function Displays Green Check for installed programs
#Else Displays Red Cross for Missing Programs
function check {
if [ $1 == 1 ]; then
printf "\e[32m✔"
echo $(tput sgr0)
else
printf "\e[31m✘"
echo $(tput sgr0)
fi
}
# 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 " Acquiring sudo privileges "
echo "└────────────────────────────────────────────────── "
sudo echo "" || SystemExit
# Stash the tool directory
TOOLDIR=$(dirname "$0")/tools
ARCH=$(uname -m)
BASE=`pwd`
ARM_GCC=gcc-arm-none-eabi-6-2017-q2-update
echo " ──────────────────────────────────────────────────┐"
echo " Starting SJSU-DEV-Linux Environment Setup Script "
echo "└────────────────────────────────────────────────── "
sleep 1
echo " ──────────────────────────────────────────────────┐"
echo " Basic Dependencies "
echo "└────────────────────────────────────────────────── "
#TODO Install missing dependencies after check
echo "python $(check $(programInstalled python))"
echo "pip $(check $(programInstalled pip))"
echo "git $(check $(programInstalled git))"
echo " ──────────────────────────────────────────────────┐"
echo " Detecting your platform "
echo "└────────────────────────────────────────────────── "
if [[ "$ARCH" != 'x86_64' || "$ARCH" == "amd64" ]]; then
echo 'Your system is not supported! Only 64-bit Linux and OSX systems are supported.'
SystemExit
fi
cd $TOOLDIR
case $( uname -s ) in
Linux) # Linux Case
echo "Operating System: Linux"
echo " ──────────────────────────────────────────────────┐"
echo " Downloading gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
curl -C - -LO https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/$ARM_GCC-linux.tar.bz2
GCC_PKG=$ARM_GCC-linux.tar.bz2
SJSUONEDEV=/dev/ttyUSB0
THE_GROUP=$(getent group | grep 'dial' | cut -d: -f1)
echo " ──────────────────────────────────────────────────┐"
echo " Adding current user to '$GROUP' group"
echo "└────────────────────────────────────────────────── "
sudo adduser $USER $THE_GROUP
echo " ───────────────────────────────────────────────────┐"
echo " Installing OpenOCD, Git, Python, Curl "
echo "└─────────────────────────────────────────────────── "
sudo apt -y install openocd
sudo apt-get -y install git python curl
echo " ───────────────────────────────────────────────────┐"
echo " Installing PIP + Python Virtualenv "
echo "└─────────────────────────────────────────────────── "
sudo -H pip install --upgrade pip
sudo -H pip install --upgrade virtualenv
echo " ───────────────────────────────────────────────────┐"
echo " Installing GDBGUI "
echo "└─────────────────────────────────────────────────── "
sudo -H pip install --upgrade gdbgui
;;
Darwin) # OS X Case
echo "Operating System Kernel: Mac OSX Darvin"
echo " ──────────────────────────────────────────────────┐"
echo " Downloading gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
curl -C - -LO https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/$ARM_GCC-mac.tar.bz2
GCC_PKG=$ARM_GCC-mac.tar.bz2
SJSUONEDEV=/dev/tty.usbserial-A503JOLS
# ========= Xcode ========== #
xcode-select --install &> /dev/null #Install cli tools
sudo xcodebuild -license #Accept User Agreement
;;
*) #Default if Operating System other than Mac or Linux
echo Other
exit 1
;;
esac
echo " ──────────────────────────────────────────────────┐"
echo " Extracting gcc-arm-embedded "
echo "└────────────────────────────────────────────────── "
tar --extract \
--verbose \
--bzip2 \
--file=$GCC_PKG 2> /dev/null
cd $BASE
echo " ───────────────────────────────────────────────────┐"
echo " Installing Hyperload "
echo "└─────────────────────────────────────────────────── "
git clone --depth=1 https://github.com/kammce/Hyperload.git $TOOLDIR/Hyperload/
cd $TOOLDIR/Hyperload/ && ./setup
cd $BASE
echo " ───────────────────────────────────────────────────┐"
echo " Installing Telemetry "
echo "└─────────────────────────────────────────────────── "
git clone --depth=1 https://github.com/kammce/Telemetry.git $TOOLDIR/Telemetry
cd $TOOLDIR/Telemetry/ && ./setup
cd $BASE
echo " ───────────────────────────────────────────────────┐"
echo " Generating Environment Variables "
echo "└─────────────────────────────────────────────────── "
cat > env.sh <<EOL
#!/bin/bash
# Setup a base directory:
BASE=$BASE
# SJSUOne Board Settings:
SJSUONEDEV=$SJSUONEDEV # Set this to your board ID
SJSUONEBAUD=38400
# Project Target Settings:
# Sets the binary name, defaults to "firmware" (Optional)
PROJ=firmware
# Sets which DBC to generate, defaults to "DBG"
ENTITY=DBG
# Compiler and library settings:
# Selects compiler version to use
PATH=\$PATH:\$BASE/tools/$ARM_GCC/bin:\$BASE/tools/Hyperload:\$BASE/tools/Telemetry
LIB_DIR="\$BASE/firmware/lib"
# Export everything to the environment
export PATH
export PROJ
export ENTITY
export LIB_DIR
export SJSUONEDEV
export SJSUONEBAUD
export MAKEFLAGS
EOL
echo " ───────────────────────────────────────────────────┐"
echo " Linking Files into Firmware projects "
echo "└─────────────────────────────────────────────────── "
for PROJECT in HelloWorld FreeRTOS Telemetry Unittest
do
# Place env.sh link into project folder
ln -s -f $BASE/env.sh firmware/$PROJECT/env.sh
# Place makefile link into project folder
ln -s -f $BASE/makefile firmware/$PROJECT/makefile
# Place Unit test template folder into project folder
ln -s -f $BASE/tools/Unittest-Template/README.md firmware/$PROJECT/test/README.md
# Copy simple tests into project folder
cp -rf tools/Unittest-Template/simple-test/ firmware/$PROJECT/test/
# Place the unit test makefile link into project folder
ln -s -f $BASE/makefile.test firmware/$PROJECT/test/simple-test/makefile
done
echo " ───────────────────────────────────────────────────┐"
echo " SETUP COMPLETE! "
echo " "
echo " PLEASE RESTART YOUR SYSTEM "
echo " TO LOAD CODE INTO YOUR SJONE BOARD "
echo "└─────────────────────────────────────────────────── "