blob: e9195c2adf9062f4ef58ae7260f1b245ab2d7895 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval579c7372020-10-23 15:23:32 -05003# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# Builds a package with Trusted Firwmare and other payload binaries. The package
9# is meant to be executed by run_package.sh
10
11set -e
12
13ci_root="$(readlink -f "$(dirname "$0")/..")"
14source "$ci_root/utils.sh"
15
16if [ ! -d "$workspace" ]; then
17 die "Directory $workspace doesn't exist"
18fi
19
20# Directory to where the source code e.g. for Trusted Firmware is checked out.
Zelalem219df412020-05-17 19:21:20 -050021export tf_root="${tf_root:-$workspace/trusted_firmware}"
22export tftf_root="${tftf_root:-$workspace/trusted_firmware_tf}"
23export scp_root="${scp_root:-$workspace/scp}"
24scp_tools_root="${scp_tools_root:-$workspace/scp_tools}"
25cc_root="${cc_root:-$ccpathspec}"
Olivier Deprez0a9a3482019-12-16 14:10:31 +010026spm_root="${spm_root:-$workspace/spm}"
Zelalem219df412020-05-17 19:21:20 -050027
28scp_tf_tools_root="$scp_tools_root/scp_tf_tools"
Fathi Boudra422bf772019-12-02 11:10:16 +020029
30# Refspecs
31tf_refspec="$TF_REFSPEC"
32tftf_refspec="$TFTF_REFSPEC"
33scp_refspec="$SCP_REFSPEC"
Zelalem219df412020-05-17 19:21:20 -050034scp_tools_commit="${SCP_TOOLS_COMMIT:-master}"
Olivier Deprez0a9a3482019-12-16 14:10:31 +010035spm_refspec="$SPM_REFSPEC"
Fathi Boudra422bf772019-12-02 11:10:16 +020036
37test_config="${TEST_CONFIG:?}"
38test_group="${TEST_GROUP:?}"
39build_configs="${BUILD_CONFIG:?}"
40run_config="${RUN_CONFIG:?}"
Zelalem219df412020-05-17 19:21:20 -050041cc_config="${CC_ENABLE:-}"
Fathi Boudra422bf772019-12-02 11:10:16 +020042
43archive="$artefacts"
44build_log="$artefacts/build.log"
45fiptool="$tf_root/tools/fiptool/fiptool"
46cert_create="$tf_root/tools/cert_create/cert_create"
47
48# Validate $bin_mode
49case "$bin_mode" in
50 "" | debug | release)
51 ;;
52 *)
53 die "Invalid value for bin_mode: $bin_mode"
54 ;;
55esac
56
57# File to save any environem
58hook_env_file="$(mktempfile)"
59
60# Check if a config is valid
61config_valid() {
62 local config="${1?}"
63 if [ -z "$config" ] || [ "$(basename "$config")" = "nil" ]; then
64 return 1
65 fi
66
67 return 0
68}
69
70# Echo from a build wrapper. Print to descriptor 3 that's opened by the build
71# function.
72echo_w() {
73 echo $echo_flags "$@" >&3
74}
75
76# Print a separator to the log file. Intended to be used at the tail end of a pipe
77log_separator() {
78 {
79 echo
80 echo "----------"
81 } >> "$build_log"
82
83 tee -a "$build_log"
84
85 {
86 echo "----------"
87 echo
88 } >> "$build_log"
89}
90
91# Call function $1 if it's defined
92call_func() {
93 if type "${1:?}" &>/dev/null; then
94 echo
95 echo "> ${2:?}:$1()"
96 eval "$1"
97 echo "< $2:$1()"
98 fi
99}
100
101# Call hook $1 in all chosen fragments if it's defined. Hooks are invoked from
102# within a subshell, so any variables set within a hook are lost. Should a
103# variable needs to be set from within a hook, the function 'set_hook_var'
104# should be used
105call_hook() {
106 local func="$1"
107 local config_fragment
108
109 [ -z "$func" ] && return 0
110
111 : >"$hook_env_file"
112
113 if [ "$run_config_candiates" ]; then
114 for config_fragment in $run_config_candiates; do
115 (
116 source "$ci_root/run_config/$config_fragment"
117 call_func "$func" "$config_fragment"
118 )
119 done
120 fi
121
122 # Also source test config file
123 (
124 unset "$func"
125 source "$test_config_file"
126 call_func "$func" "$(basename $test_config_file)"
127 )
128
129 # Have any variables set take effect
130 source "$hook_env_file"
131}
132
133# Set a variable from within a hook
134set_hook_var() {
135 echo "export $1=\"${2?}\"" >> "$hook_env_file"
136}
137
138# Append to an array from within a hook
139append_hook_var() {
140 echo "export $1+=\"${2?}\"" >> "$hook_env_file"
141}
142
143# Have the main build script source a file
144source_later() {
145 echo "source ${1?}" >> "$hook_env_file"
146}
147
148# Setup TF build wrapper function by pointing to a script containing a function
149# that will be called with the TF build commands.
150setup_tf_build_wrapper() {
151 source_later "$ci_root/script/${wrapper?}_wrapper.sh"
152 set_hook_var "tf_build_wrapper" "${wrapper}_wrapper"
153 echo "Setup $wrapper build wrapper."
154}
155
156# Collect .bin files for archiving
157collect_build_artefacts() {
158 if [ ! -d "${from:?}" ]; then
159 return
160 fi
161
Javier Almansa Sobrinof98dbd82020-09-30 19:29:27 +0100162 if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' -o -name '*.axf' \) -exec cp -t "${to:?}" '{}' +; then
Fathi Boudra422bf772019-12-02 11:10:16 +0200163 echo "You probably are running local CI on local repositories."
164 echo "Did you set 'dont_clean' but forgot to run 'distclean'?"
165 die
166 fi
167}
168
169# SCP and MCP binaries are named firmware.{bin,elf}, and are placed under
170# scp/mcp_ramfw and scp/mcp_romfw directories, so can't be collected by
171# collect_build_artefacts function.
172collect_scp_artefacts() {
173 to="${to:?}" \
174 find "$scp_root" \( -name "*.bin" -o -name '*.elf' \) -exec bash -c '
175 for file; do
176 ext="$(echo $file | awk -F. "{print \$NF}")"
177 case $file in
178 */scp_ramfw/*)
179 cp $file $to/scp_ram.$ext
180 ;;
181 */scp_romfw/*)
182 cp $file $to/scp_rom.$ext
183 ;;
184 */mcp_ramfw/*)
185 cp $file $to/mcp_ram.$ext
186 ;;
187 */mcp_romfw/*)
188 cp $file $to/mcp_rom.$ext
189 ;;
Zelalem219df412020-05-17 19:21:20 -0500190 */scp_romfw_bypass/*)
191 cp $file $to/scp_rom_bypass.$ext
192 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200193 *)
194 echo "Unknown SCP binary: $file" >&2
195 ;;
196 esac
197 done
198 ' bash '{}' +
199}
200
Manish Pandey1e7be852020-11-09 16:04:48 +0000201# Collect SPM/hafnium artefacts with "secure_" appended to the files
202# generated for SPM(secure hafnium).
203collect_spm_artefacts() {
204 if [ ! -d "${non_secure_from:?}" ] || [ ! -d "${secure_from:?}" ]; then
205 return
206 fi
207
208 find "$non_secure_from" \( -name "*.bin" -o -name '*.elf' \) -exec cp -t "${to:?}" '{}' +
209
210 for f in $(find "$secure_from" \( -name "*.bin" -o -name '*.elf' \)); do cp -- "$f" "${to:?}"/secure_$(basename $f); done
211}
212
Javier Almansa Sobrino412d3612020-05-22 17:53:12 +0100213# Map the UART ID used for expect with the UART descriptor and port
214# used by the FPGA automation tools.
215map_uart() {
216 local port="${port:?}"
217 local descriptor="${descriptor:?}"
218 local baudrate="${baudrate:?}"
219 local run_root="${archive:?}/run"
220
221 local uart_dir="$run_root/uart${uart:?}"
222 mkdir -p "$uart_dir"
223
224 echo "$port" > "$uart_dir/port"
225 echo "$descriptor" > "$uart_dir/descriptor"
226 echo "$baudrate" > "$uart_dir/baudrate"
227
228 echo "UART${uart} mapped to port ${port} with descriptor ${descriptor} and baudrate ${baudrate}"
229}
230
Fathi Boudra422bf772019-12-02 11:10:16 +0200231# Arrange environment varibles to be set when expect scripts are launched
232set_expect_variable() {
233 local var="${1:?}"
234 local val="${2?}"
235
236 local run_root="${archive:?}/run"
237 local uart_dir="$run_root/uart${uart:?}"
238 mkdir -p "$uart_dir"
239
240 env_file="$uart_dir/env" quote="1" emit_env "$var" "$val"
241 echo "UART$uart: env has $@"
242}
243
244# Place the binary package a pointer to expect script, and its parameters
245track_expect() {
246 local file="${file:?}"
247 local timeout="${timeout-600}"
248 local run_root="${archive:?}/run"
249
250 local uart_dir="$run_root/uart${uart:?}"
251 mkdir -p "$uart_dir"
252
253 echo "$file" > "$uart_dir/expect"
254 echo "$timeout" > "$uart_dir/timeout"
255
256 echo "UART$uart to be tracked with $file; timeout ${timeout}s"
257
258 # The run script assumes UART0 to be primary. If we're asked to set any
259 # other UART to be primary, set a run environment variable to signal
260 # that to the run script
261 if upon "$set_primary"; then
262 echo "Primary UART set to UART$uart."
263 set_run_env "primary_uart" "$uart"
264 fi
265}
266
267# Extract a FIP in $1 using fiptool
268extract_fip() {
269 local fip="$1"
270
271 if is_url "$1"; then
272 url="$1" fetch_file
273 fip="$(basename "$1")"
274 fi
275
276 "$fiptool" unpack "$fip"
277 echo "Extracted FIP: $fip"
278}
279
280# Report build failure by printing a the tail end of build log. Archive the
281# build log for later inspection
282fail_build() {
283 local log_path
284
285 if upon "$jenkins_run"; then
286 log_path="$BUILD_URL/artifact/artefacts/build.log"
287 else
288 log_path="$build_log"
289 fi
290
291 echo
Leonardo Sandovalae97eda2020-11-12 10:07:03 -0600292 echo "Build failed! Full build log below:"
Fathi Boudra422bf772019-12-02 11:10:16 +0200293 echo "[...]"
294 echo
Leonardo Sandovalae97eda2020-11-12 10:07:03 -0600295 cat "$build_log"
Fathi Boudra422bf772019-12-02 11:10:16 +0200296 echo
297 echo "See $log_path for full output"
298 echo
299 cp -t "$archive" "$build_log"
300 exit 1;
301}
302
303# Build a FIP with supplied arguments
304build_fip() {
305 (
306 echo "Building FIP with arguments: $@"
307 local tf_env="$workspace/tf.env"
308
309 if [ -f "$tf_env" ]; then
310 set -a
311 source "$tf_env"
312 set +a
313 fi
314
315 make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 "$@" \
316 ${fip_targets:-fip} &>>"$build_log" || fail_build
317 )
318}
319
320fip_update() {
321 # Before the update process, check if the given image is supported by
322 # the fiptool. It's assumed that both fiptool and cert_create move in
323 # tandem, and therfore, if one has support, the other has it too.
324 if ! "$fiptool" update 2>&1 | grep -qe "\s\+--${bin_name:?}"; then
325 return 1
326 fi
327
328 if not_upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then
329 echo "Updating FIP image: $bin_name"
330 # Update HW config. Without TBBR, it's only a matter of using
331 # the update sub-command of fiptool
332 "$fiptool" update "--$bin_name" "${src:-}" \
333 "$archive/fip.bin"
334 else
335 echo "Updating FIP image (TBBR): $bin_name"
336 # With TBBR, we need to unpack, re-create certificates, and then
337 # recreate the FIP.
338 local fip_dir="$(mktempdir)"
339 local bin common_args stem
340 local rot_key="$(get_tf_opt ROT_KEY)"
341
342 rot_key="${rot_key:?}"
343 if ! is_abs "$rot_key"; then
344 rot_key="$tf_root/$rot_key"
345 fi
346
347 # Arguments only for cert_create
348 local cert_args="-n"
349 cert_args+=" --tfw-nvctr ${nvctr:-31}"
350 cert_args+=" --ntfw-nvctr ${nvctr:-223}"
351 cert_args+=" --key-alg ${KEY_ALG:-rsa}"
352 cert_args+=" --rot-key $rot_key"
353
354 local dyn_config_opts=(
Zelalem1af7a7b2020-08-04 17:34:32 -0500355 "fw-config"
Fathi Boudra422bf772019-12-02 11:10:16 +0200356 "hw-config"
357 "tb-fw-config"
358 "nt-fw-config"
359 "soc-fw-config"
360 "tos-fw-config"
361 )
362
363 # Binaries without key certificates
364 declare -A has_no_key_cert
365 for bin in "tb-fw" "${dyn_config_opts[@]}"; do
366 has_no_key_cert["$bin"]="1"
367 done
368
369 # Binaries without certificates
370 declare -A has_no_cert
371 for bin in "hw-config" "${dyn_config_opts[@]}"; do
372 has_no_cert["$bin"]="1"
373 done
374
375 pushd "$fip_dir"
376
377 # Unpack FIP
378 "$fiptool" unpack "$archive/fip.bin" &>>"$build_log"
379
380 # Remove all existing certificates
381 rm -f *-cert.bin
382
383 # Copy the binary to be updated
384 cp -f "$src" "${bin_name}.bin"
385
386 # FIP unpack dumps binaries with the same name as the option
387 # used to pack it; likewise for certificates. Reverse-engineer
388 # the command line from the binary output.
389 common_args="--trusted-key-cert trusted_key.crt"
390 for bin in *.bin; do
391 stem="${bin%%.bin}"
392 common_args+=" --$stem $bin"
393 if not_upon "${has_no_cert[$stem]}"; then
394 common_args+=" --$stem-cert $stem.crt"
395 fi
396 if not_upon "${has_no_key_cert[$stem]}"; then
397 common_args+=" --$stem-key-cert $stem-key.crt"
398 fi
399 done
400
401 # Create certificates
402 "$cert_create" $cert_args $common_args &>>"$build_log"
403
404 # Recreate and archive FIP
405 "$fiptool" create $common_args "fip.bin" &>>"$build_log"
406 archive_file "fip.bin"
407
408 popd
409 fi
410}
411
412# Update hw-config in FIP, and remove the original DTB afterwards.
413update_fip_hw_config() {
414 # The DTB needs to be loaded by the model (and not updated in the FIP)
415 # in configs where BL2 isn't present
416 case "1" in
417 "$(get_tf_opt RESET_TO_BL31)" | \
418 "$(get_tf_opt RESET_TO_SP_MIN)" | \
419 "$(get_tf_opt BL2_AT_EL3)")
420 return 0;;
421 esac
422
423 if bin_name="hw-config" src="$archive/dtb.bin" fip_update; then
424 # Remove the DTB so that model won't load it
425 rm -f "$archive/dtb.bin"
426 fi
427}
428
429get_scp_opt() {
430 (
431 name="${1:?}"
432 if config_valid "$scp_config_file"; then
433 source "$scp_config_file"
434 echo "${!name}"
435 fi
436 )
437}
438
439get_tftf_opt() {
440 (
441 name="${1:?}"
442 if config_valid "$tftf_config_file"; then
443 source "$tftf_config_file"
444 echo "${!name}"
445 fi
446 )
447}
448
449get_tf_opt() {
450 (
451 name="${1:?}"
452 if config_valid "$tf_config_file"; then
453 source "$tf_config_file"
454 echo "${!name}"
455 fi
456 )
457}
458
459build_tf() {
460 (
461 env_file="$workspace/tf.env"
462 config_file="${tf_build_config:-$tf_config_file}"
463
464 # Build fiptool and all targets by default
465 build_targets="${tf_build_targets:-fiptool all}"
466
467 source "$config_file"
468
469 # If it is a TBBR build, extract the MBED TLS library from archive
470 if [ "$(get_tf_opt TRUSTED_BOARD_BOOT)" = 1 ]; then
471 mbedtls_dir="$workspace/mbedtls"
472 if [ ! -d "$mbedtls_dir" ]; then
473 mbedtls_ar="$workspace/mbedtls.tar.gz"
474
475 url="$mbedtls_archive" saveas="$mbedtls_ar" fetch_file
476 mkdir "$mbedtls_dir"
Leonardo Sandovalec9e16c2020-09-09 14:32:40 -0500477 extract_tarball $mbedtls_ar $mbedtls_dir --strip-components=1
Fathi Boudra422bf772019-12-02 11:10:16 +0200478 fi
479
480 emit_env "MBEDTLS_DIR" "$mbedtls_dir"
481 fi
482
483 if [ -f "$env_file" ]; then
484 set -a
485 source "$env_file"
486 set +a
487 fi
488
489 cd "$tf_root"
490
491 # Always distclean when running on Jenkins. Skip distclean when running
492 # locally and explicitly requested.
493 if upon "$jenkins_run" || not_upon "$dont_clean"; then
494 make distclean &>>"$build_log" || fail_build
495 fi
496
497 # Log build command line. It is left unfolded on purpose to assist
498 # copying to clipboard.
499 cat <<EOF | log_separator >/dev/null
500
501Build command line:
502 $tf_build_wrapper make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets
503
504EOF
505
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000506 if not_upon "$local_ci"; then
507 connect_debugger=0
508 fi
509
Fathi Boudra422bf772019-12-02 11:10:16 +0200510 # Build TF. Since build output is being directed to the build log, have
511 # descriptor 3 point to the current terminal for build wrappers to vent.
512 $tf_build_wrapper make $make_j_opts $(cat "$config_file") \
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000513 DEBUG="$DEBUG" V=1 SPIN_ON_BL1_EXIT="$connect_debugger" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200514 $build_targets 3>&1 &>>"$build_log" || fail_build
515 )
516}
517
518build_tftf() {
519 (
520 config_file="${tftf_build_config:-$tftf_config_file}"
521
522 # Build tftf target by default
523 build_targets="${tftf_build_targets:-all}"
524
525 source "$config_file"
526
527 cd "$tftf_root"
528
529 # Always distclean when running on Jenkins. Skip distclean when running
530 # locally and explicitly requested.
531 if upon "$jenkins_run" || not_upon "$dont_clean"; then
532 make distclean &>>"$build_log" || fail_build
533 fi
534
535 # TFTF build system cannot reliably deal with -j option, so we avoid
536 # using that.
537
538 # Log build command line
539 cat <<EOF | log_separator >/dev/null
540
541Build command line:
542 make $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets
543
544EOF
545
546 make $(cat "$config_file") DEBUG="$DEBUG" V=1 \
547 $build_targets &>>"$build_log" || fail_build
548 )
549}
550
551build_scp() {
552 (
553 config_file="${scp_build_config:-$scp_config_file}"
554
555 source "$config_file"
556
557 cd "$scp_root"
558
559 # Always distclean when running on Jenkins. Skip distclean when running
560 # locally and explicitly requested.
561 if upon "$jenkins_run" || not_upon "$dont_clean"; then
562 make clean &>>"$build_log" || fail_build
563 fi
564
565 # Log build command line. It is left unfolded on purpose to assist
566 # copying to clipboard.
567 cat <<EOF | log_separator >/dev/null
568
569SCP build command line:
570 make $(cat "$config_file" | tr '\n' ' ') MODE=$mode V=1
571
572EOF
573
574 # Build SCP
575 make $(cat "$config_file") MODE="$mode" V=1 &>>"$build_log" \
576 || fail_build
577 )
578}
579
Zelalem219df412020-05-17 19:21:20 -0500580clone_scp_tools() {
581
582 if [ ! -d "$scp_tools_root" ]; then
583 echo "Cloning SCP-tools ... $scp_tools_commit" |& log_separator
584
585 clone_url="${SCP_TOOLS_CHECKOUT_LOC:-$scp_tools_src_repo_url}" \
586 where="$scp_tools_root" \
587 refspec="${scp_tools_commit}"
588 clone_repo &>>"$build_log"
589 else
590 echo "Already cloned SCP-tools ..." |& log_separator
591 fi
592
593 show_head "$scp_tools_root"
594
595 cd "$scp_tools_root"
596
597 echo "Updating submodules"
598
599 git submodule init
600
601 git submodule update
602
603 cd "scmi"
604
605 git show --quiet --no-color | sed 's/^/ > /g'
606}
607
608clone_tf_for_scp_tools() {
609 scp_tools_arm_tf="$scp_tools_root/arm-tf"
610
611 if [ ! -d "$scp_tools_arm_tf" ]; then
612 echo "Cloning TF-4-SCP-tools ..." |& log_separator
613
614 clone_url="$tf_for_scp_tools_src_repo_url"
615 where="$scp_tools_arm_tf"
616
617 git clone "$clone_url" "$where"
618
619 cd "$scp_tools_arm_tf"
620
621 git checkout --track origin/dev/pedro/juno
622
623 git show --quiet --no-color | sed 's/^/ > /g'
624
625 else
626 echo "Already cloned TF-4-SCP-tools ..." |& log_separator
627 fi
628}
629
630build_scmi_lib_scp_tools() {
631 (
632 cd "$scp_tools_root"
633
634 cd "scmi"
635
636 scp_tools_arm_tf="$scp_tools_root/arm-tf"
637
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600638 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500639
640 std_libs="-I$scp_tools_arm_tf/include/common"
641 std_libs="$std_libs -I$scp_tools_arm_tf/include/common/tbbr"
642 std_libs="$std_libs -I$scp_tools_arm_tf/include/drivers/arm"
643 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib"
644 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/aarch64"
645 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib"
646 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib/sys"
647 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/xlat_tables"
648 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/common"
649 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/common"
650 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/css/common"
651 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/board/common"
652 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/soc/common"
653 std_libs="$std_libs -I$scp_tools_arm_tf/plat/arm/board/juno/include"
654
655 cflags="-Og -g"
656 cflags="$cflags -mgeneral-regs-only"
657 cflags="$cflags -mstrict-align"
658 cflags="$cflags -nostdinc"
659 cflags="$cflags -fno-inline"
660 cflags="$cflags -ffreestanding"
661 cflags="$cflags -ffunction-sections"
662 cflags="$cflags -fdata-sections"
663 cflags="$cflags -DAARCH64"
664 cflags="$cflags -DPRId32=\"ld\""
665
666 cflags="$cflags $std_libs"
667
668 protocols="power,system_power,performance,sensor"
669
670 echo "Building SCMI library (SCP-tools) ..."
671
672 make "CROSS_COMPILE=$cross_compile" \
673 "CFLAGS=$cflags" \
674 "PROTOCOLS=$protocols" \
675 "clean" \
676 "all"
677 )
678}
679
680build_tf_for_scp_tools() {
681
682 cd "$scp_tools_root/arm-tf"
683
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600684 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500685
686 if [ "$1" = "release" ]; then
687 echo "Build TF-4-SCP-Tools rls..."
688 else
689 echo "Build TF-4-SCP-Tools dbg..."
690
691 make realclean
692
693 make "BM_TEST=scmi" \
694 "ARM_BOARD_OPTIMISE_MEM=1" \
695 "BM_CSS=juno" \
696 "CSS_USE_SCMI_SDS_DRIVER=1" \
697 "PLAT=juno" \
698 "DEBUG=1" \
699 "PLATFORM=juno" \
700 "CROSS_COMPILE=$cross_compile" \
701 "BM_WORKSPACE=$scp_tools_root/baremetal"
702
703 archive_file "build/juno/debug/bl1.bin"
704
705 archive_file "build/juno/debug/bl2.bin"
706
707 archive_file "build/juno/debug/bl31.bin"
708 fi
709}
710
711build_fip_for_scp_tools() {
712
713 cd "$scp_tools_root/arm-tf"
714
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600715 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500716
717 if [ ! -d "$scp_root/build/product/juno/scp_ramfw/debug" ]; then
718 make fiptool
719 echo "Make FIP 4 SCP-Tools rls..."
720
721 else
722 make fiptool
723 echo "Make FIP 4 SCP-Tools dbg..."
724
725 make "PLAT=juno" \
726 "all" \
727 "fip" \
728 "DEBUG=1" \
729 "CROSS_COMPILE=$cross_compile" \
730 "BL31=$scp_tools_root/arm-tf/build/juno/debug/bl31.bin" \
731 "BL33=$scp_tools_root/baremetal/dummy_bl33" \
732 "SCP_BL2=$scp_root/build/product/juno/scp_ramfw/debug/bin/firmware.bin"
733
734 archive_file "$scp_tools_root/arm-tf/build/juno/debug/fip.bin"
735 fi
736}
737
738build_cc() {
739# Building code coverage plugin
740 ARM_DIR=/arm
741 pvlibversion=$(/arm/devsys-tools/abs/detag "SysGen:PVModelLib:$model_version::trunk")
742 PVLIB_HOME=$warehouse/SysGen/PVModelLib/$model_version/${pvlibversion}/external
743 if [ -n "$(find "$ARM_DIR" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then
744 echo "Error: Arm warehouse not mounted. Please mount the Arm warehouse to your /arm local folder"
745 exit -1
746 fi # Error if arm warehouse not found
747 cd "$ccpathspec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov"
748
749 make -C model-plugin PVLIB_HOME=$PVLIB_HOME &>>"$build_log"
750}
751
Olivier Deprez0a9a3482019-12-16 14:10:31 +0100752build_spm() {
753 (
754 env_file="$workspace/spm.env"
755 config_file="${spm_build_config:-$spm_config_file}"
756
757 source "$config_file"
758
759 if [ -f "$env_file" ]; then
760 set -a
761 source "$env_file"
762 set +a
763 fi
764
765 cd "$spm_root"
766
767 # Always clean when running on Jenkins. Skip clean when running
768 # locally and explicitly requested.
769 if upon "$jenkins_run" || not_upon "$dont_clean"; then
770 # make clean fails on a fresh repo where the project has not
771 # yet been built. Hence only clean if out/reference directory
772 # already exists.
773 if [ -d "out/reference" ]; then
774 make clean &>>"$build_log" || fail_build
775 fi
776 fi
777
778 # Log build command line. It is left unfolded on purpose to assist
779 # copying to clipboard.
780 cat <<EOF | log_separator >/dev/null
781
782Build command line:
783 make $make_j_opts $(cat "$config_file" | tr '\n' ' ')
784
785EOF
786
787 # Build SPM. Since build output is being directed to the build log, have
788 # descriptor 3 point to the current terminal for build wrappers to vent.
789 make $make_j_opts $(cat "$config_file") 3>&1 &>>"$build_log" \
790 || fail_build
791 )
792}
Zelalem219df412020-05-17 19:21:20 -0500793
Fathi Boudra422bf772019-12-02 11:10:16 +0200794# Set metadata for the whole package so that it can be used by both Jenkins and
795# shell
796set_package_var() {
797 env_file="$artefacts/env" emit_env "$@"
798}
799
800set_tf_build_targets() {
801 echo "Set build target to '${targets:?}'"
802 set_hook_var "tf_build_targets" "$targets"
803}
804
805set_tftf_build_targets() {
806 echo "Set build target to '${targets:?}'"
807 set_hook_var "tftf_build_targets" "$targets"
808}
809
810set_scp_build_targets() {
811 echo "Set build target to '${targets:?}'"
812 set_hook_var "scp_build_targets" "$targets"
813}
814
Olivier Deprez0a9a3482019-12-16 14:10:31 +0100815set_spm_build_targets() {
816 echo "Set build target to '${targets:?}'"
817 set_hook_var "spm_build_targets" "$targets"
818}
819
Fathi Boudra422bf772019-12-02 11:10:16 +0200820# Look under $archive directory for known files such as blX images, kernel, DTB,
821# initrd etc. For each known file foo, if foo.bin exists, then set variable
822# foo_bin to the path of the file. Make the path relative to the workspace so as
823# to remove any @ characters, which Jenkins inserts for parallel runs. If the
824# file doesn't exist, unset its path.
825set_default_bin_paths() {
826 local image image_name image_path path
827 local archive="${archive:?}"
828 local set_vars
829 local var
830
831 pushd "$archive"
832
833 for file in *.bin; do
834 # Get a shell variable from the file's stem
835 var_name="${file%%.*}_bin"
836 var_name="$(echo "$var_name" | sed -r 's/[^[:alnum:]]/_/g')"
837
838 # Skip setting the variable if it's already
839 if [ "${!var_name}" ]; then
840 echo "Note: not setting $var_name; already set to ${!var_name}"
841 continue
842 else
843 set_vars+="$var_name "
844 fi
845
846 eval "$var_name=$file"
847 done
848
849 echo "Binary paths set for: "
850 {
851 for var in $set_vars; do
852 echo -n "\$$var "
853 done
854 } | fmt -80 | sed 's/^/ /'
855 echo
856
857 popd
858}
859
860gen_model_params() {
861 local model_param_file="$archive/model_params"
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000862 [ "$connect_debugger" ] && [ "$connect_debugger" -eq 1 ] && wait_debugger=1
Fathi Boudra422bf772019-12-02 11:10:16 +0200863
864 set_default_bin_paths
865 echo "Generating model parameter for $model..."
866 source "$ci_root/model/${model:?}.sh"
867 archive_file "$model_param_file"
868}
869
870set_model_path() {
871 set_run_env "model_path" "${1:?}"
872}
873
Zelalem1af7a7b2020-08-04 17:34:32 -0500874set_model_env() {
875 local var="${1:?}"
876 local val="${2?}"
877 local run_root="${archive:?}/run"
878
879 mkdir -p "$run_root"
880 echo "export $var=$val" >> "$run_root/model_env"
881}
Fathi Boudra422bf772019-12-02 11:10:16 +0200882set_run_env() {
883 local var="${1:?}"
884 local val="${2?}"
885 local run_root="${archive:?}/run"
886
887 mkdir -p "$run_root"
888 env_file="$run_root/env" quote="1" emit_env "$var" "$val"
889}
890
891show_head() {
892 # Display HEAD descripton
893 pushd "$1"
894 git show --quiet --no-color | sed 's/^/ > /g'
895 echo
896 popd
897}
898
899# Choose debug binaries to run; by default, release binaries are chosen to run
900use_debug_bins() {
901 local run_root="${archive:?}/run"
902
903 echo "Choosing debug binaries for execution"
904 set_package_var "BIN_MODE" "debug"
905}
906
907assert_can_git_clone() {
908 local name="${1:?}"
909 local dir="${!name}"
910
911 # If it doesn't exist, it can be cloned into
912 if [ ! -e "$dir" ]; then
913 return 0
914 fi
915
916 # If it's a directory, it must be a Git clone already
917 if [ -d "$dir" ] && [ -d "$dir/.git" ]; then
918 # No need to clone again
919 echo "Using existing git clone for $name: $dir"
920 return 1
921 fi
922
923 die "Path $dir exists but is not a git clone"
924}
925
926clone_repo() {
927 if ! is_url "${clone_url?}"; then
928 # For --depth to take effect on local paths, it needs to use the
929 # file:// scheme.
930 clone_url="file://$clone_url"
931 fi
932
933 git clone -q --depth 1 "$clone_url" "${where?}"
934 if [ "$refspec" ]; then
935 pushd "$where"
936 git fetch -q --depth 1 origin "$refspec"
937 git checkout -q FETCH_HEAD
938 popd
939 fi
940}
941
942build_unstable() {
943 echo "--BUILD UNSTABLE--" | tee -a "$build_log"
944}
945
946undo_patch_record() {
947 if [ ! -f "${patch_record:?}" ]; then
948 return
949 fi
950
951 # Undo patches in reverse
952 echo
953 for patch_name in $(tac "$patch_record"); do
954 echo "Undoing $patch_name..."
955 if ! git apply -R "$ci_root/patch/$patch_name"; then
956 if upon "$local_ci"; then
957 echo
958 echo "Your local directory may have been dirtied."
959 echo
960 fi
961 fail_build
962 fi
963 done
964
965 rm -f "$patch_record"
966}
967
968undo_local_patches() {
969 pushd "$tf_root"
970 patch_record="$tf_patch_record" undo_patch_record
971 popd
972
973 if [ -d "$tftf_root" ]; then
974 pushd "$tftf_root"
975 patch_record="$tftf_patch_record" undo_patch_record
976 popd
977 fi
978}
979
980undo_tftf_patches() {
981 pushd "$tftf_root"
982 patch_record="$tftf_patch_record" undo_patch_record
983 popd
984}
985
986undo_tf_patches() {
987 pushd "$tf_root"
988 patch_record="$tf_patch_record" undo_patch_record
989 popd
990}
991
992apply_patch() {
993 # If skip_patches is set, the developer has applied required patches
994 # manually. They probably want to keep them applied for debugging
995 # purposes too. This means we don't have to apply/revert them as part of
996 # build process.
997 if upon "$skip_patches"; then
998 echo "Skipped applying ${1:?}..."
999 return 0
1000 else
1001 echo "Applying ${1:?}..."
1002 fi
1003
1004 if git apply < "$ci_root/patch/$1"; then
1005 echo "$1" >> "${patch_record:?}"
1006 else
1007 if upon "$local_ci"; then
1008 undo_local_patches
1009 fi
1010 fail_build
1011 fi
1012}
1013
1014apply_tftf_patch() {
1015 pushd "$tftf_root"
1016 patch_record="$tftf_patch_record" apply_patch "$1"
1017 popd
1018}
1019
1020apply_tf_patch() {
1021 pushd "$tf_root"
1022 patch_record="$tf_patch_record" apply_patch "$1"
1023 popd
1024}
1025
1026# Clear workspace for a local run
1027if not_upon "$jenkins_run"; then
1028 rm -rf "$workspace"
1029
1030 # Clear residue from previous runs
1031 rm -rf "$archive"
1032fi
1033
1034mkdir -p "$workspace"
1035mkdir -p "$archive"
1036set_package_var "TEST_CONFIG" "$test_config"
1037
1038{
1039echo
1040echo "CONFIGURATION: $test_group/$test_config"
1041echo
1042} |& log_separator
1043
1044tf_config="$(echo "$build_configs" | awk -F, '{print $1}')"
1045tftf_config="$(echo "$build_configs" | awk -F, '{print $2}')"
1046scp_config="$(echo "$build_configs" | awk -F, '{print $3}')"
Zelalem219df412020-05-17 19:21:20 -05001047scp_tools_config="$(echo "$build_configs" | awk -F, '{print $4}')"
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001048spm_config="$(echo "$build_configs" | awk -F, '{print $5}')"
Fathi Boudra422bf772019-12-02 11:10:16 +02001049
1050test_config_file="$ci_root/group/$test_group/$test_config"
1051
1052tf_config_file="$ci_root/tf_config/$tf_config"
1053tftf_config_file="$ci_root/tftf_config/$tftf_config"
1054scp_config_file="$ci_root/scp_config/$scp_config"
Zelalem219df412020-05-17 19:21:20 -05001055scp_tools_config_file="$ci_root/scp_tools_config/$scp_tools_config"
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001056spm_config_file="$ci_root/spm_config/$spm_config"
Fathi Boudra422bf772019-12-02 11:10:16 +02001057
1058# File that keeps track of applied patches
1059tf_patch_record="$workspace/tf_patches"
1060tftf_patch_record="$workspace/tftf_patches"
1061
1062pushd "$workspace"
1063
1064if ! config_valid "$tf_config"; then
1065 tf_config=
1066else
1067 echo "Trusted Firmware config:"
1068 echo
1069 sort "$tf_config_file" | sed '/^\s*$/d;s/^/\t/'
1070 echo
1071fi
1072
1073if ! config_valid "$tftf_config"; then
1074 tftf_config=
1075else
1076 echo "Trusted Firmware TF config:"
1077 echo
1078 sort "$tftf_config_file" | sed '/^\s*$/d;s/^/\t/'
1079 echo
1080fi
1081
1082if ! config_valid "$scp_config"; then
1083 scp_config=
1084else
1085 echo "SCP firmware config:"
1086 echo
1087 sort "$scp_config_file" | sed '/^\s*$/d;s/^/\t/'
1088 echo
1089fi
1090
Zelalem219df412020-05-17 19:21:20 -05001091if ! config_valid "$scp_tools_config"; then
1092 scp_tools_config=
1093else
1094 echo "SCP Tools config:"
1095 echo
1096 sort "$scp_tools_config_file" | sed '/^\s*$/d;s/^/\t/'
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001097fi
1098
1099if ! config_valid "$spm_config"; then
1100 spm_config=
1101else
1102 echo "SPM config:"
1103 echo
1104 sort "$spm_config_file" | sed '/^\s*$/d;s/^/\t/'
Zelalem219df412020-05-17 19:21:20 -05001105 echo
1106fi
1107
Fathi Boudra422bf772019-12-02 11:10:16 +02001108if ! config_valid "$run_config"; then
1109 run_config=
1110fi
1111
1112if [ "$tf_config" ] && assert_can_git_clone "tf_root"; then
1113 # If the Trusted Firmware repository has already been checked out, use
1114 # that location. Otherwise, clone one ourselves.
1115 echo "Cloning Trusted Firmware..."
1116 clone_url="${TF_CHECKOUT_LOC:-$tf_src_repo_url}" where="$tf_root" \
1117 refspec="$TF_REFSPEC" clone_repo &>>"$build_log"
1118 show_head "$tf_root"
1119fi
1120
1121if [ "$tftf_config" ] && assert_can_git_clone "tftf_root"; then
1122 # If the Trusted Firmware TF repository has already been checked out,
1123 # use that location. Otherwise, clone one ourselves.
1124 echo "Cloning Trusted Firmware TF..."
1125 clone_url="${TFTF_CHECKOUT_LOC:-$tftf_src_repo_url}" where="$tftf_root" \
1126 refspec="$TFTF_REFSPEC" clone_repo &>>"$build_log"
1127 show_head "$tftf_root"
1128fi
1129
1130if [ "$scp_config" ] && assert_can_git_clone "scp_root"; then
1131 # If the SCP firmware repository has already been checked out,
1132 # use that location. Otherwise, clone one ourselves.
1133 echo "Cloning SCP Firmware..."
1134 clone_url="${SCP_CHECKOUT_LOC:-$scp_src_repo_url}" where="$scp_root" \
1135 refspec="${SCP_REFSPEC-master-upstream}" clone_repo &>>"$build_log"
1136
1137 pushd "$scp_root"
1138
1139 # Use filer submodule as a reference if it exists
1140 if [ -d "$SCP_CHECKOUT_LOC/cmsis" ]; then
1141 cmsis_reference="--reference $SCP_CHECKOUT_LOC/cmsis"
1142 fi
1143
1144 # If we don't have a reference yet, fall back to $cmsis_root if set, or
1145 # then to project filer if accessible.
1146 if [ -z "$cmsis_reference" ]; then
1147 cmsis_ref_repo="${cmsis_root:-$project_filer/ref-repos/cmsis}"
1148 if [ -d "$cmsis_ref_repo" ]; then
1149 cmsis_reference="--reference $cmsis_ref_repo"
1150 fi
1151 fi
1152
1153 git submodule -q update $cmsis_reference --init
1154
1155 popd
1156
1157 show_head "$scp_root"
1158fi
1159
Zelalem219df412020-05-17 19:21:20 -05001160if [ -n "$cc_config" ] ; then
1161 if [ "$cc_config" -eq 1 ] && assert_can_git_clone "cc_root"; then
1162 # Copy code coverage repository
1163 echo "Cloning Code Coverage..."
1164 git clone -q $cc_src_repo_url cc_plugin --depth 1 -b $cc_src_repo_tag > /dev/null
1165 show_head "$cc_root"
1166 fi
1167fi
1168
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001169if [ "$spm_config" ] && assert_can_git_clone "spm_root"; then
1170 # If the SPM repository has already been checked out, use
1171 # that location. Otherwise, clone one ourselves.
1172 echo "Cloning SPM..."
1173 clone_url="${SPM_CHECKOUT_LOC:-$spm_src_repo_url}" where="$spm_root" \
1174 refspec="$SPM_REFSPEC" clone_repo &>>"$build_log"
1175
1176 # Query git submodules
1177 pushd "$spm_root"
1178 git submodule update --init
1179 popd
1180
1181 show_head "$spm_root"
1182fi
1183
Fathi Boudra422bf772019-12-02 11:10:16 +02001184if [ "$run_config" ]; then
1185 # Get candidates for run config
1186 run_config_candiates="$("$ci_root/script/gen_run_config_candidates.py" \
1187 "$run_config")"
1188 if [ -z "$run_config_candiates" ]; then
1189 die "No run config candidates!"
1190 else
1191 echo
1192 echo "Chosen fragments:"
1193 echo
1194 echo "$run_config_candiates" | sed 's/^\|\n/\t/g'
1195 echo
1196 fi
1197fi
1198
1199call_hook "test_setup"
1200echo
1201
1202if upon "$local_ci"; then
1203 # For local runs, since each config is tried in sequence, it's
1204 # advantageous to run jobs in parallel
1205 if [ "$make_j" ]; then
1206 make_j_opts="-j $make_j"
1207 else
1208 n_cores="$(getconf _NPROCESSORS_ONLN)" 2>/dev/null || true
1209 if [ "$n_cores" ]; then
1210 make_j_opts="-j $n_cores"
1211 fi
1212 fi
1213fi
1214
1215modes="${bin_mode:-debug release}"
1216for mode in $modes; do
1217 # Build with a temporary archive
1218 build_archive="$archive/$mode"
1219 mkdir "$build_archive"
1220
1221 if [ "$mode" = "debug" ]; then
Zelalem219df412020-05-17 19:21:20 -05001222 export bin_mode="debug"
Fathi Boudra422bf772019-12-02 11:10:16 +02001223 DEBUG=1
1224 else
Zelalem219df412020-05-17 19:21:20 -05001225 export bin_mode="release"
Fathi Boudra422bf772019-12-02 11:10:16 +02001226 DEBUG=0
1227 fi
1228
1229 # Perform builds in a subshell so as not to pollute the current and
1230 # subsequent builds' environment
1231
Zelalem219df412020-05-17 19:21:20 -05001232 if config_valid "$cc_config"; then
1233 # Build code coverage plugin
1234 build_cc
1235 fi
1236
Fathi Boudra422bf772019-12-02 11:10:16 +02001237 # SCP build
1238 if config_valid "$scp_config"; then
1239 (
1240 echo "##########"
1241
1242 # Source platform-specific utilities
1243 plat="$(get_scp_opt PRODUCT)"
1244 plat_utils="$ci_root/${plat}_utils.sh"
1245 if [ -f "$plat_utils" ]; then
1246 source "$plat_utils"
1247 fi
1248
1249 archive="$build_archive"
1250 scp_build_root="$scp_root/build"
1251
1252 echo "Building SCP Firmware ($mode) ..." |& log_separator
1253
1254 build_scp
Fathi Boudra422bf772019-12-02 11:10:16 +02001255 to="$archive" collect_scp_artefacts
1256
1257 echo "##########"
1258 echo
1259 )
1260 fi
1261
Zelalem219df412020-05-17 19:21:20 -05001262 # SCP-tools build
1263 if config_valid "$scp_tools_config"; then
1264 (
1265 echo "##########"
1266
1267 archive="$build_archive"
1268 scp_tools_build_root="$scp_tools_root/build"
1269
1270 clone_scp_tools
1271
1272 echo "##########"
1273 echo
1274
1275 echo "##########"
1276 clone_tf_for_scp_tools
1277 echo "##########"
1278 echo
1279 )
1280 fi
1281
Fathi Boudra422bf772019-12-02 11:10:16 +02001282 # TFTF build
1283 if config_valid "$tftf_config"; then
1284 (
1285 echo "##########"
1286
Manish V Badarkhe3bd3fea2020-11-08 15:17:00 +00001287 plat_utils="$(get_tf_opt PLAT_UTILS)"
1288 if [ -z ${plat_utils} ]; then
1289 # Source platform-specific utilities.
1290 plat="$(get_tftf_opt PLAT)"
1291 plat_utils="$ci_root/${plat}_utils.sh"
1292 else
1293 # Source platform-specific utilities by
1294 # using plat_utils name.
1295 plat_utils="$ci_root/${plat_utils}.sh"
1296 fi
1297
Fathi Boudra422bf772019-12-02 11:10:16 +02001298 if [ -f "$plat_utils" ]; then
1299 source "$plat_utils"
1300 fi
1301
1302 archive="$build_archive"
1303 tftf_build_root="$tftf_root/build"
1304
1305 echo "Building Trusted Firmware TF ($mode) ..." |& log_separator
1306
1307 # Call pre-build hook
1308 call_hook pre_tftf_build
1309
1310 build_tftf
1311
1312 from="$tftf_build_root" to="$archive" collect_build_artefacts
1313
1314 # Clear any local changes made by applied patches
1315 undo_tftf_patches
1316
1317 echo "##########"
1318 echo
1319 )
1320 fi
1321
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001322 # SPM build
1323 if config_valid "$spm_config"; then
1324 (
1325 echo "##########"
1326
1327 # Get platform name from spm_config file
1328 plat="$(echo "$spm_config" | awk -F- '{print $1}')"
1329 plat_utils="$ci_root/${plat}_utils.sh"
1330 if [ -f "$plat_utils" ]; then
1331 source "$plat_utils"
1332 fi
1333
Manish Pandey1e7be852020-11-09 16:04:48 +00001334 # SPM build generates two sets of binaries, one for normal and other
1335 # for Secure world. We need both set of binaries for CI.
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001336 archive="$build_archive"
Manish Pandey1e7be852020-11-09 16:04:48 +00001337 spm_build_root="$spm_root/out/reference/$spm_secure_out_dir"
1338 hafnium_build_root="$spm_root/out/reference/$spm_non_secure_out_dir"
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001339
1340 echo "Building SPM ($mode) ..." |& log_separator
1341
1342 # NOTE: mode has no effect on SPM build (for now), hence debug
1343 # mode is built but subsequent build using release mode just
1344 # goes through with "nothing to do".
1345 build_spm
1346
1347 # Show SPM/Hafnium binary details
Manish Pandey1e7be852020-11-09 16:04:48 +00001348 ls -lart $spm_build_root/hafnium.bin $hafnium_build_root/hafnium.bin
1349 cksum $spm_build_root/hafnium.bin $hafnium_build_root/hafnium.bin
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001350
Manish Pandey1e7be852020-11-09 16:04:48 +00001351 secure_from="$spm_build_root" non_secure_from="$hafnium_build_root" to="$archive" collect_spm_artefacts
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001352
1353 echo "##########"
1354 echo
1355 )
1356 fi
1357
Fathi Boudra422bf772019-12-02 11:10:16 +02001358 # TF build
1359 if config_valid "$tf_config"; then
1360 (
1361 echo "##########"
1362
Manish V Badarkhe3bd3fea2020-11-08 15:17:00 +00001363 plat_utils="$(get_tf_opt PLAT_UTILS)"
1364 if [ -z ${plat_utils} ]; then
1365 # Source platform-specific utilities.
1366 plat="$(get_tf_opt PLAT)"
1367 plat_utils="$ci_root/${plat}_utils.sh"
1368 else
1369 # Source platform-specific utilities by
1370 # using plat_utils name.
1371 plat_utils="$ci_root/${plat_utils}.sh"
1372 fi
1373
Fathi Boudra422bf772019-12-02 11:10:16 +02001374 if [ -f "$plat_utils" ]; then
1375 source "$plat_utils"
1376 fi
1377
1378 archive="$build_archive"
1379 tf_build_root="$tf_root/build"
1380
1381 echo "Building Trusted Firmware ($mode) ..." |& log_separator
1382
1383 # Call pre-build hook
1384 call_hook pre_tf_build
1385
1386 build_tf
1387
1388 # Call post-build hook
1389 call_hook post_tf_build
1390
1391 # Pre-archive hook
1392 call_hook pre_tf_archive
1393
1394 from="$tf_build_root" to="$archive" collect_build_artefacts
1395
1396 # Post-archive hook
1397 call_hook post_tf_archive
1398
1399 call_hook fetch_tf_resource
1400 call_hook post_fetch_tf_resource
1401
1402 # Clear any local changes made by applied patches
1403 undo_tf_patches
1404
1405 echo "##########"
1406 )
1407 fi
1408
1409 echo
1410 echo
1411done
1412
1413call_hook pre_package
1414
1415call_hook post_package
1416
1417if upon "$jenkins_run" && upon "$artefacts_receiver" && [ -d "artefacts" ]; then
Zelalem219df412020-05-17 19:21:20 -05001418 source "$CI_ROOT/script/send_artefacts.sh" "artefacts"
Fathi Boudra422bf772019-12-02 11:10:16 +02001419fi
1420
1421echo
1422echo "Done"