This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
hero-z-7045-builder
executable file
·366 lines (297 loc) · 8.04 KB
/
hero-z-7045-builder
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#! /bin/bash
# Copyright (C) 2018 ETH Zurich and University of Bologna
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Error handler
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' ERR
if [[ ! -f "${0##*/}" ]]; then
echo "Error: ${0##*/} should be launched from the directory that contains it"
exit 1
fi
update_env() {
source scripts/hero-z-7045-env.sh
}
prepare_linux() {
cd ${HERO_SDK_DIR}
update_env
# Does the kernel directory already exist? It may be external.
if [ ! -d "${HERO_LINUX_KERNEL_DIR}" ]; then
# Prepare Linux workspace and get sources
mkdir -p ${HERO_LINUX_WORKSPACE_DIR}
cp -r ${HERO_SUPPORT_DIR}/linux/zynqlinux/* ${HERO_LINUX_WORKSPACE_DIR}/.
cd ${HERO_LINUX_WORKSPACE_DIR}
./setup.sh
fi
}
get_sources() {
cd ${HERO_SDK_DIR}
git submodule update --init
update_env
cd ${HERO_TOOLCHAIN_DIR}
git submodule update --init --recursive
cd ${HERO_PULP_SDK_DIR}
git submodule update --init --recursive
cd ${HERO_SUPPORT_DIR}
git submodule update --init --recursive
cd ${HERO_OMP_EXAMPLES_DIR}
git submodule update --init --recursive
}
build_riscv32_toolchain() {
cd ${HERO_SDK_DIR}
update_env
cd ${HERO_TOOLCHAIN_DIR}
./hero_riscv32_toolchain_builder -dPj
if [ $? -ne 0 ]; then
echo "ERROR: build_riscv32_toolchain failed, aborting now."
exit 1
fi
}
build_pulp_sdk() {
cd ${HERO_SDK_DIR}
update_env
cd ${HERO_PULP_SDK_DIR}
source scripts/hero/setup.sh
if [ $? -ne 0 ]; then
echo "ERROR: build_pulp_sdk failed, aborting now."
exit 1
fi
}
build_arm_toolchain() {
cd ${HERO_SDK_DIR}
update_env
# requires Linux kernel headers
prepare_linux
cd ${HERO_TOOLCHAIN_DIR}
./hero_arm_toolchain_builder -dPj
if [ $? -ne 0 ]; then
echo "ERROR: build_arm_toolchain failed, aborting now."
exit 1
fi
}
build_linux() {
cd ${HERO_SDK_DIR}
update_env
prepare_linux
# Build Linux (kernel, root filesystem, boot files, etc.)
cd ${HERO_LINUX_WORKSPACE_DIR}
./build.sh
if [ $? -ne 0 ]; then
echo "ERROR: build_linux failed, aborting now."
exit 1
fi
}
build_offload() {
cd ${HERO_SDK_DIR}
update_env
# Build the Linux kernel-level PULP driver
cd ${HERO_SUPPORT_DIR}/drivers/pulp
make clean build
if [ $? -ne 0 ]; then
echo "ERROR: Build of the Linux PULP driver failed, aborting now."
exit 1
fi
# Build the PULP offload library
cd ${HERO_SUPPORT_DIR}/libpulp
make clean build
if [ $? -ne 0 ]; then
echo "ERROR: Build of the PULP library failed, aborting now."
exit 1
fi
# Build the PULP UART reader
cd ${HERO_SUPPORT_DIR}/apps/uart
make clean build
if [ $? -ne 0 ]; then
echo "ERROR: Build of the PULP UART reader failed, aborting now."
exit 1
fi
}
build_hero_toolchain() {
cd ${HERO_SDK_DIR}
update_env
cd ${HERO_TOOLCHAIN_DIR}
./hero_riscv32_toolchain_builder -gj
if [ $? -ne 0 ]; then
echo "ERROR: build_hero_toolchain failed for PULP, aborting now."
exit 1
fi
./hero_arm_toolchain_builder -gj
if [ $? -ne 0 ]; then
echo "ERROR: build_hero_toolchain failed for host, aborting now."
exit 1
fi
# Build the HERO target library
cd ${HERO_SDK_DIR}/libhero-target
make clean header build
if [ $? -ne 0 ]; then
echo "ERROR: Build of the HERO target library failed, aborting now."
exit 1
fi
}
install() {
cd ${HERO_SDK_DIR}
update_env
if [[ -z "${HERO_TARGET_HOST}" ]]; then
echo "ERROR: HERO target platform not defined, aborting now."
fi
TARGET=`echo ${HERO_TARGET_HOST} | rev | cut -d@ -f-1 | rev`
ping ${TARGET} -c 1 > /dev/null
if [ $? -ne 0 ]; then
echo "ERROR: HERO target platform not online, aborting now."
fi
# Build and install the Linux kernel-level PULP driver
cd ${HERO_SUPPORT_DIR}/drivers/pulp
make clean all
if [ $? -ne 0 ]; then
echo "ERROR: Build of the Linux PULP driver failed, aborting now."
exit 1
fi
# Build and install the PULP offload library
cd ${HERO_SUPPORT_DIR}/libpulp
make clean all
if [ $? -ne 0 ]; then
echo "ERROR: Build of the PULP library failed, aborting now."
exit 1
fi
# Build and install the PULP UART reader
cd ${HERO_SUPPORT_DIR}/apps/uart
make clean all
if [ $? -ne 0 ]; then
echo "ERROR: Build of the PULP UART reader failed, aborting now."
exit 1
fi
# Install the HERO toolchain
cd ${HERO_TOOLCHAIN_DIR}
scripts/./install_toolchain.sh
if [ $? -ne 0 ]; then
echo "ERROR: HERO toolchain installation failed, aborting now."
exit 1
fi
# Build and install the HERO target library
cd ${HERO_SDK_DIR}/libhero-target
make clean all
if [ $? -ne 0 ]; then
echo "ERROR: Build of the HERO target library failed, aborting now."
exit 1
fi
}
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-hAsrpaloti]
HERO SDK builder
----------------------------------------------------
HERO toolchain commands
----------------------------------------------------
-A : build whole HERO toolchain and its dependecies:
> get sources
> RISCV GCC standalone toolchain
> PULP SDK
> ARM GCC standalone toolchain
> Linux
> offload framework
> HERO toolchain
Commands for building individual components
----------------------------------------------------
-s : get sources
-r : RISCV GCC standalone toolchain
-p : PULP SDK
-a : ARM GCC standalone toolchain
-l : Linux
-o : offload framework
-t : HERO toolchain
-i : install
EOF
}
# Setup the environment variables
update_env
do_get_sources=false
do_build_riscv32_toolchain=false
do_build_pulp_sdk=false
do_build_arm_toolchain=false
do_build_linux=false
do_build_offload=false
do_build_hero_toolchain=false
do_install=false
while getopts hAsrpaloti opt; do
case $opt in
A)
do_get_sources=true
do_build_riscv32_toolchain=true
do_build_pulp_sdk=true
do_build_arm_toolchain=true
do_build_linux=true
do_build_offload=true
do_build_hero_toolchain=true
;;
s)
do_get_sources=true
;;
r)
do_build_riscv32_toolchain=true
;;
p)
do_build_pulp_sdk=true
;;
a)
do_build_arm_toolchain=true
;;
l)
do_build_linux=true
;;
o)
do_build_offload=true
;;
t)
do_build_hero_toolchain=true
;;
i)
do_install=true
;;
h)
show_help
exit 0
;;
*)
show_help >&2
exit 1
;;
esac
done
if [ "$do_get_sources" = true ] ; then
get_sources
fi
if [ "$do_build_riscv32_toolchain" = true ] ; then
build_riscv32_toolchain
fi
if [ "$do_build_pulp_sdk" = true ] ; then
build_pulp_sdk
fi
if [ "$do_build_arm_toolchain" = true ] ; then
build_arm_toolchain
fi
if [ "$do_build_linux" = true ] ; then
build_linux
fi
if [ "$do_build_offload" = true ] ; then
build_offload
fi
if [ "$do_build_hero_toolchain" = true ] ; then
build_hero_toolchain
fi
if [ "$do_install" = true ] ; then
install
fi
# That's all folks!!