Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | 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}" |
| 25 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 26 | ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}" |
| 27 | fwu_fip_addr="${fwu_fip_addr:-0x08400000}" |
| 28 | backup_fip_addr="${backup_fip_addr:-0x09000000}" |
| 29 | romlib_addr="${romlib_addr:-0x03ff2000}" |
| 30 | |
| 31 | uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin" |
| 32 | |
| 33 | rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img.gz" |
| 34 | |
| 35 | # FVP Kernel URLs |
| 36 | declare -A fvp_kernels |
| 37 | fvp_kernels=( |
| 38 | [fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image" |
| 39 | [fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image" |
| 40 | [fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image" |
| 41 | [fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image" |
| 42 | [fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image" |
| 43 | ) |
| 44 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 45 | # FVP initrd URLs |
| 46 | declare -A fvp_initrd_urls |
| 47 | fvp_initrd_urls=( |
| 48 | [aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 49 | [dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img" |
| 50 | [dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img" |
| 51 | [default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img" |
| 52 | ) |
| 53 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 54 | get_optee_bin() { |
| 55 | url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \ |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 56 | saveas="bl32.bin" fetch_file |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 57 | archive_file "bl32.bin" |
| 58 | } |
| 59 | |
| 60 | get_uboot32_bin() { |
| 61 | local tmpdir="$(mktempdir)" |
| 62 | |
| 63 | pushd "$tmpdir" |
| 64 | extract_fip "$uboot32_fip_url" |
| 65 | mv "nt-fw.bin" "uboot.bin" |
| 66 | archive_file "uboot.bin" |
| 67 | popd |
| 68 | } |
| 69 | |
| 70 | get_uboot_bin() { |
| 71 | local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin" |
| 72 | |
| 73 | url="$uboot_url" saveas="uboot.bin" fetch_file |
| 74 | archive_file "uboot.bin" |
| 75 | } |
| 76 | |
| 77 | get_uefi_bin() { |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 78 | uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}" |
| 79 | 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] | 80 | |
| 81 | url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file |
| 82 | archive_file "uefi.bin" |
| 83 | } |
| 84 | |
| 85 | get_kernel() { |
| 86 | local kernel_type="${kernel_type:?}" |
| 87 | local url="${fvp_kernels[$kernel_type]}" |
| 88 | |
| 89 | url="${url:?}" saveas="kernel.bin" fetch_file |
| 90 | archive_file "kernel.bin" |
| 91 | } |
| 92 | |
| 93 | get_initrd() { |
| 94 | local initrd_type="${initrd_type:?}" |
| 95 | local url="${fvp_initrd_urls[$initrd_type]}" |
| 96 | |
| 97 | url="${url:?}" saveas="initrd.bin" fetch_file |
| 98 | archive_file "initrd.bin" |
| 99 | } |
| 100 | |
| 101 | get_dtb() { |
| 102 | local dtb_type="${dtb_type:?}" |
| 103 | local dtb_url |
| 104 | local dtb_saveas="$workspace/dtb.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 105 | local cc="$(get_tf_opt CROSS_COMPILE)" |
| 106 | local pp_flags="-P -nostdinc -undef -x assembler-with-cpp" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 107 | |
| 108 | case "$dtb_type" in |
| 109 | "fvp-base-quad-cluster-gicv3-psci") |
| 110 | # Get the quad-cluster FDT from pdsw area |
| 111 | dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb" |
| 112 | url="$dtb_url" saveas="$dtb_saveas" fetch_file |
| 113 | ;; |
| 114 | "sgm775") |
| 115 | # Get the SGM775 FDT from pdsw area |
| 116 | dtb_url="$sgm_prebuilts/sgm775.dtb" |
| 117 | url="$dtb_url" saveas="$dtb_saveas" fetch_file |
| 118 | ;; |
| 119 | *) |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 120 | # Preprocess DTS file |
| 121 | ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \ |
| 122 | -o "$workspace/${dtb_type}.pre.dts" \ |
| 123 | "$tf_root/fdts/${dtb_type}.dts" |
| 124 | # Generate DTB file from DTS |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 125 | dtc -I dts -O dtb \ |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 126 | "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 127 | esac |
| 128 | |
| 129 | archive_file "$dtb_saveas" |
| 130 | } |
| 131 | |
| 132 | get_rootfs() { |
| 133 | local tmpdir |
| 134 | local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')" |
| 135 | local cached="$project_filer/ci-files/$fs_base" |
| 136 | |
| 137 | if upon "$jenkins_run" && [ -f "$cached" ]; then |
| 138 | # Job workspace is limited in size, and the root file system is |
| 139 | # quite large. This means, parallel runs of root file system |
| 140 | # tests could fail. So, for Jenkins runs, copy and use the root |
| 141 | # file system image from the $CI_SCRATCH location |
| 142 | local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER" |
| 143 | mkdir -p "$private" |
| 144 | rm -f "$private/rootfs.bin" |
| 145 | url="$cached" saveas="$private/rootfs.bin" fetch_file |
| 146 | ln -s "$private/rootfs.bin" "$archive/rootfs.bin" |
| 147 | return |
| 148 | fi |
| 149 | |
| 150 | tmpdir="$(mktempdir)" |
| 151 | pushd "$tmpdir" |
| 152 | url="$rootfs_url" saveas="rootfs.bin" fetch_file |
| 153 | |
| 154 | # Possibly, the filesystem image we just downloaded is compressed. |
| 155 | # Decompress it if required. |
| 156 | if file "rootfs.bin" | grep -iq 'gzip compressed data'; then |
| 157 | echo "Decompressing root file system image rootfs.bin ..." |
| 158 | gunzip --stdout "rootfs.bin" > uncompressed_fs.bin |
| 159 | mv uncompressed_fs.bin "rootfs.bin" |
| 160 | fi |
| 161 | |
| 162 | archive_file "rootfs.bin" |
| 163 | popd |
| 164 | } |
| 165 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 166 | fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i" |
| 167 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 168 | fvp_romlib_runtime() { |
| 169 | local tmpdir="$(mktempdir)" |
| 170 | |
| 171 | # Save BL1 and romlib binaries from original build |
| 172 | mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin" |
| 173 | mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin" |
| 174 | |
| 175 | # Patch index file |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 176 | cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup" |
| 177 | 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] | 178 | |
| 179 | # Rebuild with patched file |
| 180 | echo "Building patched romlib:" |
| 181 | build_tf |
| 182 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 183 | # Retrieve original BL1 and romlib binaries |
| 184 | mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" |
| 185 | mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" |
| 186 | } |
| 187 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 188 | fvp_romlib_cleanup() { |
| 189 | # Restore original index |
| 190 | mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" |
| 191 | } |
| 192 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 193 | set +u |