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 | # |
Rupinderjit Singh | 385f17d | 2022-07-18 20:28:10 +0100 | [diff] [blame] | 3 | # Copyright (c) 2020-2022, 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 | set -u |
| 9 | |
| 10 | bl1_addr="${bl1_addr:-0x0}" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 11 | bl31_addr="${bl31_addr:-0x04001000}" |
Zelalem | 1b87461 | 2020-08-04 18:08:18 -0500 | [diff] [blame] | 12 | bl32_addr="${bl32_addr:-0x04003000}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 13 | bl33_addr="${bl33_addr:-0x88000000}" |
| 14 | dtb_addr="${dtb_addr:-0x82000000}" |
| 15 | fip_addr="${fip_addr:-0x08000000}" |
| 16 | initrd_addr="${initrd_addr:-0x84000000}" |
| 17 | kernel_addr="${kernel_addr:-0x80080000}" |
| 18 | el3_payload_addr="${el3_payload_addr:-0x80000000}" |
| 19 | |
Manish Pandey | 3c43558 | 2020-07-15 12:14:26 +0100 | [diff] [blame] | 20 | # SPM requires following addresses for RESET_TO_BL31 case |
| 21 | spm_addr="${spm_addr:-0x6000000}" |
| 22 | spmc_manifest_addr="${spmc_addr:-0x0403f000}" |
| 23 | sp1_addr="${sp1_addr:-0x7000000}" |
| 24 | sp2_addr="${sp2_addr:-0x7100000}" |
Olivier Deprez | 0b83409 | 2020-08-21 08:36:01 +0200 | [diff] [blame] | 25 | sp3_addr="${sp3_addr:-0x7200000}" |
Olivier Deprez | dd9ed33 | 2021-07-02 12:07:17 +0200 | [diff] [blame] | 26 | sp4_addr="${sp4_addr:-0x7600000}" |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 27 | # SPM out directories |
| 28 | export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_clang}" |
| 29 | export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_clang}" |
Manish Pandey | 3c43558 | 2020-07-15 12:14:26 +0100 | [diff] [blame] | 30 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 31 | ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}" |
| 32 | fwu_fip_addr="${fwu_fip_addr:-0x08400000}" |
| 33 | backup_fip_addr="${backup_fip_addr:-0x09000000}" |
| 34 | romlib_addr="${romlib_addr:-0x03ff2000}" |
| 35 | |
| 36 | uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin" |
| 37 | |
Alexei Fedorov | e405cc3 | 2020-09-30 18:13:55 +0100 | [diff] [blame] | 38 | rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 39 | |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 40 | # Default FVP model variables |
Leonardo Sandoval | e146066 | 2021-05-27 16:05:38 -0500 | [diff] [blame] | 41 | default_model_dtb="dtb.bin" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 42 | |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 43 | # FVP containers and model paths |
laurenw-arm | 35faeaa | 2021-05-03 14:28:17 -0500 | [diff] [blame] | 44 | fvp_arm_std_library_11_12="fvp:fvp_arm_std_library_${model_version_11_12}_${model_build_11_12};/opt/model/FVP_ARM_Std_Library/models/${model_flavour_11_12}" |
Maksims Svecovs | 284a50d | 2021-11-02 11:09:47 +0000 | [diff] [blame] | 45 | fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base" |
laurenw-arm | f414aba | 2021-04-26 15:58:56 -0500 | [diff] [blame] | 46 | fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 47 | foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}" |
johpow01 | 936638d | 2021-11-08 18:22:24 -0600 | [diff] [blame] | 48 | fvp_base_aemv8r="fvp:fvp_base_aemv8r_${model_version}_${model_build};/opt/model/AEMv8R_base_pkg/models/${model_flavour}" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 49 | |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 50 | # FVP associate array, run_config are keys and fvp container parameters are the values |
| 51 | # Container parameters syntax: <model name>;<model dir>;<model bin> |
| 52 | # FIXMEs: fix those ;;; values with real values |
| 53 | |
| 54 | declare -A fvp_models |
| 55 | fvp_models=( |
| 56 | [base-aemv8a-quad]=";;;" |
| 57 | [base-aemv8a-revb]=";;;" |
| 58 | [base-aemv8a-latest-revb]=";;;" |
| 59 | [base-aemva]=";;;" |
Manish V Badarkhe | e478383 | 2021-02-22 14:36:56 +0000 | [diff] [blame] | 60 | [base-aemv8a-gic600ae]=";;;" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 61 | [foundationv8]="${foundation_platform};Foundation_Platform" |
laurenw-arm | f414aba | 2021-04-26 15:58:56 -0500 | [diff] [blame] | 62 | [base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA" |
johpow01 | 936638d | 2021-11-08 18:22:24 -0600 | [diff] [blame] | 63 | [baser-aemv8r]=";;;" |
laurenw-arm | 35faeaa | 2021-05-03 14:28:17 -0500 | [diff] [blame] | 64 | [cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 65 | [cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4" |
| 66 | [cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4" |
Leonardo Sandoval | 95f896b | 2021-02-22 10:16:29 -0600 | [diff] [blame] | 67 | [cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4" |
| 68 | [cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 69 | [cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1" |
| 70 | [cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4" |
| 71 | [cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4" |
| 72 | [cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4" |
| 73 | [cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8" |
| 74 | [cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4" |
| 75 | [cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4" |
| 76 | [cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4" |
| 77 | [cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4" |
| 78 | [cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4" |
| 79 | [cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4" |
| 80 | [cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4" |
| 81 | [cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2" |
| 82 | [cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4" |
| 83 | [cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4" |
| 84 | [cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4" |
laurenw-arm | 06c4a19 | 2022-07-12 14:55:28 -0500 | [diff] [blame] | 85 | [cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78Cx4" |
johpow01 | 1008edc | 2022-02-01 18:50:33 -0600 | [diff] [blame] | 86 | [cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2x4" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 87 | [neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1" |
| 88 | [neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2" |
| 89 | [neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4" |
Leonardo Sandoval | 54f1ade | 2021-06-26 19:20:48 -0500 | [diff] [blame] | 90 | [neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4" |
Maksims Svecovs | d10c1b9 | 2021-10-06 10:25:40 +0100 | [diff] [blame] | 91 | [neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 92 | [neoverse-v1x4]=";;;" |
Manish V Badarkhe | cbed15e | 2021-07-02 09:34:53 +0100 | [diff] [blame] | 93 | [cortexa710x4]=";;;" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 94 | [css-rdv1]=";;;" |
| 95 | [css-rde1edge]=";;;" |
| 96 | [css-rdn1edge]=";;;" |
| 97 | [css-rdn1edgex2]=";;;" |
| 98 | [css-sgi575]=";;;" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 99 | [tc0]=";;;" |
Usama Arif | cba711d | 2021-08-04 15:53:42 +0100 | [diff] [blame] | 100 | [tc1]=";;;" |
Rupinderjit Singh | 385f17d | 2022-07-18 20:28:10 +0100 | [diff] [blame] | 101 | [tc2]=";;;" |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 102 | ) |
| 103 | |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 104 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 105 | # FVP Kernel URLs |
| 106 | declare -A fvp_kernels |
| 107 | fvp_kernels=( |
| 108 | [fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image" |
| 109 | [fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image" |
| 110 | [fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image" |
| 111 | [fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image" |
| 112 | [fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image" |
| 113 | ) |
| 114 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 115 | # FVP initrd URLs |
| 116 | declare -A fvp_initrd_urls |
| 117 | fvp_initrd_urls=( |
| 118 | [aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 119 | [dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img" |
| 120 | [dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img" |
| 121 | [default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img" |
| 122 | ) |
| 123 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 124 | get_optee_bin() { |
Sandrine Bailleux | 25ff294 | 2021-02-25 14:00:10 +0100 | [diff] [blame] | 125 | url="$tfa_downloads/optee/tee.bin" \ |
| 126 | saveas="bl32.bin" fetch_file |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 127 | archive_file "bl32.bin" |
| 128 | } |
| 129 | |
Javier Almansa Sobrino | 98de503 | 2020-09-17 12:47:05 +0100 | [diff] [blame] | 130 | # For Measured Boot tests using a TA based on OPTEE, it is necessary to use a |
| 131 | # specific build rather than the default one generated by Jenkins. |
| 132 | get_ftpm_optee_bin() { |
Javier Almansa Sobrino | de64772 | 2020-10-08 19:17:44 +0100 | [diff] [blame] | 133 | url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \ |
Javier Almansa Sobrino | 98de503 | 2020-09-17 12:47:05 +0100 | [diff] [blame] | 134 | saveas="bl32.bin" fetch_file |
| 135 | archive_file "bl32.bin" |
| 136 | |
Javier Almansa Sobrino | de64772 | 2020-10-08 19:17:44 +0100 | [diff] [blame] | 137 | url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \ |
Javier Almansa Sobrino | 98de503 | 2020-09-17 12:47:05 +0100 | [diff] [blame] | 138 | saveas="bl32_extra1.bin" fetch_file |
| 139 | archive_file "bl32_extra1.bin" |
| 140 | |
Leonardo Sandoval | da5f78d | 2021-03-18 11:09:30 -0600 | [diff] [blame] | 141 | # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin, |
| 142 | # so just create the file |
| 143 | touch "bl32_extra2.bin" |
Javier Almansa Sobrino | 98de503 | 2020-09-17 12:47:05 +0100 | [diff] [blame] | 144 | archive_file "bl32_extra2.bin" |
| 145 | } |
| 146 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 147 | get_uboot32_bin() { |
| 148 | local tmpdir="$(mktempdir)" |
| 149 | |
| 150 | pushd "$tmpdir" |
| 151 | extract_fip "$uboot32_fip_url" |
| 152 | mv "nt-fw.bin" "uboot.bin" |
| 153 | archive_file "uboot.bin" |
| 154 | popd |
| 155 | } |
| 156 | |
| 157 | get_uboot_bin() { |
| 158 | local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin" |
| 159 | |
| 160 | url="$uboot_url" saveas="uboot.bin" fetch_file |
| 161 | archive_file "uboot.bin" |
| 162 | } |
| 163 | |
| 164 | get_uefi_bin() { |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 165 | uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}" |
| 166 | uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 167 | |
| 168 | url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file |
| 169 | archive_file "uefi.bin" |
| 170 | } |
| 171 | |
| 172 | get_kernel() { |
| 173 | local kernel_type="${kernel_type:?}" |
| 174 | local url="${fvp_kernels[$kernel_type]}" |
| 175 | |
| 176 | url="${url:?}" saveas="kernel.bin" fetch_file |
| 177 | archive_file "kernel.bin" |
| 178 | } |
| 179 | |
| 180 | get_initrd() { |
| 181 | local initrd_type="${initrd_type:?}" |
| 182 | local url="${fvp_initrd_urls[$initrd_type]}" |
| 183 | |
| 184 | url="${url:?}" saveas="initrd.bin" fetch_file |
| 185 | archive_file "initrd.bin" |
| 186 | } |
| 187 | |
| 188 | get_dtb() { |
| 189 | local dtb_type="${dtb_type:?}" |
| 190 | local dtb_url |
| 191 | local dtb_saveas="$workspace/dtb.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 192 | local cc="$(get_tf_opt CROSS_COMPILE)" |
| 193 | local pp_flags="-P -nostdinc -undef -x assembler-with-cpp" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 194 | |
| 195 | case "$dtb_type" in |
| 196 | "fvp-base-quad-cluster-gicv3-psci") |
| 197 | # Get the quad-cluster FDT from pdsw area |
| 198 | dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb" |
| 199 | url="$dtb_url" saveas="$dtb_saveas" fetch_file |
| 200 | ;; |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 201 | *) |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 202 | # Preprocess DTS file |
| 203 | ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \ |
| 204 | -o "$workspace/${dtb_type}.pre.dts" \ |
| 205 | "$tf_root/fdts/${dtb_type}.dts" |
| 206 | # Generate DTB file from DTS |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 207 | dtc -I dts -O dtb \ |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 208 | "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 209 | esac |
| 210 | |
| 211 | archive_file "$dtb_saveas" |
| 212 | } |
| 213 | |
| 214 | get_rootfs() { |
| 215 | local tmpdir |
| 216 | local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')" |
| 217 | local cached="$project_filer/ci-files/$fs_base" |
| 218 | |
| 219 | if upon "$jenkins_run" && [ -f "$cached" ]; then |
| 220 | # Job workspace is limited in size, and the root file system is |
| 221 | # quite large. This means, parallel runs of root file system |
| 222 | # tests could fail. So, for Jenkins runs, copy and use the root |
| 223 | # file system image from the $CI_SCRATCH location |
| 224 | local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER" |
| 225 | mkdir -p "$private" |
| 226 | rm -f "$private/rootfs.bin" |
| 227 | url="$cached" saveas="$private/rootfs.bin" fetch_file |
| 228 | ln -s "$private/rootfs.bin" "$archive/rootfs.bin" |
| 229 | return |
| 230 | fi |
| 231 | |
| 232 | tmpdir="$(mktempdir)" |
| 233 | pushd "$tmpdir" |
| 234 | url="$rootfs_url" saveas="rootfs.bin" fetch_file |
| 235 | |
| 236 | # Possibly, the filesystem image we just downloaded is compressed. |
| 237 | # Decompress it if required. |
| 238 | if file "rootfs.bin" | grep -iq 'gzip compressed data'; then |
| 239 | echo "Decompressing root file system image rootfs.bin ..." |
| 240 | gunzip --stdout "rootfs.bin" > uncompressed_fs.bin |
| 241 | mv uncompressed_fs.bin "rootfs.bin" |
| 242 | fi |
| 243 | |
| 244 | archive_file "rootfs.bin" |
| 245 | popd |
| 246 | } |
| 247 | |
Sandrine Bailleux | 14a692d | 2022-06-29 15:39:42 +0200 | [diff] [blame] | 248 | fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i" |
| 249 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 250 | fvp_romlib_runtime() { |
| 251 | local tmpdir="$(mktempdir)" |
| 252 | |
| 253 | # Save BL1 and romlib binaries from original build |
| 254 | mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin" |
| 255 | mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin" |
| 256 | |
| 257 | # Patch index file |
Sandrine Bailleux | 14a692d | 2022-06-29 15:39:42 +0200 | [diff] [blame] | 258 | cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup" |
| 259 | sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 260 | |
Sandrine Bailleux | 14a692d | 2022-06-29 15:39:42 +0200 | [diff] [blame] | 261 | # Rebuild with patched file |
| 262 | echo "Building patched romlib:" |
| 263 | build_tf |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 264 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 265 | # Retrieve original BL1 and romlib binaries |
| 266 | mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" |
| 267 | mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" |
| 268 | } |
| 269 | |
Sandrine Bailleux | 14a692d | 2022-06-29 15:39:42 +0200 | [diff] [blame] | 270 | fvp_romlib_cleanup() { |
| 271 | # Restore original index |
| 272 | mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" |
| 273 | } |
| 274 | |
| 275 | |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 276 | fvp_gen_bin_url() { |
| 277 | local bin_mode="${bin_mode:?}" |
| 278 | local bin="${1:?}" |
| 279 | |
| 280 | if upon "$jenkins_run"; then |
| 281 | echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin" |
| 282 | else |
| 283 | echo "file://$workspace/artefacts/$bin_mode/$bin" |
| 284 | fi |
| 285 | } |
| 286 | |
| 287 | gen_fvp_yaml_template() { |
| 288 | local yaml_template_file="$workspace/fvp_template.yaml" |
| 289 | |
| 290 | # must parameters for yaml generation |
| 291 | local payload_type="${payload_type:?}" |
| 292 | |
| 293 | "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file" |
| 294 | |
| 295 | archive_file "$yaml_template_file" |
| 296 | } |
| 297 | |
| 298 | gen_fvp_yaml() { |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 299 | local model="${model:?}" |
| 300 | |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 301 | local yaml_template_file="$workspace/fvp_template.yaml" |
| 302 | local yaml_file="$workspace/fvp.yaml" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 303 | local yaml_job_file="$workspace/job.yaml" |
| 304 | local lava_model_params="$workspace/lava_model_params" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 305 | |
Leonardo Sandoval | fda4f29 | 2020-10-06 15:59:26 -0500 | [diff] [blame] | 306 | # this function expects a template, quit if it is not present |
| 307 | if [ ! -f "$yaml_template_file" ]; then |
| 308 | return |
| 309 | fi |
| 310 | |
Leonardo Sandoval | 00ced1f | 2020-12-07 12:55:08 -0600 | [diff] [blame] | 311 | local model_params="${fvp_models[$model]}" |
| 312 | local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')" |
| 313 | local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')" |
| 314 | local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')" |
| 315 | |
| 316 | # model params are required for correct yaml creation, quit if empty |
| 317 | if [ -z "${model_name}" ]; then |
| 318 | echo "FVP model param 'model_name' variable empty, yaml not produced" |
| 319 | return |
| 320 | elif [ -z "${model_dir}" ]; then |
| 321 | echo "FVP model param 'model_dir' variable empty, yaml not produced" |
| 322 | return |
| 323 | elif [ -z "${model_bin}" ]; then |
| 324 | echo "FVP model param 'model_bin' variable empty, yaml not produced" |
| 325 | return |
| 326 | fi |
| 327 | |
| 328 | echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 329 | |
| 330 | # optional parameters, defaults to globals |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 331 | local model_dtb="${model_dtb:-$default_model_dtb}" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 332 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 333 | # possible artefacts |
| 334 | backup_fip="$(fvp_gen_bin_url backup_fip.bin)" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 335 | bl1="$(fvp_gen_bin_url bl1.bin)" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 336 | bl2="$(fvp_gen_bin_url bl2.bin)" |
| 337 | bl31="$(fvp_gen_bin_url bl31.bin)" |
| 338 | bl32="$(fvp_gen_bin_url bl32.bin)" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 339 | busybox="$(fvp_gen_bin_url busybox.bin.gz)" |
| 340 | cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)" |
| 341 | cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)" |
| 342 | cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)" |
Leonardo Sandoval | d98f833 | 2021-04-13 16:46:38 -0500 | [diff] [blame] | 343 | coverage_trace_plugin="${coverage_trace_plugin}" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 344 | dtb="$(fvp_gen_bin_url ${model_dtb})" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 345 | el3_payload="$(fvp_gen_bin_url el3_payload.bin)" |
| 346 | fip="$(fvp_gen_bin_url fip.bin)" |
Leonardo Sandoval | cc52beb | 2021-05-05 19:05:31 -0500 | [diff] [blame] | 347 | fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)" |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 348 | fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 349 | fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 350 | generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so" |
| 351 | hafnium="$(fvp_gen_bin_url hafnium.bin)" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 352 | image="$(fvp_gen_bin_url kernel.bin)" |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 353 | ivy="$(fvp_gen_bin_url ivy.pkg)" |
| 354 | manifest_dtb="$(fvp_gen_bin_url manifest.dtb)" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 355 | mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)" |
| 356 | mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 357 | ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)" |
| 358 | ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 359 | ramdisk="$(fvp_gen_bin_url initrd.bin)" |
| 360 | romlib="$(fvp_gen_bin_url romlib.bin)" |
| 361 | rootfs="$(fvp_gen_bin_url rootfs.bin.gz)" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 362 | secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)" |
| 363 | scp_ram="$(fvp_gen_bin_url scp_ram.bin)" |
| 364 | scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)" |
| 365 | scp_rom="$(fvp_gen_bin_url scp_rom.bin)" |
| 366 | scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 367 | spm="$(fvp_gen_bin_url spm.bin)" |
| 368 | tftf="$(fvp_gen_bin_url tftf.bin)" |
| 369 | tmp="$(fvp_gen_bin_url tmp.bin)" |
| 370 | uboot="$(fvp_gen_bin_url uboot.bin)" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 371 | |
| 372 | docker_registry="${docker_registry:-}" |
| 373 | docker_registry="$(docker_registry_append)" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 374 | docker_name="${docker_registry}$model_name" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 375 | prompt1='/ #' |
| 376 | prompt2='root@genericarmv8:~#' |
| 377 | version_string="\"Fast Models"' [^\\n]+'"\"" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 378 | |
Leonardo Sandoval | 5d87b70 | 2021-05-10 11:53:13 -0500 | [diff] [blame] | 379 | test_config="${TEST_CONFIG}" |
| 380 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 381 | # arrays that relates variables and template macros |
| 382 | # NOTE: any addition on these arrays, requires an addition in the |
| 383 | # fvp templates |
Leonardo Sandoval | 5d87b70 | 2021-05-10 11:53:13 -0500 | [diff] [blame] | 384 | declare -A metadata_macros |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 385 | declare -A yaml_macros |
| 386 | declare -A artefacts_macros |
Leonardo Sandoval | 5d87b70 | 2021-05-10 11:53:13 -0500 | [diff] [blame] | 387 | metadata_macros=( |
| 388 | [test_config]="{TEST_CONFIG}" |
| 389 | ) |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 390 | yaml_macros=( |
| 391 | [armlmd_license_file]="{ARMLMD_LICENSE_FILE}" |
| 392 | [docker_name]="{BOOT_DOCKER_NAME}" |
| 393 | [model]="{MODEL}" |
| 394 | [model_bin]="{BOOT_IMAGE_BIN}" |
| 395 | [model_dir]="{BOOT_IMAGE_DIR}" |
| 396 | [prompt1]="{PROMPT1}" |
| 397 | [prompt2]="{PROMPT2}" |
| 398 | [version_string]="{BOOT_VERSION_STRING}" |
| 399 | ) |
| 400 | artefacts_macros=( |
| 401 | [backup_fip]="{BACKUP_FIP}" |
| 402 | [bl1]="{BL1}" |
| 403 | [bl2]="{BL2}" |
| 404 | [bl31]="{BL31}" |
| 405 | [bl32]="{BL32}" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 406 | [cactus_primary]="{CACTUS_PRIMARY}" |
| 407 | [cactus_secondary]="{CACTUS_SECONDARY}" |
| 408 | [cactus_tertiary]="{CACTUS_TERTIARY}" |
Leonardo Sandoval | d98f833 | 2021-04-13 16:46:38 -0500 | [diff] [blame] | 409 | [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}" |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 410 | [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 411 | [busybox]="{BUSYBOX}" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 412 | [dtb]="{DTB}" |
| 413 | [el3_payload]="{EL3_PAYLOAD}" |
Leonardo Sandoval | cc52beb | 2021-05-05 19:05:31 -0500 | [diff] [blame] | 414 | [fip_gpt]="{FIP_GPT}" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 415 | [fwu_fip]="{FWU_FIP}" |
| 416 | [fip]="{FIP}" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 417 | [generic_trace]="{GENERIC_TRACE}" |
| 418 | [hafnium]="{HAFNIUM}" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 419 | [image]="{IMAGE}" |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 420 | [ivy]="{IVY}" |
| 421 | [manifest_dtb]="{MANIFEST_DTB}" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 422 | [mcp_rom]="{MCP_ROM}" |
| 423 | [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 424 | [ns_bl1u]="{NS_BL1U}" |
| 425 | [ns_bl2u]="{NS_BL2U}" |
| 426 | [ramdisk]="{RAMDISK}" |
| 427 | [romlib]="{ROMLIB}" |
| 428 | [rootfs]="{ROOTFS}" |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 429 | [secure_hafnium]="{SECURE_HAFNIUM}" |
| 430 | [scp_ram]="{SCP_RAM}" |
| 431 | [scp_ram_hyphen]="{SCP_RAM_HYPHEN}" |
| 432 | [scp_rom]="{SCP_ROM}" |
| 433 | [scp_rom_hyphen]="{SCP_ROM_HYPHEN}" |
| 434 | [spm]="{SPM}" |
| 435 | [tftf]="{TFTF}" |
| 436 | [tmp]="{TMP}" |
| 437 | [uboot]="{UBOOT}" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 438 | ) |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 439 | |
Chris Kay | 4eb9ded | 2022-10-10 15:51:40 +0100 | [diff] [blame^] | 440 | declare -A artefact_filters=( |
| 441 | [backup_fip]="backup_fip.bin" |
| 442 | [bl1]="bl1.bin" |
| 443 | [bl2]="bl2.bin" |
| 444 | [bl31]="bl31.bin" |
| 445 | [bl32]="bl32.bin" |
| 446 | [busybox]="busybox.bin" |
| 447 | [cactus_primary]="cactus-primary.pkg" |
| 448 | [cactus_secondary]="cactus-secondary.pkg" |
| 449 | [cactus_tertiary]="cactus-tertiary.pkg" |
| 450 | [coverage_trace_plugin]="coverage_trace.so" |
| 451 | [dtb]="dtb.bin" |
| 452 | [el3_payload]="el3_payload.bin" |
| 453 | [fip_gpt]="fip_gpt.bin" |
| 454 | [fip]="fip.bin" |
| 455 | [fvp_spmc_manifest_dtb]="=fvp_spmc_manifest.dtb" |
| 456 | [fwu_fip]="fwu_fip.bin" |
| 457 | [generic_trace]="GenericTrace.so" |
| 458 | [hafnium]="hafnium.bin" |
| 459 | [image]="kernel.bin" |
| 460 | [ivy]="ivy.pkg" |
| 461 | [manifest_dtb]="=manifest.dtb" |
| 462 | [mcp_rom_hyphen]="mcp-rom.bin" |
| 463 | [mcp_rom]="mcp_rom.bin" |
| 464 | [ns_bl1u]="ns_bl1u.bin" |
| 465 | [ns_bl2u]="ns_bl2u.bin" |
| 466 | [ramdisk]="initrd.bin|initrd.img" |
| 467 | [romlib]="romlib.bin" |
| 468 | [rootfs]="rootfs.bin" |
| 469 | [scp_ram_hyphen]="scp-ram.bin" |
| 470 | [scp_ram]="scp_ram.bin" |
| 471 | [scp_rom_hyphen]="scp-rom.bin" |
| 472 | [scp_rom]="scp_rom.bin" |
| 473 | [secure_hafnium]="secure_hafnium.bin" |
| 474 | [spm]="spm.bin" |
| 475 | [tftf]="tftf.bin" |
| 476 | [tmp]="tmp.bin" |
| 477 | [uboot]="uboot.bin" |
| 478 | ) |
| 479 | |
| 480 | declare -a artefacts=() |
| 481 | |
| 482 | for artefact in "${!artefact_filters[@]}"; do |
| 483 | if grep -E -q "${artefact_filters[${artefact}]}" "${archive}/model_params"; then |
| 484 | artefacts+=("${artefact}") |
| 485 | fi |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 486 | done |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 487 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 488 | # copied files are the working files |
| 489 | cp "${yaml_template_file}" "${yaml_file}" |
| 490 | cp "$archive/model_params" "$lava_model_params" |
| 491 | |
Leonardo Sandoval | 5d87b70 | 2021-05-10 11:53:13 -0500 | [diff] [blame] | 492 | # replace metadata macros with real values |
| 493 | for m in "${!metadata_macros[@]}"; do |
| 494 | sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file" |
| 495 | done |
| 496 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 497 | # replace yaml macros with real values |
| 498 | for m in "${!yaml_macros[@]}"; do |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 499 | sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 500 | done |
| 501 | |
| 502 | # replace artefact macros with real values |
| 503 | for m in "${!artefacts_macros[@]}"; do |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 504 | sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 505 | done |
| 506 | |
| 507 | # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 508 | # replace them. As in the macro removal above, handle special cases for several |
| 509 | # artefacts |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 510 | for m in "${!artefacts_macros[@]}"; do |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 511 | case "$m" in |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 512 | cactus_primary) |
| 513 | sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 514 | ;; |
| 515 | cactus_secondary) |
| 516 | sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 517 | ;; |
| 518 | cactus_tertiary) |
| 519 | sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 520 | ;; |
Leonardo Sandoval | d98f833 | 2021-04-13 16:46:38 -0500 | [diff] [blame] | 521 | coverage_trace_plugin) |
| 522 | sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params" |
| 523 | sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params" |
| 524 | ;; |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 525 | fvp_spmc_manifest_dtb) |
| 526 | sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 527 | ;; |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 528 | generic_trace) |
| 529 | sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params" |
| 530 | sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params" |
| 531 | ;; |
| 532 | image) |
| 533 | sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 534 | ;; |
Leonardo Sandoval | b1fb634 | 2021-11-18 15:34:25 -0600 | [diff] [blame] | 535 | ivy) |
| 536 | sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 537 | ;; |
| 538 | manifest_dtb) |
| 539 | sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 540 | ;; |
Leonardo Sandoval | df9c92f | 2021-03-12 11:31:09 -0600 | [diff] [blame] | 541 | mcp_rom_hyphen) |
| 542 | sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 543 | ;; |
| 544 | ramdisk) |
| 545 | sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 546 | sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 547 | ;; |
| 548 | scp_ram_hyphen) |
| 549 | sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 550 | ;; |
| 551 | scp_rom_hyphen) |
| 552 | sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 553 | ;; |
| 554 | tmp | hafnium | secure_hafnium) |
| 555 | sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 556 | ;; |
| 557 | *) |
| 558 | sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params" |
| 559 | ;; |
| 560 | esac |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 561 | done |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 562 | |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 563 | # include the model parameters |
| 564 | while read -r line; do |
| 565 | if [ -n "$line" ]; then |
Chris Kay | 60df24d | 2022-10-04 17:35:06 +0100 | [diff] [blame] | 566 | yaml_line="- $(echo "${line}" | jq -R .)" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 567 | sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 568 | fi |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 569 | done < "$lava_model_params" |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 570 | sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file" |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 571 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 572 | # Append expect commands into the job definition through test-interactive commands |
| 573 | gen_fvp_yaml_expect >> "$yaml_file" |
| 574 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 575 | # create job.yaml |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 576 | cp "$yaml_file" "$yaml_job_file" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 577 | |
Leonardo Sandoval | 850a486 | 2021-02-16 13:56:18 -0600 | [diff] [blame] | 578 | # archive both yamls |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 579 | archive_file "$yaml_file" |
Leonardo Sandoval | 5d90dff | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 580 | archive_file "$yaml_job_file" |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 581 | } |
| 582 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 583 | gen_fvp_yaml_expect() { |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 584 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 585 | run_root="$archive/run" |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 586 | |
| 587 | # Loop through all uarts expect files |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 588 | for expect_file in $(find $run_root -name expect); do |
| 589 | |
| 590 | # TODO: currently, only handle UART 0 |
| 591 | case $expect_file in |
| 592 | *uart0* ) |
| 593 | uart_number=uart0 |
| 594 | ;; |
| 595 | *) |
| 596 | continue |
| 597 | ;; |
| 598 | esac |
| 599 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 600 | # Array containing "interactive" or "monitor" expect strings and populated during run config execution. |
| 601 | # Interactive expect scripts are converted into LAVA Interactive Test Actions (see |
| 602 | # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and |
| 603 | # monitor expect scripts are converted into LAVA Monitor Test Actions (see |
| 604 | # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor) |
| 605 | # |
| 606 | # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>' |
| 607 | # where multiple successes or failures or commands are separated by @ |
| 608 | # |
| 609 | # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>' |
| 610 | # where multiple patterns are separated by @ |
| 611 | # |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 612 | expect_string=() |
| 613 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 614 | # Get the real name of the expect file |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 615 | expect_file=$(cat $expect_file) |
| 616 | |
| 617 | # Source the run_config enviroment variables |
| 618 | env=$run_root/$uart_number/env |
| 619 | if [ -e $env ]; then |
| 620 | source $env |
| 621 | fi |
| 622 | |
| 623 | # Get all expect strings |
Paul Sokolovsky | eece6f7 | 2021-12-01 15:04:29 +0300 | [diff] [blame] | 624 | expect_file=$ci_root/expect-lava/${expect_file} |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 625 | source $expect_file |
| 626 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 627 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 628 | if [ ${#expect_string[@]} -gt 0 ]; then |
| 629 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 630 | # expect loop |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 631 | for key in "${!expect_string[@]}"; do |
| 632 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 633 | # single raw expect string |
| 634 | es="${expect_string[${key}]}" |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 635 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 636 | # action type: either m or i |
| 637 | action="$(echo "${es}" | awk -F ';' '{print $1}')" |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 638 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 639 | if [ "${action}" = "m" ]; then |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 640 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 641 | start="$(echo "${es}" | awk -F ';' '{print $2}')" |
| 642 | end="$(echo "${es}" | awk -F ';' '{print $3}')" |
| 643 | patterns="$(echo "${es}" | awk -F ';' '{print $4}')" |
| 644 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 645 | cat << EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 646 | - test: |
| 647 | monitors: |
| 648 | - name: tests |
| 649 | start: '${start}' |
| 650 | end: '${end}' |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 651 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 652 | # Patterns are separated by '@' |
| 653 | OLD_IFS=$IFS; IFS=$'@' |
| 654 | for p in ${patterns}; do |
| 655 | cat << EOF |
| 656 | pattern: '$p' |
| 657 | EOF |
| 658 | done |
| 659 | IFS=$OLD_IFS |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 660 | cat << EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 661 | fixupdict: |
| 662 | PASS: pass |
| 663 | FAIL: fail |
| 664 | EOF |
| 665 | fi # end of monitor action |
| 666 | |
| 667 | if [ "${action}" = "i" ]; then |
| 668 | |
| 669 | prompts="$(echo "${es}" | awk -F ';' '{print $2}')" |
| 670 | successes="$(echo "${es}" | awk -F ';' '{print $3}')" |
| 671 | failures="$(echo "${es}" | awk -F ';' '{print $4}')" |
| 672 | commands="$(echo "${es}" | awk -F ';' '{print $5}')" |
| 673 | |
| 674 | cat << EOF |
| 675 | - test: |
| 676 | interactive: |
| 677 | EOF |
| 678 | OLD_IFS=$IFS; IFS=$'@' |
| 679 | |
| 680 | if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then |
| 681 | cat << EOF |
| 682 | - name: interactive_${uart_number}_${key} |
| 683 | prompts: ['${prompts}'] |
| 684 | script: |
| 685 | EOF |
| 686 | if [ -z "${commands}" ]; then |
| 687 | cat <<EOF |
| 688 | - name: interactive_command_${uart_number}_${key} |
| 689 | command: |
| 690 | EOF |
| 691 | else |
| 692 | for c in ${commands}; do |
| 693 | cat <<EOF |
| 694 | - name: interactive_command_${uart_number}_${key} |
Paul Sokolovsky | df44524 | 2021-12-15 16:57:51 +0300 | [diff] [blame] | 695 | command: "$c" |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 696 | EOF |
| 697 | done |
| 698 | fi |
| 699 | cat << EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 700 | successes: |
| 701 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 702 | for s in ${successes}; do |
| 703 | cat <<EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 704 | - message: '$s' |
| 705 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 706 | done |
| 707 | cat << EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 708 | failures: |
| 709 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 710 | for f in ${failures}; do |
| 711 | cat <<EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 712 | - message: '$f' |
| 713 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 714 | done |
| 715 | elif [[ -n "${prompts}" && -n "${successes}" ]]; then |
| 716 | cat << EOF |
| 717 | - name: interactive_${uart_number}_${key} |
| 718 | prompts: ['${prompts}'] |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 719 | script: |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 720 | EOF |
| 721 | |
| 722 | if [ -z "${commands}" ]; then |
| 723 | cat <<EOF |
| 724 | - name: interactive_command_${uart_number}_${key} |
| 725 | command: |
| 726 | EOF |
| 727 | else |
| 728 | for c in ${commands}; do |
| 729 | cat <<EOF |
| 730 | - name: interactive_command_${uart_number}_${key} |
Paul Sokolovsky | df44524 | 2021-12-15 16:57:51 +0300 | [diff] [blame] | 731 | command: "$c" |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 732 | EOF |
| 733 | done |
| 734 | fi |
| 735 | cat << EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 736 | successes: |
| 737 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 738 | for s in ${successes}; do |
| 739 | cat <<EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 740 | - message: '$s' |
| 741 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 742 | done |
| 743 | |
| 744 | elif [[ -n "${prompts}" && -n "${failures}" ]]; then |
| 745 | cat << EOF |
| 746 | - name: interactive_${uart_number}_${key} |
| 747 | prompts: ['${prompts}'] |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 748 | script: |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 749 | EOF |
| 750 | if [ -z "${commands}" ]; then |
| 751 | cat <<EOF |
| 752 | - name: interactive_command_${uart_number}_${key} |
| 753 | command: |
| 754 | EOF |
| 755 | else |
| 756 | for c in ${commands}; do |
| 757 | cat <<EOF |
| 758 | - name: interactive_command_${uart_number}_${key} |
Paul Sokolovsky | df44524 | 2021-12-15 16:57:51 +0300 | [diff] [blame] | 759 | command: "$c" |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 760 | EOF |
| 761 | done |
| 762 | fi |
| 763 | cat << EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 764 | failures: |
| 765 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 766 | for f in ${failures}; do |
| 767 | cat <<EOF |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 768 | - message: '$f' |
| 769 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 770 | done |
| 771 | else |
| 772 | cat << EOF |
| 773 | - name: interactive_${uart_number}_${key} |
| 774 | prompts: ['${prompts}'] |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 775 | script: |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 776 | EOF |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 777 | if [ -z "${commands}" ]; then |
| 778 | cat <<EOF |
| 779 | - name: interactive_command_${uart_number}_${key} |
| 780 | command: |
| 781 | EOF |
| 782 | else |
| 783 | for c in ${commands}; do |
| 784 | cat <<EOF |
| 785 | - name: interactive_command_${uart_number}_${key} |
Paul Sokolovsky | df44524 | 2021-12-15 16:57:51 +0300 | [diff] [blame] | 786 | command: "$c" |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 787 | EOF |
| 788 | done |
| 789 | fi |
| 790 | fi |
| 791 | |
| 792 | IFS=$OLD_IFS |
| 793 | fi # end of interactive action |
| 794 | |
| 795 | done # end of expect loop |
| 796 | |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 797 | fi |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 798 | done # end of uart loop |
Leonardo Sandoval | cd06bf4 | 2021-04-08 11:53:39 -0500 | [diff] [blame] | 799 | } |
| 800 | |
Leonardo Sandoval | d76d1e2 | 2020-10-06 16:02:52 -0500 | [diff] [blame] | 801 | docker_registry_append() { |
| 802 | # if docker_registry is empty, just use local docker registry |
| 803 | [ -z "$docker_registry" ] && return |
| 804 | |
| 805 | local last=-1 |
| 806 | local last_char="${docker_registry:last}" |
| 807 | |
| 808 | if [ "$last_char" != '/' ]; then |
| 809 | docker_registry="${docker_registry}/"; |
| 810 | fi |
| 811 | echo "$docker_registry" |
| 812 | } |
| 813 | |
Manish V Badarkhe | ea3e094 | 2021-03-05 11:51:48 +0000 | [diff] [blame] | 814 | # generate GPT image and archive it |
| 815 | gen_gpt_bin() { |
| 816 | raw_image="fip_gpt.bin" |
| 817 | img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE" |
| 818 | img_bank_uuid=`uuidgen` |
| 819 | disk_uuid=`uuidgen` |
| 820 | bin="${1:?}" |
| 821 | |
| 822 | # maximum FIP size 2MB |
| 823 | fip_max_size=2097152 |
| 824 | start_sector=34 |
| 825 | sector_size=512 |
| 826 | num_sectors=$(($fip_max_size/$sector_size)) |
| 827 | bin_size=$(stat -c %s $bin) |
| 828 | |
| 829 | if [[ $fip_max_size -lt $bin_size ]] |
| 830 | then |
| 831 | echo "FIP binary ($bin_size bytes) larger than max partition 1" |
| 832 | "size ($fip_max_size byte)" |
| 833 | return |
| 834 | fi |
| 835 | |
| 836 | # create raw 5MB image |
| 837 | dd if=/dev/zero of=$raw_image bs=5M count=1 |
| 838 | |
| 839 | # create GPT image |
| 840 | sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \ |
| 841 | -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid |
| 842 | |
| 843 | echo "write binary $bin at sector $start_sector" |
| 844 | dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \ |
| 845 | count=$num_sectors conv=notrunc |
| 846 | |
| 847 | archive_file "fip_gpt.bin" |
| 848 | } |
| 849 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 850 | set +u |