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