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