Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 3 | # Copyright (c) 2019-2024 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 | # Builds a package with Trusted Firwmare and other payload binaries. The package |
| 9 | # is meant to be executed by run_package.sh |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | ci_root="$(readlink -f "$(dirname "$0")/..")" |
| 14 | source "$ci_root/utils.sh" |
| 15 | |
| 16 | if [ ! -d "$workspace" ]; then |
| 17 | die "Directory $workspace doesn't exist" |
| 18 | fi |
| 19 | |
| 20 | # Directory to where the source code e.g. for Trusted Firmware is checked out. |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 21 | export tf_root="${tf_root:-$workspace/trusted_firmware}" |
| 22 | export tftf_root="${tftf_root:-$workspace/trusted_firmware_tf}" |
| 23 | export scp_root="${scp_root:-$workspace/scp}" |
| 24 | scp_tools_root="${scp_tools_root:-$workspace/scp_tools}" |
| 25 | cc_root="${cc_root:-$ccpathspec}" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 26 | spm_root="${spm_root:-$workspace/spm}" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 27 | rmm_root="${rmm_root:-$workspace/tf-rmm}" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 28 | |
| 29 | scp_tf_tools_root="$scp_tools_root/scp_tf_tools" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 30 | |
| 31 | # Refspecs |
| 32 | tf_refspec="$TF_REFSPEC" |
| 33 | tftf_refspec="$TFTF_REFSPEC" |
| 34 | scp_refspec="$SCP_REFSPEC" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 35 | scp_tools_commit="${SCP_TOOLS_COMMIT:-master}" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 36 | spm_refspec="$SPM_REFSPEC" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 37 | rmm_refspec="$RMM_REFSPEC" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 38 | |
| 39 | test_config="${TEST_CONFIG:?}" |
| 40 | test_group="${TEST_GROUP:?}" |
| 41 | build_configs="${BUILD_CONFIG:?}" |
| 42 | run_config="${RUN_CONFIG:?}" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 43 | cc_config="${CC_ENABLE:-}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 44 | |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 45 | export archive="$artefacts" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 46 | build_log="$artefacts/build.log" |
| 47 | fiptool="$tf_root/tools/fiptool/fiptool" |
| 48 | cert_create="$tf_root/tools/cert_create/cert_create" |
| 49 | |
| 50 | # Validate $bin_mode |
| 51 | case "$bin_mode" in |
| 52 | "" | debug | release) |
| 53 | ;; |
| 54 | *) |
| 55 | die "Invalid value for bin_mode: $bin_mode" |
| 56 | ;; |
| 57 | esac |
| 58 | |
| 59 | # File to save any environem |
| 60 | hook_env_file="$(mktempfile)" |
| 61 | |
| 62 | # Check if a config is valid |
| 63 | config_valid() { |
| 64 | local config="${1?}" |
| 65 | if [ -z "$config" ] || [ "$(basename "$config")" = "nil" ]; then |
| 66 | return 1 |
| 67 | fi |
| 68 | |
| 69 | return 0 |
| 70 | } |
| 71 | |
| 72 | # Echo from a build wrapper. Print to descriptor 3 that's opened by the build |
| 73 | # function. |
| 74 | echo_w() { |
| 75 | echo $echo_flags "$@" >&3 |
| 76 | } |
| 77 | |
| 78 | # Print a separator to the log file. Intended to be used at the tail end of a pipe |
| 79 | log_separator() { |
| 80 | { |
| 81 | echo |
| 82 | echo "----------" |
| 83 | } >> "$build_log" |
| 84 | |
| 85 | tee -a "$build_log" |
| 86 | |
| 87 | { |
| 88 | echo "----------" |
| 89 | echo |
| 90 | } >> "$build_log" |
| 91 | } |
| 92 | |
| 93 | # Call function $1 if it's defined |
| 94 | call_func() { |
| 95 | if type "${1:?}" &>/dev/null; then |
| 96 | echo |
| 97 | echo "> ${2:?}:$1()" |
| 98 | eval "$1" |
| 99 | echo "< $2:$1()" |
| 100 | fi |
| 101 | } |
| 102 | |
Paul Sokolovsky | be6510c | 2024-08-15 21:54:00 +0300 | [diff] [blame] | 103 | # Retry a command a number of times if it fails. Intended for I/O commands |
| 104 | # in a CI environment which may be flaky. |
| 105 | function retry() { |
| 106 | for i in $(seq 1 3); do |
| 107 | if "$@"; then |
| 108 | return 0 |
| 109 | fi |
| 110 | sleep $(( i * 5 )) |
| 111 | done |
| 112 | return 1 |
| 113 | } |
| 114 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 115 | # Call hook $1 in all chosen fragments if it's defined. Hooks are invoked from |
| 116 | # within a subshell, so any variables set within a hook are lost. Should a |
| 117 | # variable needs to be set from within a hook, the function 'set_hook_var' |
| 118 | # should be used |
| 119 | call_hook() { |
| 120 | local func="$1" |
| 121 | local config_fragment |
| 122 | |
| 123 | [ -z "$func" ] && return 0 |
| 124 | |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 125 | echo "=== Calling hooks: $1 ===" |
| 126 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 127 | : >"$hook_env_file" |
| 128 | |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 129 | if [ "$run_config_candidates" ]; then |
| 130 | for config_fragment in $run_config_candidates; do |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 131 | ( |
| 132 | source "$ci_root/run_config/$config_fragment" |
| 133 | call_func "$func" "$config_fragment" |
| 134 | ) |
| 135 | done |
| 136 | fi |
| 137 | |
| 138 | # Also source test config file |
| 139 | ( |
| 140 | unset "$func" |
| 141 | source "$test_config_file" |
| 142 | call_func "$func" "$(basename $test_config_file)" |
| 143 | ) |
| 144 | |
| 145 | # Have any variables set take effect |
| 146 | source "$hook_env_file" |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 147 | |
| 148 | echo "=== End calling hooks: $1 ===" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | # Set a variable from within a hook |
| 152 | set_hook_var() { |
| 153 | echo "export $1=\"${2?}\"" >> "$hook_env_file" |
| 154 | } |
| 155 | |
| 156 | # Append to an array from within a hook |
| 157 | append_hook_var() { |
| 158 | echo "export $1+=\"${2?}\"" >> "$hook_env_file" |
| 159 | } |
| 160 | |
| 161 | # Have the main build script source a file |
| 162 | source_later() { |
| 163 | echo "source ${1?}" >> "$hook_env_file" |
| 164 | } |
| 165 | |
| 166 | # Setup TF build wrapper function by pointing to a script containing a function |
| 167 | # that will be called with the TF build commands. |
| 168 | setup_tf_build_wrapper() { |
| 169 | source_later "$ci_root/script/${wrapper?}_wrapper.sh" |
| 170 | set_hook_var "tf_build_wrapper" "${wrapper}_wrapper" |
| 171 | echo "Setup $wrapper build wrapper." |
| 172 | } |
| 173 | |
| 174 | # Collect .bin files for archiving |
| 175 | collect_build_artefacts() { |
| 176 | if [ ! -d "${from:?}" ]; then |
| 177 | return |
| 178 | fi |
| 179 | |
Manish V Badarkhe | 84c3a48 | 2025-04-16 08:15:38 +0100 | [diff] [blame] | 180 | if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' -o -name '*.axf' -o -name '*.stm32' -o -name '*.img' \) -exec cp -t "${to:?}" '{}' +; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 181 | echo "You probably are running local CI on local repositories." |
| 182 | echo "Did you set 'dont_clean' but forgot to run 'distclean'?" |
| 183 | die |
| 184 | fi |
| 185 | } |
| 186 | |
| 187 | # SCP and MCP binaries are named firmware.{bin,elf}, and are placed under |
| 188 | # scp/mcp_ramfw and scp/mcp_romfw directories, so can't be collected by |
| 189 | # collect_build_artefacts function. |
| 190 | collect_scp_artefacts() { |
| 191 | to="${to:?}" \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 192 | find "$scp_root" \( \( -name "*.bin" -o -name '*.elf' \) -and ! -name 'CMake*' \) -exec bash -c ' |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 193 | for file; do |
| 194 | ext="$(echo $file | awk -F. "{print \$NF}")" |
| 195 | case $file in |
Anurag Koul | baedf93 | 2021-12-09 12:49:56 +0000 | [diff] [blame] | 196 | */firmware-scp_ramfw/bin/*|*/firmware-scp_ramfw_fvp/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 197 | cp $file $to/scp_ram.$ext |
| 198 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 199 | */firmware-scp_romfw/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 200 | cp $file $to/scp_rom.$ext |
| 201 | ;; |
Anurag Koul | baedf93 | 2021-12-09 12:49:56 +0000 | [diff] [blame] | 202 | */firmware-mcp_ramfw/bin/*|*/firmware-mcp_ramfw_fvp/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 203 | cp $file $to/mcp_ram.$ext |
| 204 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 205 | */firmware-mcp_romfw/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 206 | cp $file $to/mcp_rom.$ext |
| 207 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 208 | */firmware-scp_romfw_bypass/bin/*) |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 209 | cp $file $to/scp_rom_bypass.$ext |
| 210 | ;; |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 211 | *) |
| 212 | echo "Unknown SCP binary: $file" >&2 |
| 213 | ;; |
| 214 | esac |
| 215 | done |
| 216 | ' bash '{}' + |
| 217 | } |
| 218 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 219 | # Collect SPM/hafnium artefacts with "secure_" appended to the files |
| 220 | # generated for SPM(secure hafnium). |
| 221 | collect_spm_artefacts() { |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 222 | if [ -d "${non_secure_from:?}" ]; then |
| 223 | find "$non_secure_from" \( -name "*.bin" -o -name '*.elf' \) -exec cp -t "${to:?}" '{}' + |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 224 | fi |
| 225 | |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 226 | if [ -d "${secure_from:?}" ]; then |
| 227 | for f in $(find "$secure_from" \( -name "*.bin" -o -name '*.elf' \)); do cp -- "$f" "${to:?}"/secure_$(basename $f); done |
| 228 | fi |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 231 | # Map the UART ID used for expect with the UART descriptor and port |
| 232 | # used by the FPGA automation tools. |
| 233 | map_uart() { |
| 234 | local port="${port:?}" |
| 235 | local descriptor="${descriptor:?}" |
| 236 | local baudrate="${baudrate:?}" |
| 237 | local run_root="${archive:?}/run" |
| 238 | |
| 239 | local uart_dir="$run_root/uart${uart:?}" |
| 240 | mkdir -p "$uart_dir" |
| 241 | |
| 242 | echo "$port" > "$uart_dir/port" |
| 243 | echo "$descriptor" > "$uart_dir/descriptor" |
| 244 | echo "$baudrate" > "$uart_dir/baudrate" |
| 245 | |
| 246 | echo "UART${uart} mapped to port ${port} with descriptor ${descriptor} and baudrate ${baudrate}" |
| 247 | } |
| 248 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 249 | # Arrange environment varibles to be set when expect scripts are launched |
| 250 | set_expect_variable() { |
| 251 | local var="${1:?}" |
| 252 | local val="${2?}" |
| 253 | |
| 254 | local run_root="${archive:?}/run" |
| 255 | local uart_dir="$run_root/uart${uart:?}" |
| 256 | mkdir -p "$uart_dir" |
| 257 | |
| 258 | env_file="$uart_dir/env" quote="1" emit_env "$var" "$val" |
| 259 | echo "UART$uart: env has $@" |
| 260 | } |
| 261 | |
| 262 | # Place the binary package a pointer to expect script, and its parameters |
| 263 | track_expect() { |
| 264 | local file="${file:?}" |
| 265 | local timeout="${timeout-600}" |
| 266 | local run_root="${archive:?}/run" |
| 267 | |
| 268 | local uart_dir="$run_root/uart${uart:?}" |
| 269 | mkdir -p "$uart_dir" |
| 270 | |
| 271 | echo "$file" > "$uart_dir/expect" |
| 272 | echo "$timeout" > "$uart_dir/timeout" |
Paul Sokolovsky | bfa8bab | 2023-01-25 19:34:51 +0700 | [diff] [blame] | 273 | if [ -n "$lava_timeout" ]; then |
| 274 | set_run_env "lava_timeout" "$lava_timeout" |
| 275 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 276 | |
Paul Sokolovsky | bfa8bab | 2023-01-25 19:34:51 +0700 | [diff] [blame] | 277 | echo "UART$uart to be tracked with $file; timeout ${timeout}s; lava_timeout ${lava_timeout:-N/A}s" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 278 | |
Chris Kay | fab6edc | 2022-11-17 19:18:32 +0000 | [diff] [blame] | 279 | if [ ! -z "${port}" ]; then |
| 280 | echo "${port}" > "$uart_dir/port" |
| 281 | fi |
| 282 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 283 | # The run script assumes UART0 to be primary. If we're asked to set any |
| 284 | # other UART to be primary, set a run environment variable to signal |
| 285 | # that to the run script |
| 286 | if upon "$set_primary"; then |
| 287 | echo "Primary UART set to UART$uart." |
| 288 | set_run_env "primary_uart" "$uart" |
| 289 | fi |
Madhukar Pappireddy | 1e95372 | 2021-11-08 15:23:02 -0600 | [diff] [blame] | 290 | |
| 291 | # UART used by payload(such as tftf, Linux) may not be the same as the |
| 292 | # primary UART. Set a run environment variable to track the payload |
| 293 | # UART which is tracked to check if the test has finished sucessfully. |
| 294 | if upon "$set_payload_uart"; then |
| 295 | echo "Payload uses UART$uart." |
| 296 | set_run_env "payload_uart" "$uart" |
| 297 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | # Extract a FIP in $1 using fiptool |
| 301 | extract_fip() { |
| 302 | local fip="$1" |
| 303 | |
| 304 | if is_url "$1"; then |
| 305 | url="$1" fetch_file |
| 306 | fip="$(basename "$1")" |
| 307 | fi |
| 308 | |
| 309 | "$fiptool" unpack "$fip" |
| 310 | echo "Extracted FIP: $fip" |
| 311 | } |
| 312 | |
| 313 | # Report build failure by printing a the tail end of build log. Archive the |
| 314 | # build log for later inspection |
| 315 | fail_build() { |
| 316 | local log_path |
| 317 | |
| 318 | if upon "$jenkins_run"; then |
| 319 | log_path="$BUILD_URL/artifact/artefacts/build.log" |
| 320 | else |
| 321 | log_path="$build_log" |
| 322 | fi |
| 323 | |
| 324 | echo |
Leonardo Sandoval | ae97eda | 2020-11-12 10:07:03 -0600 | [diff] [blame] | 325 | echo "Build failed! Full build log below:" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 326 | echo "[...]" |
| 327 | echo |
Leonardo Sandoval | ae97eda | 2020-11-12 10:07:03 -0600 | [diff] [blame] | 328 | cat "$build_log" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 329 | echo |
| 330 | echo "See $log_path for full output" |
| 331 | echo |
| 332 | cp -t "$archive" "$build_log" |
| 333 | exit 1; |
| 334 | } |
| 335 | |
| 336 | # Build a FIP with supplied arguments |
| 337 | build_fip() { |
| 338 | ( |
| 339 | echo "Building FIP with arguments: $@" |
| 340 | local tf_env="$workspace/tf.env" |
| 341 | |
| 342 | if [ -f "$tf_env" ]; then |
| 343 | set -a |
| 344 | source "$tf_env" |
| 345 | set +a |
| 346 | fi |
| 347 | |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 348 | make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" BUILD_BASE=$tf_build_root V=1 "$@" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 349 | ${fip_targets:-fip} &>>"$build_log" || fail_build |
| 350 | ) |
| 351 | } |
| 352 | |
Sandrine Bailleux | 189fdb3 | 2023-10-20 13:41:22 +0200 | [diff] [blame] | 353 | # Build any extra rule from TF-A makefile with supplied arguments. |
| 354 | # |
| 355 | # This is useful in case you need to build something else than firmware binaries |
| 356 | # or the FIP. |
| 357 | build_tf_extra() { |
| 358 | ( |
| 359 | tf_extra_rules=${tf_extra_rules:?} |
| 360 | echo "Building extra TF rule(s): $tf_extra_rules" |
| 361 | echo " Arguments: $@" |
| 362 | |
| 363 | local tf_env="$workspace/tf.env" |
| 364 | |
| 365 | if [ -f "$tf_env" ]; then |
| 366 | set -a |
| 367 | source "$tf_env" |
| 368 | set +a |
| 369 | fi |
| 370 | |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 371 | make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 BUILD_BASE=$tf_build_root "$@" \ |
Sandrine Bailleux | 189fdb3 | 2023-10-20 13:41:22 +0200 | [diff] [blame] | 372 | ${tf_extra_rules} &>>"$build_log" || fail_build |
| 373 | ) |
| 374 | } |
| 375 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 376 | fip_update() { |
| 377 | # Before the update process, check if the given image is supported by |
| 378 | # the fiptool. It's assumed that both fiptool and cert_create move in |
Chris Kay | 197b102 | 2023-08-16 21:31:41 +0100 | [diff] [blame] | 379 | # tandem, and therefore, if one has support, the other has it too. |
| 380 | if ! ("$fiptool" update 2>&1 || true) | grep -qe "\s\+--${bin_name:?}"; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 381 | return 1 |
| 382 | fi |
| 383 | |
| 384 | if not_upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then |
| 385 | echo "Updating FIP image: $bin_name" |
| 386 | # Update HW config. Without TBBR, it's only a matter of using |
| 387 | # the update sub-command of fiptool |
| 388 | "$fiptool" update "--$bin_name" "${src:-}" \ |
| 389 | "$archive/fip.bin" |
| 390 | else |
| 391 | echo "Updating FIP image (TBBR): $bin_name" |
| 392 | # With TBBR, we need to unpack, re-create certificates, and then |
| 393 | # recreate the FIP. |
| 394 | local fip_dir="$(mktempdir)" |
| 395 | local bin common_args stem |
| 396 | local rot_key="$(get_tf_opt ROT_KEY)" |
| 397 | |
| 398 | rot_key="${rot_key:?}" |
| 399 | if ! is_abs "$rot_key"; then |
| 400 | rot_key="$tf_root/$rot_key" |
| 401 | fi |
| 402 | |
| 403 | # Arguments only for cert_create |
| 404 | local cert_args="-n" |
| 405 | cert_args+=" --tfw-nvctr ${nvctr:-31}" |
| 406 | cert_args+=" --ntfw-nvctr ${nvctr:-223}" |
| 407 | cert_args+=" --key-alg ${KEY_ALG:-rsa}" |
| 408 | cert_args+=" --rot-key $rot_key" |
| 409 | |
| 410 | local dyn_config_opts=( |
Zelalem | 1af7a7b | 2020-08-04 17:34:32 -0500 | [diff] [blame] | 411 | "fw-config" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 412 | "hw-config" |
| 413 | "tb-fw-config" |
| 414 | "nt-fw-config" |
| 415 | "soc-fw-config" |
| 416 | "tos-fw-config" |
| 417 | ) |
| 418 | |
| 419 | # Binaries without key certificates |
| 420 | declare -A has_no_key_cert |
| 421 | for bin in "tb-fw" "${dyn_config_opts[@]}"; do |
| 422 | has_no_key_cert["$bin"]="1" |
| 423 | done |
| 424 | |
| 425 | # Binaries without certificates |
| 426 | declare -A has_no_cert |
| 427 | for bin in "hw-config" "${dyn_config_opts[@]}"; do |
| 428 | has_no_cert["$bin"]="1" |
| 429 | done |
| 430 | |
| 431 | pushd "$fip_dir" |
| 432 | |
| 433 | # Unpack FIP |
| 434 | "$fiptool" unpack "$archive/fip.bin" &>>"$build_log" |
| 435 | |
| 436 | # Remove all existing certificates |
| 437 | rm -f *-cert.bin |
| 438 | |
| 439 | # Copy the binary to be updated |
| 440 | cp -f "$src" "${bin_name}.bin" |
| 441 | |
| 442 | # FIP unpack dumps binaries with the same name as the option |
| 443 | # used to pack it; likewise for certificates. Reverse-engineer |
| 444 | # the command line from the binary output. |
| 445 | common_args="--trusted-key-cert trusted_key.crt" |
| 446 | for bin in *.bin; do |
| 447 | stem="${bin%%.bin}" |
| 448 | common_args+=" --$stem $bin" |
| 449 | if not_upon "${has_no_cert[$stem]}"; then |
| 450 | common_args+=" --$stem-cert $stem.crt" |
| 451 | fi |
| 452 | if not_upon "${has_no_key_cert[$stem]}"; then |
| 453 | common_args+=" --$stem-key-cert $stem-key.crt" |
| 454 | fi |
| 455 | done |
| 456 | |
| 457 | # Create certificates |
| 458 | "$cert_create" $cert_args $common_args &>>"$build_log" |
| 459 | |
| 460 | # Recreate and archive FIP |
| 461 | "$fiptool" create $common_args "fip.bin" &>>"$build_log" |
| 462 | archive_file "fip.bin" |
| 463 | |
| 464 | popd |
| 465 | fi |
| 466 | } |
| 467 | |
| 468 | # Update hw-config in FIP, and remove the original DTB afterwards. |
| 469 | update_fip_hw_config() { |
| 470 | # The DTB needs to be loaded by the model (and not updated in the FIP) |
Madhukar Pappireddy | 9062ebf | 2021-03-02 17:07:06 -0600 | [diff] [blame] | 471 | # in configs: |
| 472 | # 1. Where BL2 isn't present |
| 473 | # 2. Where we boot to Linux directly as BL33 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 474 | case "1" in |
| 475 | "$(get_tf_opt RESET_TO_BL31)" | \ |
Madhukar Pappireddy | 9062ebf | 2021-03-02 17:07:06 -0600 | [diff] [blame] | 476 | "$(get_tf_opt ARM_LINUX_KERNEL_AS_BL33)" | \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 477 | "$(get_tf_opt RESET_TO_SP_MIN)" | \ |
Maksims Svecovs | 7a0da52 | 2023-03-06 16:28:27 +0000 | [diff] [blame] | 478 | "$(get_tf_opt RESET_TO_BL2)") |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 479 | return 0;; |
| 480 | esac |
| 481 | |
| 482 | if bin_name="hw-config" src="$archive/dtb.bin" fip_update; then |
| 483 | # Remove the DTB so that model won't load it |
| 484 | rm -f "$archive/dtb.bin" |
| 485 | fi |
| 486 | } |
| 487 | |
| 488 | get_scp_opt() { |
| 489 | ( |
| 490 | name="${1:?}" |
| 491 | if config_valid "$scp_config_file"; then |
| 492 | source "$scp_config_file" |
| 493 | echo "${!name}" |
| 494 | fi |
| 495 | ) |
| 496 | } |
| 497 | |
| 498 | get_tftf_opt() { |
| 499 | ( |
| 500 | name="${1:?}" |
| 501 | if config_valid "$tftf_config_file"; then |
| 502 | source "$tftf_config_file" |
| 503 | echo "${!name}" |
| 504 | fi |
| 505 | ) |
| 506 | } |
| 507 | |
| 508 | get_tf_opt() { |
| 509 | ( |
| 510 | name="${1:?}" |
| 511 | if config_valid "$tf_config_file"; then |
| 512 | source "$tf_config_file" |
| 513 | echo "${!name}" |
| 514 | fi |
| 515 | ) |
| 516 | } |
| 517 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 518 | get_rmm_opt() { |
| 519 | ( |
| 520 | name="${1:?}" |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 521 | default="$2" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 522 | if config_valid "$rmm_config_file"; then |
| 523 | source "$rmm_config_file" |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 524 | # If !name is not defined, go with the default |
| 525 | # value (if defined) |
| 526 | if [ -z "${!name}" ]; then |
| 527 | echo "$default" |
| 528 | else |
| 529 | echo "${!name}" |
| 530 | fi |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 531 | fi |
| 532 | ) |
| 533 | } |
| 534 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 535 | build_tf() { |
| 536 | ( |
| 537 | env_file="$workspace/tf.env" |
| 538 | config_file="${tf_build_config:-$tf_config_file}" |
| 539 | |
| 540 | # Build fiptool and all targets by default |
Harrison Mutai | 32de9d0 | 2023-06-12 14:23:37 +0100 | [diff] [blame] | 541 | build_targets="${tf_build_targets:-fiptool all}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 542 | |
| 543 | source "$config_file" |
| 544 | |
| 545 | # If it is a TBBR build, extract the MBED TLS library from archive |
Manish V Badarkhe | 8f12501 | 2021-12-21 05:47:52 +0000 | [diff] [blame] | 546 | if [ "$(get_tf_opt TRUSTED_BOARD_BOOT)" = 1 ] || |
Manish V Badarkhe | f43e3f5 | 2022-06-21 20:37:25 +0100 | [diff] [blame] | 547 | [ "$(get_tf_opt MEASURED_BOOT)" = 1 ] || |
| 548 | [ "$(get_tf_opt DRTM_SUPPORT)" = 1 ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 549 | mbedtls_dir="$workspace/mbedtls" |
| 550 | if [ ! -d "$mbedtls_dir" ]; then |
| 551 | mbedtls_ar="$workspace/mbedtls.tar.gz" |
| 552 | |
| 553 | url="$mbedtls_archive" saveas="$mbedtls_ar" fetch_file |
| 554 | mkdir "$mbedtls_dir" |
Leonardo Sandoval | ec9e16c | 2020-09-09 14:32:40 -0500 | [diff] [blame] | 555 | extract_tarball $mbedtls_ar $mbedtls_dir --strip-components=1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 556 | fi |
| 557 | |
| 558 | emit_env "MBEDTLS_DIR" "$mbedtls_dir" |
| 559 | fi |
Jimmy Brisson | 0d5e12c | 2023-05-16 14:51:51 -0500 | [diff] [blame] | 560 | if [ "$(get_tf_opt PLATFORM_TEST)" = "tfm-testsuite" ] && |
| 561 | not_upon "${TF_M_TESTS_PATH}"; then |
| 562 | emit_env "TF_M_TESTS_PATH" "$WORKSPACE/tf-m-tests" |
| 563 | fi |
| 564 | if [ "$(get_tf_opt PLATFORM_TEST)" = "tfm-testsuite" ] && |
| 565 | not_upon "${TF_M_EXTRAS_PATH}"; then |
| 566 | emit_env "TF_M_EXTRAS_PATH" "$WORKSPACE/tf-m-extras" |
| 567 | fi |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 568 | if [ "$(get_tf_opt DICE_PROTECTION_ENVIRONMENT)" = 1 ] && |
| 569 | not_upon "${QCBOR_DIR}"; then |
| 570 | emit_env "QCBOR_DIR" "$WORKSPACE/qcbor" |
| 571 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 572 | if [ -f "$env_file" ]; then |
| 573 | set -a |
| 574 | source "$env_file" |
| 575 | set +a |
| 576 | fi |
| 577 | |
Harrison Mutai | 013f633 | 2022-02-16 16:06:33 +0000 | [diff] [blame] | 578 | if is_arm_jenkins_env || upon "$local_ci"; then |
| 579 | path_list=( |
| 580 | "$llvm_dir/bin" |
| 581 | ) |
| 582 | extend_path "PATH" "path_list" |
| 583 | fi |
| 584 | |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 585 | pushd "$tf_root" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 586 | |
| 587 | # Always distclean when running on Jenkins. Skip distclean when running |
| 588 | # locally and explicitly requested. |
| 589 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 590 | make distclean BUILD_BASE=$tf_build_root &>>"$build_log" || fail_build |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 591 | fi |
| 592 | |
| 593 | # Log build command line. It is left unfolded on purpose to assist |
| 594 | # copying to clipboard. |
| 595 | cat <<EOF | log_separator >/dev/null |
| 596 | |
| 597 | Build command line: |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 598 | $tf_build_wrapper make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 BUILD_BASE=$tf_build_root $build_targets |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 599 | |
Paul Sokolovsky | 7f71b07 | 2023-10-16 12:59:09 +0300 | [diff] [blame] | 600 | CC version: |
| 601 | $(${CC-${CROSS_COMPILE}gcc} -v 2>&1) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 602 | EOF |
| 603 | |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 604 | if not_upon "$local_ci"; then |
| 605 | connect_debugger=0 |
| 606 | fi |
| 607 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 608 | # Build TF. Since build output is being directed to the build log, have |
| 609 | # descriptor 3 point to the current terminal for build wrappers to vent. |
Harrison Mutai | 6361dbe | 2023-02-16 14:12:40 +0000 | [diff] [blame] | 610 | $tf_build_wrapper poetry run make $make_j_opts $(cat "$config_file") \ |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 611 | DEBUG="$DEBUG" V=1 BUILD_BASE="$tf_build_root" SPIN_ON_BL1_EXIT="$connect_debugger" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 612 | $build_targets 3>&1 &>>"$build_log" || fail_build |
Harrison Mutai | 32de9d0 | 2023-06-12 14:23:37 +0100 | [diff] [blame] | 613 | |
Harrison Mutai | 6dafb5f | 2023-07-18 15:21:48 +0100 | [diff] [blame] | 614 | if [ "$build_targets" != "doc" ]; then |
Chris Kay | 9ab2d95 | 2025-05-29 13:46:24 +0100 | [diff] [blame] | 615 | (poetry run memory --root "$tf_build_root" symbols 2>&1 || true) | tee -a "${build_log}" |
| 616 | |
| 617 | for map in $(find "${tf_build_root}" -name '*.map'); do |
| 618 | (poetry run memory --root "${tf_build_root}" summary "${map}" 2>&1 || true) | tee -a "${build_log}" |
| 619 | done |
Harrison Mutai | 6dafb5f | 2023-07-18 15:21:48 +0100 | [diff] [blame] | 620 | fi |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 621 | popd |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 622 | ) |
| 623 | } |
| 624 | |
| 625 | build_tftf() { |
| 626 | ( |
| 627 | config_file="${tftf_build_config:-$tftf_config_file}" |
| 628 | |
| 629 | # Build tftf target by default |
| 630 | build_targets="${tftf_build_targets:-all}" |
| 631 | |
| 632 | source "$config_file" |
| 633 | |
| 634 | cd "$tftf_root" |
| 635 | |
| 636 | # Always distclean when running on Jenkins. Skip distclean when running |
| 637 | # locally and explicitly requested. |
| 638 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 639 | make distclean BUILD_BASE="$tftf_build_root" &>>"$build_log" || fail_build |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 640 | fi |
| 641 | |
| 642 | # TFTF build system cannot reliably deal with -j option, so we avoid |
| 643 | # using that. |
| 644 | |
| 645 | # Log build command line |
| 646 | cat <<EOF | log_separator >/dev/null |
| 647 | |
| 648 | Build command line: |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 649 | make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 BUILD_BASE="$tftf_build_root" $build_targets |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 650 | |
| 651 | EOF |
| 652 | |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 653 | make $make_j_opts $(cat "$config_file") DEBUG="$DEBUG" V=1 BUILD_BASE="$tftf_build_root" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 654 | $build_targets &>>"$build_log" || fail_build |
| 655 | ) |
| 656 | } |
| 657 | |
| 658 | build_scp() { |
| 659 | ( |
| 660 | config_file="${scp_build_config:-$scp_config_file}" |
| 661 | |
| 662 | source "$config_file" |
| 663 | |
| 664 | cd "$scp_root" |
| 665 | |
| 666 | # Always distclean when running on Jenkins. Skip distclean when running |
| 667 | # locally and explicitly requested. |
| 668 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
Leandro Belli | 99e20b2 | 2022-12-29 13:50:47 +0000 | [diff] [blame] | 669 | make -f Makefile.cmake clean &>>"$build_log" || fail_build |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 670 | fi |
| 671 | |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 672 | python3 -m venv .venv |
| 673 | . .venv/bin/activate |
| 674 | |
| 675 | # Install extra tools used by CMake build system |
| 676 | pip install -r requirements.txt --timeout 30 --retries 15 |
| 677 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 678 | # Log build command line. It is left unfolded on purpose to assist |
| 679 | # copying to clipboard. |
| 680 | cat <<EOF | log_separator >/dev/null |
| 681 | |
| 682 | SCP build command line: |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 683 | make -f Makefile.cmake $(cat "$config_file" | tr '\n' ' ') \ |
| 684 | TOOLCHAIN=GNU \ |
| 685 | MODE="$mode" \ |
Nicola Mazzucato | 506b580 | 2021-12-24 14:23:25 +0000 | [diff] [blame] | 686 | EXTRA_CONFIG_ARGS+=-DDISABLE_CPPCHECK=true \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 687 | V=1 &>>"$build_log" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 688 | |
| 689 | EOF |
| 690 | |
| 691 | # Build SCP |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 692 | make -f Makefile.cmake $(cat "$config_file" | tr '\n' ' ') \ |
| 693 | TOOLCHAIN=GNU \ |
| 694 | MODE="$mode" \ |
Nicola Mazzucato | 506b580 | 2021-12-24 14:23:25 +0000 | [diff] [blame] | 695 | EXTRA_CONFIG_ARGS+=-DDISABLE_CPPCHECK=true \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 696 | V=1 &>>"$build_log" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 697 | || fail_build |
| 698 | ) |
| 699 | } |
| 700 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 701 | clone_scp_tools() { |
| 702 | |
| 703 | if [ ! -d "$scp_tools_root" ]; then |
| 704 | echo "Cloning SCP-tools ... $scp_tools_commit" |& log_separator |
| 705 | |
| 706 | clone_url="${SCP_TOOLS_CHECKOUT_LOC:-$scp_tools_src_repo_url}" \ |
| 707 | where="$scp_tools_root" \ |
| 708 | refspec="${scp_tools_commit}" |
| 709 | clone_repo &>>"$build_log" |
| 710 | else |
| 711 | echo "Already cloned SCP-tools ..." |& log_separator |
| 712 | fi |
| 713 | |
| 714 | show_head "$scp_tools_root" |
| 715 | |
| 716 | cd "$scp_tools_root" |
| 717 | |
| 718 | echo "Updating submodules" |
| 719 | |
| 720 | git submodule init |
| 721 | |
| 722 | git submodule update |
| 723 | |
Nicola Mazzucato | 9b17142 | 2023-08-29 15:50:49 +0100 | [diff] [blame] | 724 | lib_commit=$(grep "'scmi_lib_commit'" run_tests/settings.py | cut -d':' -f 2 | tr -d "'" | tr -d ",") |
Nicola Mazzucato | 7302cd3 | 2021-12-14 13:36:57 +0000 | [diff] [blame] | 725 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 726 | cd "scmi" |
Nicola Mazzucato | 7302cd3 | 2021-12-14 13:36:57 +0000 | [diff] [blame] | 727 | git checkout $lib_commit |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 728 | |
| 729 | git show --quiet --no-color | sed 's/^/ > /g' |
| 730 | } |
| 731 | |
| 732 | clone_tf_for_scp_tools() { |
| 733 | scp_tools_arm_tf="$scp_tools_root/arm-tf" |
| 734 | |
| 735 | if [ ! -d "$scp_tools_arm_tf" ]; then |
| 736 | echo "Cloning TF-4-SCP-tools ..." |& log_separator |
| 737 | |
| 738 | clone_url="$tf_for_scp_tools_src_repo_url" |
| 739 | where="$scp_tools_arm_tf" |
| 740 | |
| 741 | git clone "$clone_url" "$where" |
| 742 | |
| 743 | cd "$scp_tools_arm_tf" |
| 744 | |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 745 | git checkout --track origin/juno-v4.3 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 746 | |
| 747 | git show --quiet --no-color | sed 's/^/ > /g' |
| 748 | |
| 749 | else |
| 750 | echo "Already cloned TF-4-SCP-tools ..." |& log_separator |
| 751 | fi |
| 752 | } |
| 753 | |
| 754 | build_scmi_lib_scp_tools() { |
| 755 | ( |
| 756 | cd "$scp_tools_root" |
| 757 | |
| 758 | cd "scmi" |
| 759 | |
| 760 | scp_tools_arm_tf="$scp_tools_root/arm-tf" |
| 761 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 762 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 763 | |
| 764 | std_libs="-I$scp_tools_arm_tf/include/common" |
| 765 | std_libs="$std_libs -I$scp_tools_arm_tf/include/common/tbbr" |
| 766 | std_libs="$std_libs -I$scp_tools_arm_tf/include/drivers/arm" |
| 767 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib" |
| 768 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/aarch64" |
| 769 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib" |
| 770 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib/sys" |
| 771 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/xlat_tables" |
| 772 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/common" |
| 773 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/common" |
| 774 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/css/common" |
| 775 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/board/common" |
| 776 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/soc/common" |
| 777 | std_libs="$std_libs -I$scp_tools_arm_tf/plat/arm/board/juno/include" |
| 778 | |
| 779 | cflags="-Og -g" |
| 780 | cflags="$cflags -mgeneral-regs-only" |
| 781 | cflags="$cflags -mstrict-align" |
| 782 | cflags="$cflags -nostdinc" |
| 783 | cflags="$cflags -fno-inline" |
| 784 | cflags="$cflags -ffreestanding" |
| 785 | cflags="$cflags -ffunction-sections" |
| 786 | cflags="$cflags -fdata-sections" |
| 787 | cflags="$cflags -DAARCH64" |
| 788 | cflags="$cflags -DPRId32=\"ld\"" |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 789 | cflags="$cflags -DVERBOSE_LEVEL=3" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 790 | |
| 791 | cflags="$cflags $std_libs" |
| 792 | |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 793 | protocols="performance,power_domain,system_power,reset" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 794 | |
| 795 | echo "Building SCMI library (SCP-tools) ..." |
| 796 | |
| 797 | make "CROSS_COMPILE=$cross_compile" \ |
| 798 | "CFLAGS=$cflags" \ |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 799 | "PLAT=baremetal" \ |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 800 | "PROTOCOLS=$protocols" \ |
| 801 | "clean" \ |
| 802 | "all" |
| 803 | ) |
| 804 | } |
| 805 | |
| 806 | build_tf_for_scp_tools() { |
| 807 | |
| 808 | cd "$scp_tools_root/arm-tf" |
| 809 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 810 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 811 | |
| 812 | if [ "$1" = "release" ]; then |
| 813 | echo "Build TF-4-SCP-Tools rls..." |
| 814 | else |
| 815 | echo "Build TF-4-SCP-Tools dbg..." |
| 816 | |
| 817 | make realclean |
| 818 | |
| 819 | make "BM_TEST=scmi" \ |
| 820 | "ARM_BOARD_OPTIMISE_MEM=1" \ |
| 821 | "BM_CSS=juno" \ |
| 822 | "CSS_USE_SCMI_SDS_DRIVER=1" \ |
| 823 | "PLAT=juno" \ |
| 824 | "DEBUG=1" \ |
| 825 | "PLATFORM=juno" \ |
| 826 | "CROSS_COMPILE=$cross_compile" \ |
| 827 | "BM_WORKSPACE=$scp_tools_root/baremetal" |
| 828 | |
| 829 | archive_file "build/juno/debug/bl1.bin" |
| 830 | |
| 831 | archive_file "build/juno/debug/bl2.bin" |
| 832 | |
| 833 | archive_file "build/juno/debug/bl31.bin" |
| 834 | fi |
| 835 | } |
| 836 | |
| 837 | build_fip_for_scp_tools() { |
| 838 | |
| 839 | cd "$scp_tools_root/arm-tf" |
| 840 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 841 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 842 | |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 843 | if [ ! -d "$scp_root/build/juno/GNU/debug/firmware-scp_ramfw" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 844 | make fiptool |
| 845 | echo "Make FIP 4 SCP-Tools rls..." |
| 846 | |
| 847 | else |
| 848 | make fiptool |
| 849 | echo "Make FIP 4 SCP-Tools dbg..." |
| 850 | |
| 851 | make "PLAT=juno" \ |
| 852 | "all" \ |
| 853 | "fip" \ |
| 854 | "DEBUG=1" \ |
| 855 | "CROSS_COMPILE=$cross_compile" \ |
| 856 | "BL31=$scp_tools_root/arm-tf/build/juno/debug/bl31.bin" \ |
| 857 | "BL33=$scp_tools_root/baremetal/dummy_bl33" \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 858 | "SCP_BL2=$scp_root/build/juno/GNU/$mode/firmware-scp_ramfw/bin/juno-bl2.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 859 | |
| 860 | archive_file "$scp_tools_root/arm-tf/build/juno/debug/fip.bin" |
| 861 | fi |
| 862 | } |
| 863 | |
| 864 | build_cc() { |
| 865 | # Building code coverage plugin |
| 866 | ARM_DIR=/arm |
| 867 | pvlibversion=$(/arm/devsys-tools/abs/detag "SysGen:PVModelLib:$model_version::trunk") |
| 868 | PVLIB_HOME=$warehouse/SysGen/PVModelLib/$model_version/${pvlibversion}/external |
| 869 | if [ -n "$(find "$ARM_DIR" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then |
| 870 | echo "Error: Arm warehouse not mounted. Please mount the Arm warehouse to your /arm local folder" |
| 871 | exit -1 |
| 872 | fi # Error if arm warehouse not found |
| 873 | cd "$ccpathspec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov" |
| 874 | |
| 875 | make -C model-plugin PVLIB_HOME=$PVLIB_HOME &>>"$build_log" |
| 876 | } |
| 877 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 878 | build_spm() { |
| 879 | ( |
| 880 | env_file="$workspace/spm.env" |
| 881 | config_file="${spm_build_config:-$spm_config_file}" |
| 882 | |
| 883 | source "$config_file" |
| 884 | |
| 885 | if [ -f "$env_file" ]; then |
| 886 | set -a |
| 887 | source "$env_file" |
| 888 | set +a |
| 889 | fi |
| 890 | |
| 891 | cd "$spm_root" |
| 892 | |
| 893 | # Always clean when running on Jenkins. Skip clean when running |
| 894 | # locally and explicitly requested. |
| 895 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 896 | # make clean fails on a fresh repo where the project has not |
| 897 | # yet been built. Hence only clean if out/reference directory |
| 898 | # already exists. |
| 899 | if [ -d "out/reference" ]; then |
| 900 | make clean &>>"$build_log" || fail_build |
| 901 | fi |
| 902 | fi |
| 903 | |
| 904 | # Log build command line. It is left unfolded on purpose to assist |
| 905 | # copying to clipboard. |
| 906 | cat <<EOF | log_separator >/dev/null |
| 907 | |
| 908 | Build command line: |
| 909 | make $make_j_opts $(cat "$config_file" | tr '\n' ' ') |
| 910 | |
| 911 | EOF |
| 912 | |
| 913 | # Build SPM. Since build output is being directed to the build log, have |
| 914 | # descriptor 3 point to the current terminal for build wrappers to vent. |
| 915 | make $make_j_opts $(cat "$config_file") 3>&1 &>>"$build_log" \ |
| 916 | || fail_build |
| 917 | ) |
| 918 | } |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 919 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 920 | build_rmm() { |
| 921 | ( |
| 922 | env_file="$workspace/rmm.env" |
| 923 | config_file="${rmm_build_config:-$rmm_config_file}" |
| 924 | |
| 925 | # Build fiptool and all targets by default |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 926 | export CROSS_COMPILE="${aarch64_none_elf_prefix}" |
| 927 | |
| 928 | source "$config_file" |
| 929 | |
| 930 | if [ -f "$env_file" ]; then |
| 931 | set -a |
| 932 | source "$env_file" |
| 933 | set +a |
| 934 | fi |
| 935 | |
| 936 | cd "$rmm_root" |
| 937 | |
| 938 | if [ -f "$rmm_root/requirements.txt" ]; then |
| 939 | export PATH="$HOME/.local/bin:$PATH" |
| 940 | python3 -m pip install --upgrade pip |
| 941 | python3 -m pip install -r "$rmm_root/requirements.txt" |
| 942 | fi |
| 943 | |
| 944 | # Always distclean when running on Jenkins. Skip distclean when running |
| 945 | # locally and explicitly requested. |
| 946 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 947 | # Remove 'rmm\build' folder |
| 948 | echo "Removing $rmm_build_root..." |
| 949 | rm -rf $rmm_build_root |
| 950 | fi |
| 951 | |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 952 | if not_upon "$local_ci"; then |
| 953 | connect_debugger=0 |
| 954 | fi |
| 955 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 956 | # Log build command line. It is left unfolded on purpose to assist |
| 957 | # copying to clipboard. |
| 958 | cat <<EOF | log_separator >/dev/null |
| 959 | |
| 960 | Build command line: |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 961 | cmake -DRMM_CONFIG=${plat}_defcfg "$cmake_gen" -S $rmm_root -B $rmm_build_root -DRMM_TOOLCHAIN=$rmm_toolchain -DRMM_FPU_USE_AT_REL2=$rmm_fpu_use_at_rel2 -DATTEST_EL3_TOKEN_SIGN=$rmm_attest_el3_token_sign -DRMM_V1_1=$rmm_v1_1 ${extra_options} |
| 962 | cmake --build $rmm_build_root --config $cmake_build_type $make_j_opts -v ${extra_targets+-- $extra_targets} |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 963 | |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 964 | EOF |
| 965 | cmake \ |
| 966 | -DRMM_CONFIG=${plat}_defcfg $cmake_gen \ |
| 967 | -S $rmm_root -B $rmm_build_root \ |
| 968 | -DRMM_TOOLCHAIN=$rmm_toolchain \ |
| 969 | -DRMM_FPU_USE_AT_REL2=$rmm_fpu_use_at_rel2 \ |
| 970 | -DATTEST_EL3_TOKEN_SIGN=$rmm_attest_el3_token_sign \ |
| 971 | -DRMM_V1_1=$rmm_v1_1 \ |
| 972 | ${extra_options} |
| 973 | cmake --build $rmm_build_root --config $cmake_build_type $make_j_opts -v ${extra_targets+-- $extra_targets} 3>&1 &>>"$build_log" || fail_build |
| 974 | ) |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 975 | } |
| 976 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 977 | # Set metadata for the whole package so that it can be used by both Jenkins and |
| 978 | # shell |
| 979 | set_package_var() { |
| 980 | env_file="$artefacts/env" emit_env "$@" |
| 981 | } |
| 982 | |
| 983 | set_tf_build_targets() { |
| 984 | echo "Set build target to '${targets:?}'" |
| 985 | set_hook_var "tf_build_targets" "$targets" |
| 986 | } |
| 987 | |
| 988 | set_tftf_build_targets() { |
| 989 | echo "Set build target to '${targets:?}'" |
| 990 | set_hook_var "tftf_build_targets" "$targets" |
| 991 | } |
| 992 | |
| 993 | set_scp_build_targets() { |
| 994 | echo "Set build target to '${targets:?}'" |
| 995 | set_hook_var "scp_build_targets" "$targets" |
| 996 | } |
| 997 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 998 | set_spm_build_targets() { |
| 999 | echo "Set build target to '${targets:?}'" |
| 1000 | set_hook_var "spm_build_targets" "$targets" |
| 1001 | } |
| 1002 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 1003 | set_spm_out_dir() { |
| 1004 | echo "Set SPMC binary build to '${out_dir:?}'" |
| 1005 | set_hook_var "spm_secure_out_dir" "$out_dir" |
| 1006 | } |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1007 | # Look under $archive directory for known files such as blX images, kernel, DTB, |
| 1008 | # initrd etc. For each known file foo, if foo.bin exists, then set variable |
| 1009 | # foo_bin to the path of the file. Make the path relative to the workspace so as |
| 1010 | # to remove any @ characters, which Jenkins inserts for parallel runs. If the |
| 1011 | # file doesn't exist, unset its path. |
| 1012 | set_default_bin_paths() { |
| 1013 | local image image_name image_path path |
| 1014 | local archive="${archive:?}" |
| 1015 | local set_vars |
| 1016 | local var |
| 1017 | |
| 1018 | pushd "$archive" |
| 1019 | |
| 1020 | for file in *.bin; do |
| 1021 | # Get a shell variable from the file's stem |
| 1022 | var_name="${file%%.*}_bin" |
| 1023 | var_name="$(echo "$var_name" | sed -r 's/[^[:alnum:]]/_/g')" |
| 1024 | |
| 1025 | # Skip setting the variable if it's already |
| 1026 | if [ "${!var_name}" ]; then |
| 1027 | echo "Note: not setting $var_name; already set to ${!var_name}" |
| 1028 | continue |
| 1029 | else |
| 1030 | set_vars+="$var_name " |
| 1031 | fi |
| 1032 | |
| 1033 | eval "$var_name=$file" |
| 1034 | done |
| 1035 | |
| 1036 | echo "Binary paths set for: " |
| 1037 | { |
| 1038 | for var in $set_vars; do |
| 1039 | echo -n "\$$var " |
| 1040 | done |
| 1041 | } | fmt -80 | sed 's/^/ /' |
| 1042 | echo |
| 1043 | |
| 1044 | popd |
| 1045 | } |
| 1046 | |
| 1047 | gen_model_params() { |
| 1048 | local model_param_file="$archive/model_params" |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 1049 | [ "$connect_debugger" ] && [ "$connect_debugger" -eq 1 ] && wait_debugger=1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1050 | |
| 1051 | set_default_bin_paths |
| 1052 | echo "Generating model parameter for $model..." |
| 1053 | source "$ci_root/model/${model:?}.sh" |
| 1054 | archive_file "$model_param_file" |
| 1055 | } |
| 1056 | |
| 1057 | set_model_path() { |
| 1058 | set_run_env "model_path" "${1:?}" |
| 1059 | } |
| 1060 | |
Zelalem | 1af7a7b | 2020-08-04 17:34:32 -0500 | [diff] [blame] | 1061 | set_model_env() { |
| 1062 | local var="${1:?}" |
| 1063 | local val="${2?}" |
| 1064 | local run_root="${archive:?}/run" |
| 1065 | |
| 1066 | mkdir -p "$run_root" |
| 1067 | echo "export $var=$val" >> "$run_root/model_env" |
| 1068 | } |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1069 | set_run_env() { |
| 1070 | local var="${1:?}" |
| 1071 | local val="${2?}" |
| 1072 | local run_root="${archive:?}/run" |
| 1073 | |
| 1074 | mkdir -p "$run_root" |
| 1075 | env_file="$run_root/env" quote="1" emit_env "$var" "$val" |
| 1076 | } |
| 1077 | |
| 1078 | show_head() { |
| 1079 | # Display HEAD descripton |
| 1080 | pushd "$1" |
| 1081 | git show --quiet --no-color | sed 's/^/ > /g' |
| 1082 | echo |
| 1083 | popd |
| 1084 | } |
| 1085 | |
| 1086 | # Choose debug binaries to run; by default, release binaries are chosen to run |
| 1087 | use_debug_bins() { |
| 1088 | local run_root="${archive:?}/run" |
| 1089 | |
| 1090 | echo "Choosing debug binaries for execution" |
| 1091 | set_package_var "BIN_MODE" "debug" |
| 1092 | } |
| 1093 | |
| 1094 | assert_can_git_clone() { |
| 1095 | local name="${1:?}" |
| 1096 | local dir="${!name}" |
| 1097 | |
| 1098 | # If it doesn't exist, it can be cloned into |
| 1099 | if [ ! -e "$dir" ]; then |
| 1100 | return 0 |
| 1101 | fi |
| 1102 | |
| 1103 | # If it's a directory, it must be a Git clone already |
| 1104 | if [ -d "$dir" ] && [ -d "$dir/.git" ]; then |
| 1105 | # No need to clone again |
| 1106 | echo "Using existing git clone for $name: $dir" |
| 1107 | return 1 |
| 1108 | fi |
| 1109 | |
| 1110 | die "Path $dir exists but is not a git clone" |
| 1111 | } |
| 1112 | |
| 1113 | clone_repo() { |
| 1114 | if ! is_url "${clone_url?}"; then |
| 1115 | # For --depth to take effect on local paths, it needs to use the |
| 1116 | # file:// scheme. |
| 1117 | clone_url="file://$clone_url" |
| 1118 | fi |
| 1119 | |
| 1120 | git clone -q --depth 1 "$clone_url" "${where?}" |
| 1121 | if [ "$refspec" ]; then |
| 1122 | pushd "$where" |
| 1123 | git fetch -q --depth 1 origin "$refspec" |
| 1124 | git checkout -q FETCH_HEAD |
| 1125 | popd |
| 1126 | fi |
| 1127 | } |
| 1128 | |
| 1129 | build_unstable() { |
| 1130 | echo "--BUILD UNSTABLE--" | tee -a "$build_log" |
| 1131 | } |
| 1132 | |
| 1133 | undo_patch_record() { |
| 1134 | if [ ! -f "${patch_record:?}" ]; then |
| 1135 | return |
| 1136 | fi |
| 1137 | |
| 1138 | # Undo patches in reverse |
| 1139 | echo |
| 1140 | for patch_name in $(tac "$patch_record"); do |
| 1141 | echo "Undoing $patch_name..." |
| 1142 | if ! git apply -R "$ci_root/patch/$patch_name"; then |
| 1143 | if upon "$local_ci"; then |
| 1144 | echo |
| 1145 | echo "Your local directory may have been dirtied." |
| 1146 | echo |
| 1147 | fi |
| 1148 | fail_build |
| 1149 | fi |
| 1150 | done |
| 1151 | |
| 1152 | rm -f "$patch_record" |
| 1153 | } |
| 1154 | |
| 1155 | undo_local_patches() { |
| 1156 | pushd "$tf_root" |
| 1157 | patch_record="$tf_patch_record" undo_patch_record |
| 1158 | popd |
| 1159 | |
| 1160 | if [ -d "$tftf_root" ]; then |
| 1161 | pushd "$tftf_root" |
| 1162 | patch_record="$tftf_patch_record" undo_patch_record |
| 1163 | popd |
| 1164 | fi |
| 1165 | } |
| 1166 | |
| 1167 | undo_tftf_patches() { |
| 1168 | pushd "$tftf_root" |
| 1169 | patch_record="$tftf_patch_record" undo_patch_record |
| 1170 | popd |
| 1171 | } |
| 1172 | |
| 1173 | undo_tf_patches() { |
| 1174 | pushd "$tf_root" |
| 1175 | patch_record="$tf_patch_record" undo_patch_record |
| 1176 | popd |
| 1177 | } |
| 1178 | |
| 1179 | apply_patch() { |
| 1180 | # If skip_patches is set, the developer has applied required patches |
| 1181 | # manually. They probably want to keep them applied for debugging |
| 1182 | # purposes too. This means we don't have to apply/revert them as part of |
| 1183 | # build process. |
| 1184 | if upon "$skip_patches"; then |
| 1185 | echo "Skipped applying ${1:?}..." |
| 1186 | return 0 |
| 1187 | else |
| 1188 | echo "Applying ${1:?}..." |
| 1189 | fi |
| 1190 | |
Sandrine Bailleux | 4cb8c22 | 2023-09-13 13:48:15 +0200 | [diff] [blame] | 1191 | if git apply --reverse --check < "$ci_root/patch/$1" 2> /dev/null; then |
Jimmy Brisson | f134e4c | 2023-03-22 13:20:20 -0500 | [diff] [blame] | 1192 | echo "Skipping already applied ${1:?}" |
| 1193 | return 0 |
| 1194 | fi |
| 1195 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1196 | if git apply < "$ci_root/patch/$1"; then |
| 1197 | echo "$1" >> "${patch_record:?}" |
| 1198 | else |
| 1199 | if upon "$local_ci"; then |
| 1200 | undo_local_patches |
| 1201 | fi |
| 1202 | fail_build |
| 1203 | fi |
| 1204 | } |
| 1205 | |
| 1206 | apply_tftf_patch() { |
| 1207 | pushd "$tftf_root" |
| 1208 | patch_record="$tftf_patch_record" apply_patch "$1" |
| 1209 | popd |
| 1210 | } |
| 1211 | |
| 1212 | apply_tf_patch() { |
| 1213 | pushd "$tf_root" |
| 1214 | patch_record="$tf_patch_record" apply_patch "$1" |
| 1215 | popd |
| 1216 | } |
| 1217 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1218 | mkdir -p "$workspace" |
| 1219 | mkdir -p "$archive" |
| 1220 | set_package_var "TEST_CONFIG" "$test_config" |
| 1221 | |
| 1222 | { |
| 1223 | echo |
| 1224 | echo "CONFIGURATION: $test_group/$test_config" |
| 1225 | echo |
| 1226 | } |& log_separator |
| 1227 | |
| 1228 | tf_config="$(echo "$build_configs" | awk -F, '{print $1}')" |
| 1229 | tftf_config="$(echo "$build_configs" | awk -F, '{print $2}')" |
| 1230 | scp_config="$(echo "$build_configs" | awk -F, '{print $3}')" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1231 | scp_tools_config="$(echo "$build_configs" | awk -F, '{print $4}')" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1232 | spm_config="$(echo "$build_configs" | awk -F, '{print $5}')" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1233 | rmm_config="$(echo "$build_configs" | awk -F, '{print $6}')" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1234 | |
| 1235 | test_config_file="$ci_root/group/$test_group/$test_config" |
| 1236 | |
| 1237 | tf_config_file="$ci_root/tf_config/$tf_config" |
| 1238 | tftf_config_file="$ci_root/tftf_config/$tftf_config" |
| 1239 | scp_config_file="$ci_root/scp_config/$scp_config" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1240 | scp_tools_config_file="$ci_root/scp_tools_config/$scp_tools_config" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1241 | spm_config_file="$ci_root/spm_config/$spm_config" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1242 | rmm_config_file="$ci_root/rmm_config/$rmm_config" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1243 | |
| 1244 | # File that keeps track of applied patches |
| 1245 | tf_patch_record="$workspace/tf_patches" |
| 1246 | tftf_patch_record="$workspace/tftf_patches" |
| 1247 | |
| 1248 | pushd "$workspace" |
| 1249 | |
| 1250 | if ! config_valid "$tf_config"; then |
| 1251 | tf_config= |
| 1252 | else |
| 1253 | echo "Trusted Firmware config:" |
| 1254 | echo |
| 1255 | sort "$tf_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1256 | echo |
| 1257 | fi |
| 1258 | |
| 1259 | if ! config_valid "$tftf_config"; then |
| 1260 | tftf_config= |
| 1261 | else |
| 1262 | echo "Trusted Firmware TF config:" |
| 1263 | echo |
| 1264 | sort "$tftf_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1265 | echo |
| 1266 | fi |
| 1267 | |
| 1268 | if ! config_valid "$scp_config"; then |
| 1269 | scp_config= |
| 1270 | else |
| 1271 | echo "SCP firmware config:" |
| 1272 | echo |
| 1273 | sort "$scp_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1274 | echo |
| 1275 | fi |
| 1276 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1277 | if ! config_valid "$scp_tools_config"; then |
| 1278 | scp_tools_config= |
| 1279 | else |
| 1280 | echo "SCP Tools config:" |
| 1281 | echo |
| 1282 | sort "$scp_tools_config_file" | sed '/^\s*$/d;s/^/\t/' |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1283 | fi |
| 1284 | |
| 1285 | if ! config_valid "$spm_config"; then |
| 1286 | spm_config= |
| 1287 | else |
| 1288 | echo "SPM config:" |
| 1289 | echo |
| 1290 | sort "$spm_config_file" | sed '/^\s*$/d;s/^/\t/' |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1291 | echo |
| 1292 | fi |
| 1293 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1294 | # File that keeps track of applied patches |
| 1295 | rmm_patch_record="$workspace/rmm_patches" |
| 1296 | |
| 1297 | if ! config_valid "$rmm_config"; then |
| 1298 | rmm_config= |
| 1299 | else |
| 1300 | echo "Trusted Firmware RMM config:" |
| 1301 | echo |
| 1302 | sort "$rmm_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1303 | echo |
| 1304 | fi |
| 1305 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1306 | if ! config_valid "$run_config"; then |
| 1307 | run_config= |
| 1308 | fi |
| 1309 | |
| 1310 | if [ "$tf_config" ] && assert_can_git_clone "tf_root"; then |
| 1311 | # If the Trusted Firmware repository has already been checked out, use |
| 1312 | # that location. Otherwise, clone one ourselves. |
| 1313 | echo "Cloning Trusted Firmware..." |
| 1314 | clone_url="${TF_CHECKOUT_LOC:-$tf_src_repo_url}" where="$tf_root" \ |
| 1315 | refspec="$TF_REFSPEC" clone_repo &>>"$build_log" |
| 1316 | show_head "$tf_root" |
| 1317 | fi |
| 1318 | |
| 1319 | if [ "$tftf_config" ] && assert_can_git_clone "tftf_root"; then |
| 1320 | # If the Trusted Firmware TF repository has already been checked out, |
| 1321 | # use that location. Otherwise, clone one ourselves. |
| 1322 | echo "Cloning Trusted Firmware TF..." |
| 1323 | clone_url="${TFTF_CHECKOUT_LOC:-$tftf_src_repo_url}" where="$tftf_root" \ |
| 1324 | refspec="$TFTF_REFSPEC" clone_repo &>>"$build_log" |
| 1325 | show_head "$tftf_root" |
| 1326 | fi |
| 1327 | |
| 1328 | if [ "$scp_config" ] && assert_can_git_clone "scp_root"; then |
| 1329 | # If the SCP firmware repository has already been checked out, |
| 1330 | # use that location. Otherwise, clone one ourselves. |
| 1331 | echo "Cloning SCP Firmware..." |
| 1332 | clone_url="${SCP_CHECKOUT_LOC:-$scp_src_repo_url}" where="$scp_root" \ |
| 1333 | refspec="${SCP_REFSPEC-master-upstream}" clone_repo &>>"$build_log" |
| 1334 | |
| 1335 | pushd "$scp_root" |
| 1336 | |
| 1337 | # Use filer submodule as a reference if it exists |
Girish Pathak | 31b824e | 2021-03-03 20:58:21 +0000 | [diff] [blame] | 1338 | if [ -d "$SCP_CHECKOUT_LOC/cmsis" ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1339 | cmsis_reference="--reference $SCP_CHECKOUT_LOC/cmsis" |
| 1340 | fi |
| 1341 | |
| 1342 | # If we don't have a reference yet, fall back to $cmsis_root if set, or |
| 1343 | # then to project filer if accessible. |
| 1344 | if [ -z "$cmsis_reference" ]; then |
| 1345 | cmsis_ref_repo="${cmsis_root:-$project_filer/ref-repos/cmsis}" |
| 1346 | if [ -d "$cmsis_ref_repo" ]; then |
| 1347 | cmsis_reference="--reference $cmsis_ref_repo" |
| 1348 | fi |
| 1349 | fi |
| 1350 | |
| 1351 | git submodule -q update $cmsis_reference --init |
| 1352 | |
| 1353 | popd |
| 1354 | |
| 1355 | show_head "$scp_root" |
| 1356 | fi |
| 1357 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1358 | if [ -n "$cc_config" ] ; then |
| 1359 | if [ "$cc_config" -eq 1 ] && assert_can_git_clone "cc_root"; then |
| 1360 | # Copy code coverage repository |
| 1361 | echo "Cloning Code Coverage..." |
| 1362 | git clone -q $cc_src_repo_url cc_plugin --depth 1 -b $cc_src_repo_tag > /dev/null |
| 1363 | show_head "$cc_root" |
| 1364 | fi |
| 1365 | fi |
| 1366 | |
Daniel Boulby | 25385ab | 2023-12-14 14:36:25 +0000 | [diff] [blame] | 1367 | if [ "$spm_config" ] ; then |
| 1368 | if assert_can_git_clone "spm_root"; then |
| 1369 | # If the SPM repository has already been checked out, use |
| 1370 | # that location. Otherwise, clone one ourselves. |
| 1371 | echo "Cloning SPM..." |
| 1372 | clone_url="${SPM_CHECKOUT_LOC:-$spm_src_repo_url}" \ |
| 1373 | where="$spm_root" refspec="$SPM_REFSPEC" \ |
| 1374 | clone_repo &>>"$build_log" |
| 1375 | fi |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1376 | |
| 1377 | # Query git submodules |
| 1378 | pushd "$spm_root" |
Daniel Boulby | 25385ab | 2023-12-14 14:36:25 +0000 | [diff] [blame] | 1379 | # Check if submodules need initialising |
Paul Sokolovsky | ad27442 | 2024-09-01 10:27:56 +0300 | [diff] [blame] | 1380 | |
| 1381 | # This handling is needed to reliably fetch submodules |
| 1382 | # in CI environment. |
| 1383 | for subm in $(git submodule status | awk '/^-/ {print $2}'); do |
| 1384 | for i in $(seq 1 7); do |
| 1385 | git submodule init $subm |
| 1386 | if git submodule update $subm; then |
| 1387 | break |
| 1388 | fi |
| 1389 | git submodule deinit --force $subm |
| 1390 | echo "Retrying $subm" |
| 1391 | sleep $((RANDOM % 10 + 5)) |
| 1392 | done |
| 1393 | done |
| 1394 | |
| 1395 | git submodule status |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1396 | popd |
| 1397 | |
| 1398 | show_head "$spm_root" |
| 1399 | fi |
| 1400 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1401 | if [ "$rmm_config" ] && assert_can_git_clone "rmm_root"; then |
Manish V Badarkhe | 4190945 | 2025-04-11 12:06:45 +0100 | [diff] [blame] | 1402 | # If the RMM repository has already been checked out, |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1403 | # use that location. Otherwise, clone one ourselves. |
| 1404 | echo "Cloning TF-RMM..." |
| 1405 | clone_url="${RMM_CHECKOUT_LOC:-$rmm_src_repo_url}" where="$rmm_root" \ |
| 1406 | refspec="$RMM_REFSPEC" clone_repo &>>"$build_log" |
| 1407 | show_head "$rmm_root" |
| 1408 | fi |
| 1409 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1410 | if [ "$run_config" ]; then |
| 1411 | # Get candidates for run config |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1412 | run_config_candidates="$("$ci_root/script/gen_run_config_candidates.py" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1413 | "$run_config")" |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1414 | if [ -z "$run_config_candidates" ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1415 | die "No run config candidates!" |
| 1416 | else |
| 1417 | echo |
| 1418 | echo "Chosen fragments:" |
| 1419 | echo |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1420 | echo "$run_config_candidates" | sed 's/^\|\n/\t/g' |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1421 | echo |
Harrison Mutai | 4dfe119 | 2024-07-03 12:35:38 +0000 | [diff] [blame] | 1422 | |
| 1423 | if [ ! -n "$bin_mode" ]; then |
| 1424 | if echo $run_config_candidates | grep -wq "debug"; then |
| 1425 | bin_mode="debug" |
| 1426 | else |
| 1427 | bin_mode="release" |
| 1428 | fi |
| 1429 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1430 | fi |
| 1431 | fi |
| 1432 | |
| 1433 | call_hook "test_setup" |
| 1434 | echo |
| 1435 | |
| 1436 | if upon "$local_ci"; then |
| 1437 | # For local runs, since each config is tried in sequence, it's |
| 1438 | # advantageous to run jobs in parallel |
| 1439 | if [ "$make_j" ]; then |
| 1440 | make_j_opts="-j $make_j" |
| 1441 | else |
| 1442 | n_cores="$(getconf _NPROCESSORS_ONLN)" 2>/dev/null || true |
| 1443 | if [ "$n_cores" ]; then |
| 1444 | make_j_opts="-j $n_cores" |
| 1445 | fi |
| 1446 | fi |
| 1447 | fi |
| 1448 | |
Harrison Mutai | 07043e9 | 2023-07-06 09:41:12 +0100 | [diff] [blame] | 1449 | # Install python build dependencies |
| 1450 | if is_arm_jenkins_env; then |
| 1451 | source "$ci_root/script/install_python_deps.sh" |
| 1452 | fi |
| 1453 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1454 | # Print CMake version |
| 1455 | cmake_ver=$(echo `cmake --version | sed -n '1p'`) |
| 1456 | echo "Using $cmake_ver" |
| 1457 | |
| 1458 | # Check for Ninja |
| 1459 | if [ -x "$(command -v ninja)" ]; then |
| 1460 | # Print Ninja version |
| 1461 | ninja_ver=$(echo `ninja --version | sed -n '1p'`) |
| 1462 | echo "Using ninja $ninja_ver" |
| 1463 | export cmake_gen="-G Ninja" |
| 1464 | else |
| 1465 | echo 'Ninja is not installed' |
| 1466 | export cmake_gen="" |
| 1467 | fi |
| 1468 | |
| 1469 | undo_rmm_patches() { |
| 1470 | pushd "$rmm_root" |
| 1471 | patch_record="$rmm_patch_record" undo_patch_record |
| 1472 | popd |
| 1473 | } |
| 1474 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1475 | modes="${bin_mode:-debug release}" |
| 1476 | for mode in $modes; do |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 1477 | echo "===== Building package in mode: $mode =====" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1478 | # Build with a temporary archive |
| 1479 | build_archive="$archive/$mode" |
| 1480 | mkdir "$build_archive" |
| 1481 | |
| 1482 | if [ "$mode" = "debug" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1483 | export bin_mode="debug" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1484 | cmake_build_type="Debug" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1485 | DEBUG=1 |
| 1486 | else |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1487 | export bin_mode="release" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1488 | cmake_build_type="Release" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1489 | DEBUG=0 |
| 1490 | fi |
| 1491 | |
| 1492 | # Perform builds in a subshell so as not to pollute the current and |
| 1493 | # subsequent builds' environment |
| 1494 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1495 | if config_valid "$cc_config"; then |
| 1496 | # Build code coverage plugin |
| 1497 | build_cc |
| 1498 | fi |
| 1499 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1500 | # SCP build |
| 1501 | if config_valid "$scp_config"; then |
| 1502 | ( |
| 1503 | echo "##########" |
| 1504 | |
| 1505 | # Source platform-specific utilities |
| 1506 | plat="$(get_scp_opt PRODUCT)" |
| 1507 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1508 | if [ -f "$plat_utils" ]; then |
| 1509 | source "$plat_utils" |
| 1510 | fi |
| 1511 | |
| 1512 | archive="$build_archive" |
| 1513 | scp_build_root="$scp_root/build" |
| 1514 | |
| 1515 | echo "Building SCP Firmware ($mode) ..." |& log_separator |
| 1516 | |
| 1517 | build_scp |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1518 | to="$archive" collect_scp_artefacts |
| 1519 | |
| 1520 | echo "##########" |
| 1521 | echo |
| 1522 | ) |
| 1523 | fi |
| 1524 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1525 | # SCP-tools build |
| 1526 | if config_valid "$scp_tools_config"; then |
| 1527 | ( |
| 1528 | echo "##########" |
| 1529 | |
| 1530 | archive="$build_archive" |
| 1531 | scp_tools_build_root="$scp_tools_root/build" |
| 1532 | |
| 1533 | clone_scp_tools |
| 1534 | |
| 1535 | echo "##########" |
| 1536 | echo |
| 1537 | |
| 1538 | echo "##########" |
| 1539 | clone_tf_for_scp_tools |
| 1540 | echo "##########" |
| 1541 | echo |
| 1542 | ) |
| 1543 | fi |
| 1544 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1545 | # TFTF build |
| 1546 | if config_valid "$tftf_config"; then |
| 1547 | ( |
| 1548 | echo "##########" |
| 1549 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1550 | plat_utils="$(get_tf_opt PLAT_UTILS)" |
| 1551 | if [ -z ${plat_utils} ]; then |
| 1552 | # Source platform-specific utilities. |
| 1553 | plat="$(get_tftf_opt PLAT)" |
| 1554 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1555 | else |
| 1556 | # Source platform-specific utilities by |
| 1557 | # using plat_utils name. |
| 1558 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1559 | fi |
| 1560 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1561 | if [ -f "$plat_utils" ]; then |
| 1562 | source "$plat_utils" |
| 1563 | fi |
| 1564 | |
| 1565 | archive="$build_archive" |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 1566 | tftf_build_root="$archive/build/tftf" |
| 1567 | mkdir -p ${tftf_build_root} |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1568 | |
| 1569 | echo "Building Trusted Firmware TF ($mode) ..." |& log_separator |
| 1570 | |
| 1571 | # Call pre-build hook |
| 1572 | call_hook pre_tftf_build |
| 1573 | |
| 1574 | build_tftf |
| 1575 | |
| 1576 | from="$tftf_build_root" to="$archive" collect_build_artefacts |
| 1577 | |
| 1578 | # Clear any local changes made by applied patches |
| 1579 | undo_tftf_patches |
| 1580 | |
| 1581 | echo "##########" |
| 1582 | echo |
| 1583 | ) |
| 1584 | fi |
| 1585 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1586 | # SPM build |
| 1587 | if config_valid "$spm_config"; then |
| 1588 | ( |
| 1589 | echo "##########" |
| 1590 | |
| 1591 | # Get platform name from spm_config file |
| 1592 | plat="$(echo "$spm_config" | awk -F- '{print $1}')" |
| 1593 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1594 | if [ -f "$plat_utils" ]; then |
| 1595 | source "$plat_utils" |
| 1596 | fi |
| 1597 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 1598 | # Call pre-build hook |
| 1599 | call_hook pre_spm_build |
| 1600 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1601 | # SPM build generates two sets of binaries, one for normal and other |
| 1602 | # for Secure world. We need both set of binaries for CI. |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1603 | archive="$build_archive" |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1604 | spm_build_root="$spm_root/out/reference/$spm_secure_out_dir" |
| 1605 | hafnium_build_root="$spm_root/out/reference/$spm_non_secure_out_dir" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1606 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 1607 | echo "spm_build_root is $spm_build_root" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1608 | echo "Building SPM ($mode) ..." |& log_separator |
| 1609 | |
| 1610 | # NOTE: mode has no effect on SPM build (for now), hence debug |
| 1611 | # mode is built but subsequent build using release mode just |
| 1612 | # goes through with "nothing to do". |
| 1613 | build_spm |
| 1614 | |
| 1615 | # Show SPM/Hafnium binary details |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 1616 | cksum $spm_build_root/hafnium.bin |
| 1617 | |
| 1618 | # Some platforms only have secure configuration enabled. Hence, |
| 1619 | # non secure hanfnium binary might not be built. |
| 1620 | if [ -f $hafnium_build_root/hafnium.bin ]; then |
| 1621 | cksum $hafnium_build_root/hafnium.bin |
| 1622 | fi |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1623 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1624 | secure_from="$spm_build_root" non_secure_from="$hafnium_build_root" to="$archive" collect_spm_artefacts |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1625 | |
| 1626 | echo "##########" |
| 1627 | echo |
| 1628 | ) |
| 1629 | fi |
| 1630 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1631 | # TF RMM build |
| 1632 | if config_valid "$rmm_config"; then |
| 1633 | ( |
| 1634 | echo "##########" |
| 1635 | |
| 1636 | plat_utils="$(get_rmm_opt PLAT_UTILS)" |
| 1637 | if [ -z ${plat_utils} ]; then |
| 1638 | # Source platform-specific utilities. |
| 1639 | plat="$(get_rmm_opt PLAT)" |
Manish V Badarkhe | a350527 | 2025-04-17 14:20:42 +0100 | [diff] [blame] | 1640 | extra_options="$(get_rmm_opt EXTRA_OPTIONS)" |
| 1641 | extra_targets="$(get_rmm_opt EXTRA_TARGETS "")" |
| 1642 | rmm_toolchain="$(get_rmm_opt TOOLCHAIN gnu)" |
| 1643 | rmm_fpu_use_at_rel2="$(get_rmm_opt RMM_FPU_USE_AT_REL2 OFF)" |
| 1644 | rmm_attest_el3_token_sign="$(get_rmm_opt ATTEST_EL3_TOKEN_SIGN OFF)" |
| 1645 | rmm_v1_1="$(get_rmm_opt RMM_V1_1 ON)" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1646 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1647 | else |
| 1648 | # Source platform-specific utilities by |
| 1649 | # using plat_utils name. |
| 1650 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1651 | fi |
| 1652 | |
| 1653 | if [ -f "$plat_utils" ]; then |
| 1654 | source "$plat_utils" |
| 1655 | fi |
| 1656 | |
| 1657 | archive="$build_archive" |
| 1658 | rmm_build_root="$rmm_root/build" |
| 1659 | |
| 1660 | echo "Building Trusted Firmware RMM ($mode) ..." |& log_separator |
| 1661 | |
| 1662 | #call_hook pre_rmm_build |
| 1663 | build_rmm |
| 1664 | |
| 1665 | # Collect all rmm.* files: rmm.img, rmm.elf, rmm.dump, rmm.map |
| 1666 | from="$rmm_build_root" to="$archive" collect_build_artefacts |
| 1667 | |
| 1668 | # Clear any local changes made by applied patches |
| 1669 | undo_rmm_patches |
| 1670 | |
| 1671 | echo "##########" |
| 1672 | ) |
| 1673 | fi |
| 1674 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1675 | # TF build |
| 1676 | if config_valid "$tf_config"; then |
| 1677 | ( |
| 1678 | echo "##########" |
| 1679 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1680 | plat_utils="$(get_tf_opt PLAT_UTILS)" |
Madhukar Pappireddy | 2f284e1 | 2021-08-30 16:06:14 -0500 | [diff] [blame] | 1681 | export plat_variant="$(get_tf_opt TARGET_PLATFORM)" |
| 1682 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1683 | if [ -z ${plat_utils} ]; then |
| 1684 | # Source platform-specific utilities. |
| 1685 | plat="$(get_tf_opt PLAT)" |
| 1686 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1687 | else |
| 1688 | # Source platform-specific utilities by |
| 1689 | # using plat_utils name. |
| 1690 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1691 | fi |
| 1692 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1693 | if [ -f "$plat_utils" ]; then |
| 1694 | source "$plat_utils" |
| 1695 | fi |
| 1696 | |
Chris Kay | e5a486b | 2023-08-04 11:50:31 +0000 | [diff] [blame] | 1697 | fvp_tsram_size="$(get_tf_opt FVP_TRUSTED_SRAM_SIZE)" |
| 1698 | fvp_tsram_size="${fvp_tsram_size:-256}" |
| 1699 | |
Harrison Mutai | dc70340 | 2024-08-02 14:40:16 +0000 | [diff] [blame] | 1700 | poetry -C "$tf_root" install --without docs |
Chris Kay | d083790 | 2021-11-17 10:17:52 +0000 | [diff] [blame] | 1701 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1702 | archive="$build_archive" |
Boyan Karatotev | 97de8d8 | 2025-03-06 15:22:21 +0000 | [diff] [blame^] | 1703 | tf_build_root="$archive/build/tfa" |
| 1704 | mkdir -p ${tf_build_root} |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1705 | |
| 1706 | echo "Building Trusted Firmware ($mode) ..." |& log_separator |
| 1707 | |
| 1708 | # Call pre-build hook |
| 1709 | call_hook pre_tf_build |
| 1710 | |
| 1711 | build_tf |
| 1712 | |
| 1713 | # Call post-build hook |
| 1714 | call_hook post_tf_build |
| 1715 | |
| 1716 | # Pre-archive hook |
| 1717 | call_hook pre_tf_archive |
| 1718 | |
| 1719 | from="$tf_build_root" to="$archive" collect_build_artefacts |
| 1720 | |
| 1721 | # Post-archive hook |
| 1722 | call_hook post_tf_archive |
| 1723 | |
| 1724 | call_hook fetch_tf_resource |
| 1725 | call_hook post_fetch_tf_resource |
| 1726 | |
Chris Kay | 4e8aaf1 | 2022-09-01 15:21:55 +0100 | [diff] [blame] | 1727 | # Generate LAVA job files if necessary |
| 1728 | call_hook generate_lava_job_template |
| 1729 | call_hook generate_lava_job |
| 1730 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1731 | # Clear any local changes made by applied patches |
| 1732 | undo_tf_patches |
| 1733 | |
| 1734 | echo "##########" |
| 1735 | ) |
| 1736 | fi |
| 1737 | |
| 1738 | echo |
| 1739 | echo |
| 1740 | done |
| 1741 | |
| 1742 | call_hook pre_package |
| 1743 | |
| 1744 | call_hook post_package |
| 1745 | |
| 1746 | if upon "$jenkins_run" && upon "$artefacts_receiver" && [ -d "artefacts" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1747 | source "$CI_ROOT/script/send_artefacts.sh" "artefacts" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1748 | fi |
| 1749 | |
| 1750 | echo |
| 1751 | echo "Done" |