blob: 7502e9f6d95bea5dfcd0ec45f2e62e8f445232d1 [file] [log] [blame]
Fathi Boudra422bf772019-12-02 11:10:16 +02001#! /bin/sh
2#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8#
9# This script builds the TF in different configs.
10# Rather than telling cov-build to build TF using a simple 'make all' command,
11# the goal here is to combine several build flags to analyse more of our source
12# code in a single 'build'. The Coverity Scan service does not have the notion
13# of separate types of build - there is just one linear sequence of builds in
14# the project history.
15#
16
17# Bail out as soon as an error is encountered.
18set -e
19
20TF_SOURCES=$1
21if [ ! -d "$TF_SOURCES" ]; then
22 echo "ERROR: '$TF_SOURCES' does not exist or is not a directory"
23 echo "Usage: $(basename "$0") <trusted-firmware-directory>"
24 exit 1
25fi
26
Leonardo Sandoval1c24ae52020-07-08 11:47:23 -050027export CROSS_COMPILE=aarch64-none-elf-
Fathi Boudra422bf772019-12-02 11:10:16 +020028
29# Get mbed TLS library code to build Trusted Firmware with Trusted Board Boot
30# support. The version of mbed TLS to use here must be the same as when
31# building TF in the usual context.
32if [ ! -d mbedtls ]; then
33 git clone https://github.com/ARMmbed/mbedtls.git
34fi
35cd mbedtls
36containing_dir="$(readlink -f "$(dirname "$0")/")"
37. $containing_dir/common-def.sh
38git checkout "$MBED_TLS_SOURCES_TAG"
39cd -
40TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls"
41ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa"
42
43cd "$TF_SOURCES"
44
45# Clean TF source dir to make sure we don't analyse temporary files.
46make distclean
47
48#
49# Build TF in different configurations to get as much coverage as possible
50#
51
52# We need to clean the platform build between each configuration because Trusted
53# Firmware's build system doesn't track build options dependencies and won't
54# rebuild the files affected by build options changes.
55clean_build()
56{
57 local flags="$*"
58 echo "Building TF with the following build flags:"
59 echo " $flags"
60 make $flags clean
61 make $flags all
62 echo "Build config complete."
63 echo
64}
65
66#
67# FVP platform
68# We'll use the following flags for all FVP builds.
69#
70fvp_common_flags="-j PLAT=fvp DEBUG=1"
71
72# Try all possible SPDs.
73clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} ARM_TSP_RAM_LOCATION=dram SPD=tspd
74clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} ARM_TSP_RAM_LOCATION=dram SPD=tspd TSP_INIT_ASYNC=1 \
75 TSP_NS_INTR_ASYNC_PREEMPT=1
76clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} SPD=opteed
77clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} SPD=tlkd
78
79clean_build -j PLAT=fvp DEBUG=1 SPD=trusty
80clean_build -j PLAT=fvp DEBUG=1 SPD=trusty TRUSTY_SPD_WITH_GENERIC_SERVICES=1
81
82# SDEI
83clean_build PLAT=fvp DEBUG=1 SDEI_SUPPORT=1 EL3_EXCEPTION_HANDLING=1
84
85# Without coherent memory
86clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} ARM_TSP_RAM_LOCATION=dram SPD=tspd USE_COHERENT_MEM=0
87
88# Using PSCI extended State ID format rather than the original format
89clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} ARM_TSP_RAM_LOCATION=dram SPD=tspd PSCI_EXTENDED_STATE_ID=1 \
90 ARM_RECOM_STATE_ID_ENC=1
91
92# Alternative boot flows (This changes some of the platform initialisation code)
93clean_build $fvp_common_flags EL3_PAYLOAD=0x80000000
94clean_build $fvp_common_flags PRELOADED_BL33_BASE=0x80000000
95
96# Using the SP804 timer instead of the Generic Timer
97clean_build $fvp_common_flags FVP_USE_SP804_TIMER=1
98
99# Using the CCN driver and multi cluster topology
100clean_build $fvp_common_flags FVP_CLUSTER_COUNT=4
101
102# PMF
103clean_build $fvp_common_flags ENABLE_PMF=1
104
105# stack protector
106clean_build $fvp_common_flags ENABLE_STACK_PROTECTOR=strong
107
108# AArch32 build
Leonardo Sandoval1c24ae52020-07-08 11:47:23 -0500109clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \
Fathi Boudra422bf772019-12-02 11:10:16 +0200110 ARCH=aarch32 AARCH32_SP=sp_min \
111 RESET_TO_SP_MIN=1 PRELOADED_BL33_BASE=0x80000000
Leonardo Sandoval1c24ae52020-07-08 11:47:23 -0500112clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \
Fathi Boudra422bf772019-12-02 11:10:16 +0200113 ARCH=aarch32 AARCH32_SP=sp_min
114
115# Xlat tables lib version 1 (AArch64 and AArch32)
116clean_build $fvp_common_flags ARM_XLAT_TABLES_LIB_V1=1 RECLAIM_INIT_CODE=0
Leonardo Sandoval1c24ae52020-07-08 11:47:23 -0500117clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \
Fathi Boudra422bf772019-12-02 11:10:16 +0200118 ARCH=aarch32 AARCH32_SP=sp_min ARM_XLAT_TABLES_LIB_V1=1 RECLAIM_INIT_CODE=0
119
120# Using GIC600 driver
121clean_build $fvp_common_flags FVP_USE_GIC_DRIVER=FVP_GIC600
122
123# SPM support
124clean_build $fvp_common_flags ENABLE_SPM=1 EL3_EXCEPTION_HANDLING=1
125
126#BL2 at EL3 support
127clean_build $fvp_common_flags BL2_AT_EL3=1
Leonardo Sandoval1c24ae52020-07-08 11:47:23 -0500128clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \
Fathi Boudra422bf772019-12-02 11:10:16 +0200129 ARCH=aarch32 AARCH32_SP=sp_min BL2_AT_EL3=1
130
131#
132# Juno platform
133# We'll use the following flags for all Juno builds.
134#
135juno_common_flags="-j PLAT=juno DEBUG=1"
136clean_build $juno_common_flags SPD=tspd ${ARM_TBB_OPTIONS}
137clean_build $juno_common_flags EL3_PAYLOAD=0x80000000
138clean_build $juno_common_flags ENABLE_STACK_PROTECTOR=strong
139clean_build $juno_common_flags CSS_USE_SCMI_SDS_DRIVER=0
140clean_build $juno_common_flags SPD=tspd ${ARM_TBB_OPTIONS} ARM_CRYPTOCELL_INTEG=1 CCSBROM_LIB_PATH=${CRYPTOCELL_LIB_PATH}
141
142#
143# System Guidance for Infrastructure platform SGI575
144#
145make -j DEBUG=1 PLAT=sgi575 all
146
147#
148# System Guidance for Infrastructure platform RD-N1Edge
149#
150make -j DEBUG=1 PLAT=rdn1edge all
151
152#
153# System Guidance for Infrastructure platform RD-E1Edge
154#
155make -j DEBUG=1 PLAT=rde1edge all
156
157# Partners' platforms.
158# Enable as many features as possible.
159# We don't need to clean between each build here because we only do one build
160# per platform so we don't hit the build flags dependency problem.
161external_plat_common_flags="-j DEBUG=1"
162
163make PLAT=mt8173 $external_plat_common_flags all
164
165make PLAT=rk3368 $external_plat_common_flags COREBOOT=1 all
166make PLAT=rk3399 $external_plat_common_flags COREBOOT=1 all
167make PLAT=rk3328 $external_plat_common_flags COREBOOT=1 all
168
169# Although we do several consecutive builds for the Tegra platform below, we
170# don't need to clean between each one because the Tegra makefiles specify
171# a different build directory per SoC.
172make PLAT=tegra TARGET_SOC=t210 $external_plat_common_flags all
173make PLAT=tegra TARGET_SOC=t132 $external_plat_common_flags all
174make PLAT=tegra TARGET_SOC=t186 $external_plat_common_flags all
175
176# For the Xilinx platform, artificially increase the extents of BL31 memory
177# (using the platform-specific build options ZYNQMP_ATF_MEM_{BASE,SIZE}).
178# If we keep the default values, BL31 doesn't fit when it is built with all
179# these build flags.
180make PLAT=zynqmp $external_plat_common_flags \
181 RESET_TO_BL31=1 SPD=tspd \
182 ZYNQMP_ATF_MEM_BASE=0xFFFC0000 ZYNQMP_ATF_MEM_SIZE=0x00040000 \
183 all
184
185clean_build PLAT=qemu $external_plat_common_flags ${TBB_OPTIONS}
186clean_build PLAT=qemu $external_plat_common_flags ENABLE_STACK_PROTECTOR=strong
187
188# For hikey enable PMF to include all files in the platform port
189make PLAT=hikey $external_plat_common_flags ENABLE_PMF=1 all
190make PLAT=hikey960 $external_plat_common_flags all
191
192clean_build PLAT=uniphier $external_plat_common_flags ${TBB_OPTIONS} SPD=tspd
193clean_build PLAT=uniphier $external_plat_common_flags FIP_GZIP=1
194
195make PLAT=poplar $external_plat_common_flags all
196
197make PLAT=rpi3 $external_plat_common_flags PRELOADED_BL33_BASE=0xDEADBEEF all
198
199# Cannot use $external_plat_common_flags for LS1043 platform, as then
200# the binaries do not fit in memory.
201clean_build PLAT=ls1043 SPD=opteed ENABLE_STACK_PROTECTOR=strong
202clean_build PLAT=ls1043 SPD=tspd
203
204cd ..