blob: 421d997fae3eb1e74fa40d5372c56c3ea05fda1a [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Manish V Badarkhe224bf182022-03-07 21:14:07 +00003# Copyright (c) 2019-2022 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
Maksims Svecovsa6c4dc22021-10-21 12:01:17 +010010# Pre-built SCP/MCP binaries
Jayanth Dodderi Chidanandcd8da662022-04-06 14:11:00 +010011scp_bl1_url="$scp_mcp_downloads/juno/release/juno-bl1-bypass.bin"
12scp_bl2_url="$scp_mcp_downloads/juno/release/juno-bl2.bin"
Alexei Fedorov812ba0a2021-04-27 18:50:47 +010013
Zelalem219df412020-05-17 19:21:20 -050014psci_reset2_scp_bl2_url="$tfa_downloads/psci_reset2/scp_bl2.bin"
Fathi Boudra422bf772019-12-02 11:10:16 +020015uboot_bl33_url="$linaro_release/juno-latest-oe-uboot/SOFTWARE/bl33-uboot.bin"
Zelalem219df412020-05-17 19:21:20 -050016optee_fip_url="$linaro_release/juno-ack-android-uboot/SOFTWARE/fip.bin"
17
Fathi Boudra422bf772019-12-02 11:10:16 +020018juno_recovery_root="$linaro_release/juno-latest-oe-uboot"
19
20uboot32_fip_url="$linaro_release/juno32-latest-oe-uboot/SOFTWARE/fip.bin"
21juno32_recovery_root="$linaro_release/juno32-latest-busybox-uboot"
Zelalem219df412020-05-17 19:21:20 -050022juno32_recovery_root_oe="$linaro_release/juno32-latest-oe-uboot"
Fathi Boudra422bf772019-12-02 11:10:16 +020023
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -050024juno_rootfs_url="${juno_rootfs_url:-$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz}"
25juno32_rootfs_url="${juno32_rootfs_url:-$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz}"
Fathi Boudra422bf772019-12-02 11:10:16 +020026
Fathi Boudra422bf772019-12-02 11:10:16 +020027get_optee_bin() {
Zelalem219df412020-05-17 19:21:20 -050028 local tmpdir="$(mktempdir)"
29
30 pushd "$tmpdir"
31 extract_fip "$optee_fip_url"
32 mv "tos-fw.bin" "bl32.bin"
Fathi Boudra422bf772019-12-02 11:10:16 +020033 archive_file "bl32.bin"
Zelalem219df412020-05-17 19:21:20 -050034 popd
Fathi Boudra422bf772019-12-02 11:10:16 +020035}
36
37get_scp_bl2_bin() {
38 url="$scp_bl2_url" saveas="scp_bl2.bin" fetch_file
39 archive_file "scp_bl2.bin"
40}
41
Zelalem219df412020-05-17 19:21:20 -050042get_psci_reset2_scp_bl2_bin() {
43 url="$psci_reset2_scp_bl2_url" saveas="scp_bl2.bin" fetch_file
44 archive_file "scp_bl2.bin"
45}
46
Fathi Boudra422bf772019-12-02 11:10:16 +020047get_uboot32_bin() {
48 local tmpdir="$(mktempdir)"
49
50 pushd "$tmpdir"
51 extract_fip "$uboot32_fip_url"
52 mv "nt-fw.bin" "uboot.bin"
53 archive_file "uboot.bin"
54 popd
55}
56
57get_uboot_bin() {
58 url="$uboot_bl33_url" saveas="uboot.bin" fetch_file
59 archive_file "uboot.bin"
60}
61
62gen_recovery_image32() {
63 url="$juno32_recovery_root" gen_recovery_image "$@"
64}
65
Zelalem219df412020-05-17 19:21:20 -050066gen_recovery_image32_oe() {
67 url="$juno32_recovery_root_oe" gen_recovery_image "$@"
68}
69
Fathi Boudra422bf772019-12-02 11:10:16 +020070gen_recovery_image() {
71 local zip_dir="$workspace/juno_recovery"
72 local zip_file="${zip_dir}.zip"
73 local url="${url:-$juno_recovery_root}"
74
75 saveas="$zip_dir" url="$url" fetch_directory
76 if [ "$*" ]; then
Andre Przywaracb154792021-12-03 13:24:03 +000077 # Replace files needed for this test. Copying them first so
78 # that the subsequent copy can replace it if necessary.
79 url="$scp_bl1_url" saveas="$zip_dir/SOFTWARE/scp_bl1.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020080 cp -f "$@" "$zip_dir/SOFTWARE"
81 fi
82
83 # If an image.txt file was specified, replace all image.txt file inside
84 # the recovery with the specified one.
85 if upon "$image_txt"; then
86 find "$zip_dir" -name images.txt -exec cp -f "$image_txt" {} \;
87 fi
88
Leonardo Sandoval7fe8e552020-07-30 17:01:29 -050089 (cd "$zip_dir" && zip -rq "$zip_file" -- *)
Fathi Boudra422bf772019-12-02 11:10:16 +020090 archive_file "$zip_file"
91}
92
93gen_juno_yaml() {
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -050094 local yaml_file="$workspace/juno.yaml"
95 local job_file="$workspace/job.yaml"
Fathi Boudra422bf772019-12-02 11:10:16 +020096 local payload_type="${payload_type:?}"
97
Nicola Mazzucatoa5192542022-05-13 17:13:24 +010098 bin_mode="$mode" juno_revision="$juno_revision" \
Fathi Boudra422bf772019-12-02 11:10:16 +020099 "$ci_root/script/gen_juno_${payload_type}_yaml.sh" > "$yaml_file"
100
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500101 cp "$yaml_file" "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +0200102 archive_file "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500103 archive_file "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +0200104}
105
106juno_aarch32_runtime() {
Fathi Boudra422bf772019-12-02 11:10:16 +0200107 echo "Building BL32 in AArch32 for Juno:"
108 sed 's/^/\t/' < "${config_file:?}"
Manish V Badarkhe224bf182022-03-07 21:14:07 +0000109
110 # Build BL32 for Juno in AArch32. Since build_tf does a realclean, we'll
111 # lose the tools binaries. Build that again for later use.
112 if upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then
113 tf_build_targets="fiptool certtool bl32"
114 else
115 tf_build_targets="fiptool bl32"
116 fi
117
118 tf_build_config="$config_file" tf_build_targets="$tf_build_targets" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200119 build_tf
120
121 # Copy BL32 to a temporary directoy, and update it in the FIP
122 local tmpdir="$(mktempdir)"
123 from="$tf_root/build/juno/$mode" to="$tmpdir" collect_build_artefacts
124 bin_name="tos-fw" src="$tmpdir/bl32.bin" fip_update
125}
126
Fathi Boudra422bf772019-12-02 11:10:16 +0200127set +u