Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
Alexei Fedorov | 20fdf50 | 2020-07-27 17:36:38 +0100 | [diff] [blame^] | 3 | # Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 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. |
| 18 | set -e |
| 19 | |
| 20 | TF_SOURCES=$1 |
| 21 | if [ ! -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 |
| 25 | fi |
| 26 | |
Leonardo Sandoval | 1c24ae5 | 2020-07-08 11:47:23 -0500 | [diff] [blame] | 27 | export CROSS_COMPILE=aarch64-none-elf- |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 28 | |
| 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. |
| 32 | if [ ! -d mbedtls ]; then |
| 33 | git clone https://github.com/ARMmbed/mbedtls.git |
| 34 | fi |
| 35 | cd mbedtls |
| 36 | containing_dir="$(readlink -f "$(dirname "$0")/")" |
| 37 | . $containing_dir/common-def.sh |
| 38 | git checkout "$MBED_TLS_SOURCES_TAG" |
| 39 | cd - |
| 40 | TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls" |
| 41 | ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa" |
| 42 | |
| 43 | cd "$TF_SOURCES" |
| 44 | |
| 45 | # Clean TF source dir to make sure we don't analyse temporary files. |
| 46 | make 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. |
| 55 | clean_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 | # |
| 70 | fvp_common_flags="-j PLAT=fvp DEBUG=1" |
| 71 | |
| 72 | # Try all possible SPDs. |
| 73 | clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} ARM_TSP_RAM_LOCATION=dram SPD=tspd |
| 74 | clean_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 |
| 76 | clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} SPD=opteed |
| 77 | clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} SPD=tlkd |
| 78 | |
| 79 | clean_build -j PLAT=fvp DEBUG=1 SPD=trusty |
| 80 | clean_build -j PLAT=fvp DEBUG=1 SPD=trusty TRUSTY_SPD_WITH_GENERIC_SERVICES=1 |
| 81 | |
| 82 | # SDEI |
| 83 | clean_build PLAT=fvp DEBUG=1 SDEI_SUPPORT=1 EL3_EXCEPTION_HANDLING=1 |
| 84 | |
| 85 | # Without coherent memory |
| 86 | clean_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 |
| 89 | clean_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) |
| 93 | clean_build $fvp_common_flags EL3_PAYLOAD=0x80000000 |
| 94 | clean_build $fvp_common_flags PRELOADED_BL33_BASE=0x80000000 |
| 95 | |
| 96 | # Using the SP804 timer instead of the Generic Timer |
| 97 | clean_build $fvp_common_flags FVP_USE_SP804_TIMER=1 |
| 98 | |
| 99 | # Using the CCN driver and multi cluster topology |
| 100 | clean_build $fvp_common_flags FVP_CLUSTER_COUNT=4 |
| 101 | |
| 102 | # PMF |
| 103 | clean_build $fvp_common_flags ENABLE_PMF=1 |
| 104 | |
| 105 | # stack protector |
| 106 | clean_build $fvp_common_flags ENABLE_STACK_PROTECTOR=strong |
| 107 | |
| 108 | # AArch32 build |
Leonardo Sandoval | 1c24ae5 | 2020-07-08 11:47:23 -0500 | [diff] [blame] | 109 | clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 110 | ARCH=aarch32 AARCH32_SP=sp_min \ |
| 111 | RESET_TO_SP_MIN=1 PRELOADED_BL33_BASE=0x80000000 |
Leonardo Sandoval | 1c24ae5 | 2020-07-08 11:47:23 -0500 | [diff] [blame] | 112 | clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 113 | ARCH=aarch32 AARCH32_SP=sp_min |
| 114 | |
| 115 | # Xlat tables lib version 1 (AArch64 and AArch32) |
| 116 | clean_build $fvp_common_flags ARM_XLAT_TABLES_LIB_V1=1 RECLAIM_INIT_CODE=0 |
Leonardo Sandoval | 1c24ae5 | 2020-07-08 11:47:23 -0500 | [diff] [blame] | 117 | clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 118 | ARCH=aarch32 AARCH32_SP=sp_min ARM_XLAT_TABLES_LIB_V1=1 RECLAIM_INIT_CODE=0 |
| 119 | |
| 120 | # Using GIC600 driver |
| 121 | clean_build $fvp_common_flags FVP_USE_GIC_DRIVER=FVP_GIC600 |
| 122 | |
| 123 | # SPM support |
| 124 | clean_build $fvp_common_flags ENABLE_SPM=1 EL3_EXCEPTION_HANDLING=1 |
| 125 | |
| 126 | #BL2 at EL3 support |
| 127 | clean_build $fvp_common_flags BL2_AT_EL3=1 |
Leonardo Sandoval | 1c24ae5 | 2020-07-08 11:47:23 -0500 | [diff] [blame] | 128 | clean_build $fvp_common_flags CROSS_COMPILE=arm-none-eabi- \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 129 | ARCH=aarch32 AARCH32_SP=sp_min BL2_AT_EL3=1 |
| 130 | |
Alexei Fedorov | 20fdf50 | 2020-07-27 17:36:38 +0100 | [diff] [blame^] | 131 | # Measured Boot |
| 132 | clean_build $fvp_common_flags ${ARM_TBB_OPTIONS} MEASURED_BOOT=1 |
| 133 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 134 | # |
| 135 | # Juno platform |
| 136 | # We'll use the following flags for all Juno builds. |
| 137 | # |
| 138 | juno_common_flags="-j PLAT=juno DEBUG=1" |
| 139 | clean_build $juno_common_flags SPD=tspd ${ARM_TBB_OPTIONS} |
| 140 | clean_build $juno_common_flags EL3_PAYLOAD=0x80000000 |
| 141 | clean_build $juno_common_flags ENABLE_STACK_PROTECTOR=strong |
| 142 | clean_build $juno_common_flags CSS_USE_SCMI_SDS_DRIVER=0 |
| 143 | clean_build $juno_common_flags SPD=tspd ${ARM_TBB_OPTIONS} ARM_CRYPTOCELL_INTEG=1 CCSBROM_LIB_PATH=${CRYPTOCELL_LIB_PATH} |
| 144 | |
| 145 | # |
| 146 | # System Guidance for Infrastructure platform SGI575 |
| 147 | # |
| 148 | make -j DEBUG=1 PLAT=sgi575 all |
| 149 | |
| 150 | # |
| 151 | # System Guidance for Infrastructure platform RD-N1Edge |
| 152 | # |
| 153 | make -j DEBUG=1 PLAT=rdn1edge all |
| 154 | |
| 155 | # |
| 156 | # System Guidance for Infrastructure platform RD-E1Edge |
| 157 | # |
| 158 | make -j DEBUG=1 PLAT=rde1edge all |
| 159 | |
| 160 | # Partners' platforms. |
| 161 | # Enable as many features as possible. |
| 162 | # We don't need to clean between each build here because we only do one build |
| 163 | # per platform so we don't hit the build flags dependency problem. |
| 164 | external_plat_common_flags="-j DEBUG=1" |
| 165 | |
| 166 | make PLAT=mt8173 $external_plat_common_flags all |
| 167 | |
| 168 | make PLAT=rk3368 $external_plat_common_flags COREBOOT=1 all |
| 169 | make PLAT=rk3399 $external_plat_common_flags COREBOOT=1 all |
| 170 | make PLAT=rk3328 $external_plat_common_flags COREBOOT=1 all |
| 171 | |
| 172 | # Although we do several consecutive builds for the Tegra platform below, we |
| 173 | # don't need to clean between each one because the Tegra makefiles specify |
| 174 | # a different build directory per SoC. |
| 175 | make PLAT=tegra TARGET_SOC=t210 $external_plat_common_flags all |
| 176 | make PLAT=tegra TARGET_SOC=t132 $external_plat_common_flags all |
| 177 | make PLAT=tegra TARGET_SOC=t186 $external_plat_common_flags all |
| 178 | |
| 179 | # For the Xilinx platform, artificially increase the extents of BL31 memory |
| 180 | # (using the platform-specific build options ZYNQMP_ATF_MEM_{BASE,SIZE}). |
| 181 | # If we keep the default values, BL31 doesn't fit when it is built with all |
| 182 | # these build flags. |
| 183 | make PLAT=zynqmp $external_plat_common_flags \ |
| 184 | RESET_TO_BL31=1 SPD=tspd \ |
| 185 | ZYNQMP_ATF_MEM_BASE=0xFFFC0000 ZYNQMP_ATF_MEM_SIZE=0x00040000 \ |
| 186 | all |
| 187 | |
| 188 | clean_build PLAT=qemu $external_plat_common_flags ${TBB_OPTIONS} |
| 189 | clean_build PLAT=qemu $external_plat_common_flags ENABLE_STACK_PROTECTOR=strong |
| 190 | |
| 191 | # For hikey enable PMF to include all files in the platform port |
| 192 | make PLAT=hikey $external_plat_common_flags ENABLE_PMF=1 all |
| 193 | make PLAT=hikey960 $external_plat_common_flags all |
| 194 | |
| 195 | clean_build PLAT=uniphier $external_plat_common_flags ${TBB_OPTIONS} SPD=tspd |
| 196 | clean_build PLAT=uniphier $external_plat_common_flags FIP_GZIP=1 |
| 197 | |
| 198 | make PLAT=poplar $external_plat_common_flags all |
| 199 | |
| 200 | make PLAT=rpi3 $external_plat_common_flags PRELOADED_BL33_BASE=0xDEADBEEF all |
| 201 | |
| 202 | # Cannot use $external_plat_common_flags for LS1043 platform, as then |
| 203 | # the binaries do not fit in memory. |
| 204 | clean_build PLAT=ls1043 SPD=opteed ENABLE_STACK_PROTECTOR=strong |
| 205 | clean_build PLAT=ls1043 SPD=tspd |
| 206 | |
| 207 | cd .. |