blob: 9bb8a348a9e6e21d26ea151317be05a1446ac642 [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}"
25
Fathi Boudra422bf772019-12-02 11:10:16 +020026ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
27fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
28backup_fip_addr="${backup_fip_addr:-0x09000000}"
29romlib_addr="${romlib_addr:-0x03ff2000}"
30
31uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
32
33rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img.gz"
34
35# FVP Kernel URLs
36declare -A fvp_kernels
37fvp_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 Boudra422bf772019-12-02 11:10:16 +020045# FVP initrd URLs
46declare -A fvp_initrd_urls
47fvp_initrd_urls=(
48[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +020049[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 Boudra422bf772019-12-02 11:10:16 +020054get_optee_bin() {
55 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
Zelalem219df412020-05-17 19:21:20 -050056 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020057 archive_file "bl32.bin"
58}
59
60get_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
70get_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
77get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -050078 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 Boudra422bf772019-12-02 11:10:16 +020080
81 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
82 archive_file "uefi.bin"
83}
84
85get_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
93get_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
101get_dtb() {
102 local dtb_type="${dtb_type:?}"
103 local dtb_url
104 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500105 local cc="$(get_tf_opt CROSS_COMPILE)"
106 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200107
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 *)
Zelalem219df412020-05-17 19:21:20 -0500120 # 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 Boudra422bf772019-12-02 11:10:16 +0200125 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500126 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200127 esac
128
129 archive_file "$dtb_saveas"
130}
131
132get_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
Zelalem219df412020-05-17 19:21:20 -0500166fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
167
Fathi Boudra422bf772019-12-02 11:10:16 +0200168fvp_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
Zelalem219df412020-05-17 19:21:20 -0500176 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 Boudra422bf772019-12-02 11:10:16 +0200178
179 # Rebuild with patched file
180 echo "Building patched romlib:"
181 build_tf
182
Fathi Boudra422bf772019-12-02 11:10:16 +0200183 # 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
Zelalem219df412020-05-17 19:21:20 -0500188fvp_romlib_cleanup() {
189 # Restore original index
190 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
191}
192
Fathi Boudra422bf772019-12-02 11:10:16 +0200193set +u