amiro-blt / setup.sh @ 6886c3b6
History | View | Annotate | Download (7.06 KB)
1 |
################################################################################ |
---|---|
2 |
# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini # |
3 |
# Robot (AMiRo) platform. # |
4 |
# Copyright (C) 2016..2017 Thomas Schöpping et al. # |
5 |
# # |
6 |
# This program is free software: you can redistribute it and/or modify # |
7 |
# it under the terms of the GNU General Public License as published by # |
8 |
# the Free Software Foundation, either version 3 of the License, or # |
9 |
# (at your option) any later version. # |
10 |
# # |
11 |
# This program is distributed in the hope that it will be useful, # |
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
14 |
# GNU General Public License for more details. # |
15 |
# # |
16 |
# You should have received a copy of the GNU General Public License # |
17 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. # |
18 |
# # |
19 |
# This research/work was supported by the Cluster of Excellence Cognitive # |
20 |
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is # |
21 |
# funded by the German Research Foundation (DFG). # |
22 |
################################################################################ |
23 |
|
24 |
#!/bin/bash |
25 |
|
26 |
# initial info text (can be disabled with 'no_info' as last argument) |
27 |
if [[ ! ${!#} = "no_info" ]]; then |
28 |
printf "######################################################################\n" |
29 |
printf "# #\n" |
30 |
printf "# Welcome to the AMiRo-BLT setup! #\n" |
31 |
printf "# #\n" |
32 |
printf "######################################################################\n" |
33 |
printf "# #\n" |
34 |
printf "# Copyright (c) 2016..2017 Thomas Schöpping #\n" |
35 |
printf "# #\n" |
36 |
printf "# This is free software; see the source for copying conditions. #\n" |
37 |
printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR #\n" |
38 |
printf "# A PARTICULAR PURPOSE. The development of this software was #\n" |
39 |
printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction #\n" |
40 |
printf "# Technology. The Excellence Cluster EXC 227 is a grant of the #\n" |
41 |
printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n" |
42 |
printf "# Excellence Initiative. #\n" |
43 |
printf "# #\n" |
44 |
printf "######################################################################\n" |
45 |
printf "\n" |
46 |
fi |
47 |
|
48 |
# initialization of variables |
49 |
ARG_IDX=1 |
50 |
USER_INPUT=${!ARG_IDX} |
51 |
|
52 |
while [[ ! $USER_INPUT =~ ^[Ee]$ ]]; do |
53 |
|
54 |
# main menu info prompt and selection |
55 |
printf "AMiRo-BLT setup\n" |
56 |
printf "===============\n" |
57 |
printf "\n" |
58 |
if [[ -z $USER_INPUT || $USER_INPUT == "no_info" ]]; then |
59 |
printf "Please select one of the following actions:\n" |
60 |
printf " [F] - stm32flash flashing tool setup\n" |
61 |
printf " [S] - SerialBoot flashing tool setup\n" |
62 |
printf " [Q] - setup QtCreator projects\n" |
63 |
printf " [E] - exit this setup\n" |
64 |
|
65 |
while [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; do |
66 |
read -p "your selection: " -n 1 -e USER_INPUT |
67 |
if [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; then |
68 |
printf "[%s] is no valid action. \n" $USER_INPUT |
69 |
fi |
70 |
done |
71 |
|
72 |
printf "\n" |
73 |
printf "######################################################################\n" |
74 |
printf "\n" |
75 |
fi |
76 |
|
77 |
# action selection |
78 |
case $USER_INPUT in |
79 |
|
80 |
# stm32flash setup |
81 |
F|f) |
82 |
# initialize submodule |
83 |
git submodule update --init $(dirname ${BASH_SOURCE[0]})/Host/stm32flash/ |
84 |
|
85 |
USER_DIR=${PWD} |
86 |
cd $(dirname ${BASH_SOURCE[0]})/Host/stm32flash |
87 |
BUILD_STM32FLASH=true |
88 |
|
89 |
# test for existing bonary |
90 |
if [ -f bin/stm32flash ]; then |
91 |
printf "WARNING: stm32flash binary already exists.\n" |
92 |
read -p "Would you like to delete and rebuild it? [Y/n] " -n 1 -i "Y" -e USER_INPUT |
93 |
if [[ $USER_INPUT =~ ^[Yy]$ ]]; then |
94 |
BUILD_STM32FLASH=true |
95 |
rm -rf bin/ |
96 |
elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then |
97 |
BUILD_STM32FLASH=false |
98 |
printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT |
99 |
else |
100 |
BUILD_STM32FLASH=false |
101 |
fi |
102 |
fi |
103 |
|
104 |
# build the tool if required |
105 |
if [ $BUILD_STM32FLASH = true ]; then |
106 |
mkdir bin |
107 |
make |
108 |
mv stm32flash bin/ |
109 |
make clean |
110 |
fi |
111 |
|
112 |
cd $USER_DIR |
113 |
;; |
114 |
|
115 |
# SerailBoot setup |
116 |
S|s) |
117 |
# print setup header |
118 |
printf "SerialBoot setup\n" |
119 |
printf "================\n" |
120 |
printf "\n" |
121 |
|
122 |
USER_DIR=${PWD} |
123 |
cd $(dirname ${BASH_SOURCE[0]})/Host/Source/SerialBoot |
124 |
BUILD_SERIALBOOT=true |
125 |
|
126 |
# test for existing binary |
127 |
if [ -f build/SerialBoot ]; then |
128 |
printf "WARNING: SerialBoot binary already exists.\n" |
129 |
read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT |
130 |
if [[ $USER_INPUT =~ ^[Yy]$ ]]; then |
131 |
BUILD_SERIALBOOT=true |
132 |
rm -rf build/ |
133 |
elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then |
134 |
BUILD_SERIALBOOT=false |
135 |
printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT |
136 |
else |
137 |
BUILD_SERIALBOOT=false |
138 |
fi |
139 |
fi |
140 |
|
141 |
# build the tool if requested |
142 |
if [ $BUILD_SERIALBOOT = true ]; then |
143 |
mkdir build |
144 |
cd build |
145 |
cmake .. |
146 |
make |
147 |
fi |
148 |
|
149 |
cd $USER_DIR |
150 |
;; |
151 |
|
152 |
# QtCreator setup |
153 |
Q|q) |
154 |
# calling the script with no arguments prints the help and returns |
155 |
source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh "no_info" |
156 |
printf "\n" |
157 |
# set deafult arguments and call the script again |
158 |
USER_INPUT="clean all" |
159 |
read -p "select commands: " -i "$USER_INPUT" -e USER_INPUT |
160 |
printf "\n" |
161 |
source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh "no_info" $USER_INPUT |
162 |
;; |
163 |
|
164 |
# exit |
165 |
E|e) |
166 |
break; |
167 |
;; |
168 |
|
169 |
# sanity check |
170 |
*) |
171 |
printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" |
172 |
printf "ERROR (${LINENO}): unexpected state; aborting script\n" |
173 |
printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" |
174 |
printf "\n" |
175 |
exit |
176 |
;; |
177 |
|
178 |
esac |
179 |
|
180 |
printf "\n" |
181 |
printf "######################################################################\n" |
182 |
printf "\n" |
183 |
|
184 |
let ARG_IDX++ |
185 |
USER_INPUT=${!ARG_IDX} |
186 |
|
187 |
done |
188 |
|