blob: 42434dc18700720e7add0234c59e97b94f22240a [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Zelalem219df412020-05-17 19:21:20 -05003# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -u
9
10bl1_addr="${bl1_addr:-0x0}"
Zelalem219df412020-05-17 19:21:20 -050011bl31_addr="${bl31_addr:-0x04001000}"
Zelalem1b874612020-08-04 18:08:18 -050012bl32_addr="${bl32_addr:-0x04003000}"
Fathi Boudra422bf772019-12-02 11:10:16 +020013bl33_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
Manish Pandey3c435582020-07-15 12:14:26 +010020# SPM requires following addresses for RESET_TO_BL31 case
21spm_addr="${spm_addr:-0x6000000}"
22spmc_manifest_addr="${spmc_addr:-0x0403f000}"
23sp1_addr="${sp1_addr:-0x7000000}"
24sp2_addr="${sp2_addr:-0x7100000}"
Olivier Deprez0b834092020-08-21 08:36:01 +020025sp3_addr="${sp3_addr:-0x7200000}"
Manish Pandey3c435582020-07-15 12:14:26 +010026
Fathi Boudra422bf772019-12-02 11:10:16 +020027ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
28fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
29backup_fip_addr="${backup_fip_addr:-0x09000000}"
30romlib_addr="${romlib_addr:-0x03ff2000}"
31
32uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
33
34rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img.gz"
35
36# FVP Kernel URLs
37declare -A fvp_kernels
38fvp_kernels=(
39[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
40[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
41[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
42[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
43[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
44)
45
Fathi Boudra422bf772019-12-02 11:10:16 +020046# FVP initrd URLs
47declare -A fvp_initrd_urls
48fvp_initrd_urls=(
49[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +020050[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
51[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
52[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
53)
54
Fathi Boudra422bf772019-12-02 11:10:16 +020055get_optee_bin() {
56 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
Zelalem219df412020-05-17 19:21:20 -050057 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020058 archive_file "bl32.bin"
59}
60
61get_uboot32_bin() {
62 local tmpdir="$(mktempdir)"
63
64 pushd "$tmpdir"
65 extract_fip "$uboot32_fip_url"
66 mv "nt-fw.bin" "uboot.bin"
67 archive_file "uboot.bin"
68 popd
69}
70
71get_uboot_bin() {
72 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
73
74 url="$uboot_url" saveas="uboot.bin" fetch_file
75 archive_file "uboot.bin"
76}
77
78get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -050079 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
80 uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}"
Fathi Boudra422bf772019-12-02 11:10:16 +020081
82 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
83 archive_file "uefi.bin"
84}
85
86get_kernel() {
87 local kernel_type="${kernel_type:?}"
88 local url="${fvp_kernels[$kernel_type]}"
89
90 url="${url:?}" saveas="kernel.bin" fetch_file
91 archive_file "kernel.bin"
92}
93
94get_initrd() {
95 local initrd_type="${initrd_type:?}"
96 local url="${fvp_initrd_urls[$initrd_type]}"
97
98 url="${url:?}" saveas="initrd.bin" fetch_file
99 archive_file "initrd.bin"
100}
101
102get_dtb() {
103 local dtb_type="${dtb_type:?}"
104 local dtb_url
105 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500106 local cc="$(get_tf_opt CROSS_COMPILE)"
107 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200108
109 case "$dtb_type" in
110 "fvp-base-quad-cluster-gicv3-psci")
111 # Get the quad-cluster FDT from pdsw area
112 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
113 url="$dtb_url" saveas="$dtb_saveas" fetch_file
114 ;;
115 "sgm775")
116 # Get the SGM775 FDT from pdsw area
117 dtb_url="$sgm_prebuilts/sgm775.dtb"
118 url="$dtb_url" saveas="$dtb_saveas" fetch_file
119 ;;
120 *)
Zelalem219df412020-05-17 19:21:20 -0500121 # Preprocess DTS file
122 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
123 -o "$workspace/${dtb_type}.pre.dts" \
124 "$tf_root/fdts/${dtb_type}.dts"
125 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200126 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500127 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200128 esac
129
130 archive_file "$dtb_saveas"
131}
132
133get_rootfs() {
134 local tmpdir
135 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
136 local cached="$project_filer/ci-files/$fs_base"
137
138 if upon "$jenkins_run" && [ -f "$cached" ]; then
139 # Job workspace is limited in size, and the root file system is
140 # quite large. This means, parallel runs of root file system
141 # tests could fail. So, for Jenkins runs, copy and use the root
142 # file system image from the $CI_SCRATCH location
143 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
144 mkdir -p "$private"
145 rm -f "$private/rootfs.bin"
146 url="$cached" saveas="$private/rootfs.bin" fetch_file
147 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
148 return
149 fi
150
151 tmpdir="$(mktempdir)"
152 pushd "$tmpdir"
153 url="$rootfs_url" saveas="rootfs.bin" fetch_file
154
155 # Possibly, the filesystem image we just downloaded is compressed.
156 # Decompress it if required.
157 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
158 echo "Decompressing root file system image rootfs.bin ..."
159 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
160 mv uncompressed_fs.bin "rootfs.bin"
161 fi
162
163 archive_file "rootfs.bin"
164 popd
165}
166
Zelalem219df412020-05-17 19:21:20 -0500167fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
168
Fathi Boudra422bf772019-12-02 11:10:16 +0200169fvp_romlib_runtime() {
170 local tmpdir="$(mktempdir)"
171
172 # Save BL1 and romlib binaries from original build
173 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
174 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
175
176 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500177 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
178 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200179
180 # Rebuild with patched file
181 echo "Building patched romlib:"
182 build_tf
183
Fathi Boudra422bf772019-12-02 11:10:16 +0200184 # Retrieve original BL1 and romlib binaries
185 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
186 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
187}
188
Zelalem219df412020-05-17 19:21:20 -0500189fvp_romlib_cleanup() {
190 # Restore original index
191 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
192}
193
Fathi Boudra422bf772019-12-02 11:10:16 +0200194set +u