blob: 137c923aa7cd219b6e239132cee5d351077af3b0 [file] [log] [blame]
Fathi Boudra422bf772019-12-02 11:10:16 +02001#!/bin/bash
2#
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}"
Fathi Boudra422bf772019-12-02 11:10:16 +020012bl32_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
Fathi Boudra422bf772019-12-02 11:10:16 +020039# FVP initrd URLs
40declare -A fvp_initrd_urls
41fvp_initrd_urls=(
42[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +020043[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
49get_optee_bin() {
50 url="$jenkins_url/job/tf-optee-build/PLATFORM_FLAVOR=fvp,label=arch-dev/lastSuccessfulBuild/artifact/artefacts/tee.bin" \
Zelalem219df412020-05-17 19:21:20 -050051 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020052 archive_file "bl32.bin"
53}
54
55get_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
65get_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
72get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -050073 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 Boudra422bf772019-12-02 11:10:16 +020075
76 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
77 archive_file "uefi.bin"
78}
79
80get_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
88get_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
96get_dtb() {
97 local dtb_type="${dtb_type:?}"
98 local dtb_url
99 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500100 local cc="$(get_tf_opt CROSS_COMPILE)"
101 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200102
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 *)
Zelalem219df412020-05-17 19:21:20 -0500115 # 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 Boudra422bf772019-12-02 11:10:16 +0200120 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500121 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200122 esac
123
124 archive_file "$dtb_saveas"
125}
126
127get_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
Zelalem219df412020-05-17 19:21:20 -0500161fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
162
Fathi Boudra422bf772019-12-02 11:10:16 +0200163fvp_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
Zelalem219df412020-05-17 19:21:20 -0500171 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 Boudra422bf772019-12-02 11:10:16 +0200173
174 # Rebuild with patched file
175 echo "Building patched romlib:"
176 build_tf
177
Fathi Boudra422bf772019-12-02 11:10:16 +0200178 # 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
Zelalem219df412020-05-17 19:21:20 -0500183fvp_romlib_cleanup() {
184 # Restore original index
185 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
186}
187
Fathi Boudra422bf772019-12-02 11:10:16 +0200188set +u