blob: 5ef6609244c475e984cae5e3d644569be7a79125 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
David Vincze82db6932024-02-21 12:05:50 +01003# Copyright (c) 2019-2024 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -06008export CROSS_COMPILE=aarch64-none-elf-
9
10# We need to clean the platform build between each configuration because Trusted
11# Firmware's build system doesn't track build options dependencies and won't
12# rebuild the files affected by build options changes.
13clean_build()
14{
15 local flags="$*"
16 echo "Building TF with the following build flags:"
17 echo " $flags"
Andre Przywaradc5ee542021-09-02 12:56:50 +010018 make distclean
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060019 make $flags all
20 echo "Build config complete."
21 echo
22}
23
24# Defines common flags between platforms
25common_flags() {
26 local release="${1:-}"
Chris Kay2ac136d2025-08-26 14:53:15 +010027 local jobs
28
29 # By default, scale number of jobs based on number of available processors
30 jobs=$(nproc || getconf _NPROCESSORS_ONLN || echo 1)
31
32 # Scale number of jobs based on control group CPU quota if configured
33 if [[ -r /sys/fs/cgroup/cpu.max ]]; then
34 if read -r quota period < /sys/fs/cgroup/cpu.max; then
35 # If quota is "max", then there is no restriction on CPU usage
36 if [[ "${quota}" != "max" ]]; then
37 jobs=$((quota / period))
38 jobs=$((jobs == 0 ? 1 : jobs))
39 fi
40 fi
41 fi
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060042
43 # default to debug mode, unless a parameter is passed to the function
44 debug="DEBUG=1"
45 [ -n "$release" ] && debug=""
46
Chris Kay73305862025-08-29 19:02:13 +010047 echo " --jobs=${jobs} $debug -s "
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060048}
49
50# Check if execution environment is ARM's jenkins (Jenkins running under ARM
Paul Sokolovskya1afa402022-11-05 00:52:17 +030051# infrastructure)
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060052is_arm_jenkins_env() {
53 if [ "$JENKINS_HOME" ]; then
Arthur Shea813bdf2025-02-03 21:39:57 -080054 if echo "$JENKINS_PUBLIC_URL" | grep -q "oss.arm.com"; then
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060055 return 0;
56 fi
57 fi
58 return 1
59}
60
Madhukar Pappireddy3d24e422021-06-02 16:52:12 -050061# Use "$1" as a boolean
62upon() {
63 case "$1" in
64 "" | "0" | "false") return 1;;
65 *) return 0;;
66 esac
67}
68
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060069# Provide correct linaro cross toolchain based on environment
70set_cross_compile_gcc_linaro_toolchain() {
71 local cross_compile_path="/home/buildslave/tools"
72
73 # if under arm enviroment, overide cross-compilation path
Madhukar Pappireddy21a5e672021-03-08 17:49:45 -060074 is_arm_jenkins_env || upon "$local_ci" && cross_compile_path="/arm/pdsw/tools"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060075
76 echo "${cross_compile_path}/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
77}
78
79# Provide correct armclang toolchain based on environment
80set_armclang_toolchain() {
Boyan Karatotevfdae0b92025-01-27 10:48:11 +000081 local armclang_path="/home/buildslave/tools/armclang-6.23/bin"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060082
83 # if under arm enviroment, overide cross-compilation path
Boyan Karatotevfdae0b92025-01-27 10:48:11 +000084 is_arm_jenkins_env || upon "$local_ci" && armclang_path="/arm/warehouse/Distributions/FA/ARMCompiler/6.23/37/standalone-linux-x86_64-rel/bin"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060085
86 echo "${armclang_path}/armclang"
87}
Fathi Boudra422bf772019-12-02 11:10:16 +020088
Leonardo Sandovalc4dfbb02020-08-17 10:21:44 -050089# mbed TLS variables
90MBED_TLS_DIR=mbedtls
91MBED_TLS_URL_REPO=https://github.com/ARMmbed/mbedtls.git
92
Sandrine Bailleuxdf823892022-04-22 13:27:45 +020093# mbed TLS source tag to checkout when building Trusted Firmware with
94# cryptography support (e.g. for Trusted Board Boot feature).
Lauren Wehrmeister7c76aca2025-04-03 12:56:54 -050095MBED_TLS_SOURCES_TAG="mbedtls-3.6.3"
Fathi Boudra422bf772019-12-02 11:10:16 +020096
Manish V Badarkhe58a88f02023-11-06 21:42:11 +000097# TF-M variables
98TF_M_TESTS_DIR=tf-m-tests
99TF_M_TESTS_URL_REPO=https://git.trustedfirmware.org/TF-M/tf-m-tests.git
100
101TF_M_EXTRAS_DIR=tf-m-extras
102TF_M_EXTRAS_URL_REPO=https://git.trustedfirmware.org/TF-M/tf-m-extras.git
103
David Vincze82db6932024-02-21 12:05:50 +0100104QCBOR_LIB_DIR=qcbor
105QCBOR_URL_REPO=https://github.com/laurencelundblade/QCBOR.git
106
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -0600107ARMCLANG_PATH="$(set_armclang_toolchain)"
108
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -0600109TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls"
110ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa"