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