blob: 052317eb3eb2bb1af716c5f45d7c42b3d4a91bb4 [file] [log] [blame]
Fathi Boudra422bf772019-12-02 11:10:16 +02001#!/bin/bash
2#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -u
9
10bl1_addr="${bl1_addr:-0x0}"
11bl31_addr="${bl31_addr:-0x04020000}"
12bl32_addr="${bl32_addr:-0x04002000}"
13bl33_addr="${bl33_addr:-0x88000000}"
14dtb_addr="${dtb_addr:-0x82000000}"
15fip_addr="${fip_addr:-0x08000000}"
16initrd_addr="${initrd_addr:-0x84000000}"
17kernel_addr="${kernel_addr:-0x80080000}"
18el3_payload_addr="${el3_payload_addr:-0x80000000}"
19
20ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
21fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
22backup_fip_addr="${backup_fip_addr:-0x09000000}"
23romlib_addr="${romlib_addr:-0x03ff2000}"
24
25uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
26
27rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img.gz"
28
29# FVP Kernel URLs
30declare -A fvp_kernels
31fvp_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
39# From Linaro 16.12 release onwards the prebuilt ramdisk.img
40# contains 32-bit binaries which fails to boot on a AArch64-only
41# system.
42#
43# An updated 64-bit only ramdisk.img, which has been manually built,
44# has replaced the prebuilt version.
45#
46# When updating to a future Linaro release if this issue has not
47# been resolved then the fvp-uboot-tspd-aarch64-only run-config will
48# fail.
49
50# FVP initrd URLs
51declare -A fvp_initrd_urls
52fvp_initrd_urls=(
53[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
54[aarch64-only-ramdisk]="$linaro_release/fvp-latest-busybox-uboot/ramdisk-aarch64.img"
55[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
56[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
57[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
58)
59
60# FIXME use optee pre-built binaries
61get_optee_bin() {
62 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
63 saveas="bl32.bin" fetch_file
64 archive_file "bl32.bin"
65}
66
67get_uboot32_bin() {
68 local tmpdir="$(mktempdir)"
69
70 pushd "$tmpdir"
71 extract_fip "$uboot32_fip_url"
72 mv "nt-fw.bin" "uboot.bin"
73 archive_file "uboot.bin"
74 popd
75}
76
77get_uboot_bin() {
78 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
79
80 url="$uboot_url" saveas="uboot.bin" fetch_file
81 archive_file "uboot.bin"
82}
83
84get_uefi_bin() {
85
86 local project_scratch=/arm/projectscratch/ssg/uefi
87
88 local uefi_build_type="${uefi_build_type:-DEBUG}"
89 local uefi_build_aarch="${uefi_build_aarch:-AARCH64}"
90 local uefi_build_toolchain="${uefi_build_toolchain:-GCC5}"
91 local uefi_build_jobname="${uefi_build_jobname:-uefi-woa-github-edk2-master-ci}"
92 local uefi_tables="${uefi_tables:-static}"
93
94 uefi_ci_bin=FVP_${uefi_build_aarch}_EFI.fd
95 uefi_build_conf=fvp/${uefi_build_type}_${uefi_build_toolchain}/$uefi_build_aarch
96
97 if [ -d $project_scratch ]; then
98 uefi_artifacts_root=$project_scratch/$uefi_tables/Artifacts
99 else
100 local uefi_ci_job_url="$jenkins_url/job/uefi/job/$uefi_build_jobname"
101
102 local uefi_ci_conf="BUILD_AARCH=$uefi_build_aarch"
103 uefi_ci_conf="${uefi_ci_conf},BUILD_TYPE=${uefi_build_type}"
104 uefi_ci_conf="${uefi_ci_conf},EDK2_BUILD_PLATFORM=fvp"
105 uefi_ci_conf="${uefi_ci_conf},label=arch-dev"
106
107 local artifacts=lastSuccessfulBuild/artifact/Artifacts
108 uefi_artifacts_root=$uefi_ci_job_url/$uefi_ci_conf/$artifacts
109
110 fi
111
112 uefi_ci_bin_url=$uefi_artifacts_root/$uefi_build_conf/$uefi_ci_bin
113
114 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
115 archive_file "uefi.bin"
116}
117
118get_kernel() {
119 local kernel_type="${kernel_type:?}"
120 local url="${fvp_kernels[$kernel_type]}"
121
122 url="${url:?}" saveas="kernel.bin" fetch_file
123 archive_file "kernel.bin"
124}
125
126get_initrd() {
127 local initrd_type="${initrd_type:?}"
128 local url="${fvp_initrd_urls[$initrd_type]}"
129
130 url="${url:?}" saveas="initrd.bin" fetch_file
131 archive_file "initrd.bin"
132}
133
134get_dtb() {
135 local dtb_type="${dtb_type:?}"
136 local dtb_url
137 local dtb_saveas="$workspace/dtb.bin"
138
139 case "$dtb_type" in
140 "fvp-base-quad-cluster-gicv3-psci")
141 # Get the quad-cluster FDT from pdsw area
142 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
143 url="$dtb_url" saveas="$dtb_saveas" fetch_file
144 ;;
145 "sgm775")
146 # Get the SGM775 FDT from pdsw area
147 dtb_url="$sgm_prebuilts/sgm775.dtb"
148 url="$dtb_url" saveas="$dtb_saveas" fetch_file
149 ;;
150 *)
151 # Generate DTB file from DTC
152 dtc -I dts -O dtb \
153 "$tf_root/fdts/${dtb_type}.dts" -o "$dtb_saveas"
154 esac
155
156 archive_file "$dtb_saveas"
157}
158
159get_rootfs() {
160 local tmpdir
161 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
162 local cached="$project_filer/ci-files/$fs_base"
163
164 if upon "$jenkins_run" && [ -f "$cached" ]; then
165 # Job workspace is limited in size, and the root file system is
166 # quite large. This means, parallel runs of root file system
167 # tests could fail. So, for Jenkins runs, copy and use the root
168 # file system image from the $CI_SCRATCH location
169 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
170 mkdir -p "$private"
171 rm -f "$private/rootfs.bin"
172 url="$cached" saveas="$private/rootfs.bin" fetch_file
173 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
174 return
175 fi
176
177 tmpdir="$(mktempdir)"
178 pushd "$tmpdir"
179 url="$rootfs_url" saveas="rootfs.bin" fetch_file
180
181 # Possibly, the filesystem image we just downloaded is compressed.
182 # Decompress it if required.
183 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
184 echo "Decompressing root file system image rootfs.bin ..."
185 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
186 mv uncompressed_fs.bin "rootfs.bin"
187 fi
188
189 archive_file "rootfs.bin"
190 popd
191}
192
193fvp_romlib_runtime() {
194 local tmpdir="$(mktempdir)"
195
196 # Save BL1 and romlib binaries from original build
197 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
198 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
199
200 # Patch index file
201 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$tmpdir/jmptbl.i"
202 sed -i '/rom_lib_init/! s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
203
204 # Rebuild with patched file
205 echo "Building patched romlib:"
206 build_tf
207
208 # Restore original index
209 mv "$tmpdir/jmptbl.i" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
210
211 # Retrieve original BL1 and romlib binaries
212 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
213 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
214}
215
216set +u