blob: e0dd44c71d437f31dfd4d592050c1eed0f127042 [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"
Andre Przywara139d58d2021-12-03 13:39:11 +000016ml_uboot_bl33_url="$tfa_downloads/linux_boot/u-boot-juno.bin"
17uboot_env_url="$tfa_downloads/linux_boot/u-boot-env.bin"
Zelalem219df412020-05-17 19:21:20 -050018optee_fip_url="$linaro_release/juno-ack-android-uboot/SOFTWARE/fip.bin"
19
Andre Przywara139d58d2021-12-03 13:39:11 +000020linux_image_url="$tfa_downloads/linux_boot/Image.gz"
21# Busybox based initrd
22linux_busybox_initrd_url="$tfa_downloads/linux_boot/initbb.img"
23
Fathi Boudra422bf772019-12-02 11:10:16 +020024juno_recovery_root="$linaro_release/juno-latest-oe-uboot"
25
26uboot32_fip_url="$linaro_release/juno32-latest-oe-uboot/SOFTWARE/fip.bin"
27juno32_recovery_root="$linaro_release/juno32-latest-busybox-uboot"
Zelalem219df412020-05-17 19:21:20 -050028juno32_recovery_root_oe="$linaro_release/juno32-latest-oe-uboot"
Fathi Boudra422bf772019-12-02 11:10:16 +020029
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -050030juno_rootfs_url="${juno_rootfs_url:-$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz}"
31juno32_rootfs_url="${juno32_rootfs_url:-$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz}"
Fathi Boudra422bf772019-12-02 11:10:16 +020032
Fathi Boudra422bf772019-12-02 11:10:16 +020033get_optee_bin() {
Zelalem219df412020-05-17 19:21:20 -050034 local tmpdir="$(mktempdir)"
35
36 pushd "$tmpdir"
37 extract_fip "$optee_fip_url"
38 mv "tos-fw.bin" "bl32.bin"
Fathi Boudra422bf772019-12-02 11:10:16 +020039 archive_file "bl32.bin"
Zelalem219df412020-05-17 19:21:20 -050040 popd
Fathi Boudra422bf772019-12-02 11:10:16 +020041}
42
43get_scp_bl2_bin() {
44 url="$scp_bl2_url" saveas="scp_bl2.bin" fetch_file
45 archive_file "scp_bl2.bin"
46}
47
Zelalem219df412020-05-17 19:21:20 -050048get_psci_reset2_scp_bl2_bin() {
49 url="$psci_reset2_scp_bl2_url" saveas="scp_bl2.bin" fetch_file
50 archive_file "scp_bl2.bin"
51}
52
Fathi Boudra422bf772019-12-02 11:10:16 +020053get_uboot32_bin() {
54 local tmpdir="$(mktempdir)"
55
56 pushd "$tmpdir"
57 extract_fip "$uboot32_fip_url"
58 mv "nt-fw.bin" "uboot.bin"
59 archive_file "uboot.bin"
60 popd
61}
62
63get_uboot_bin() {
64 url="$uboot_bl33_url" saveas="uboot.bin" fetch_file
65 archive_file "uboot.bin"
66}
67
Andre Przywara139d58d2021-12-03 13:39:11 +000068get_ml_uboot_bin() {
69 url="$ml_uboot_bl33_url" saveas="uboot.bin" fetch_file
70 archive_file "uboot.bin"
71 url="$uboot_env_url" saveas="blank.img" fetch_file
72 archive_file "blank.img"
73}
74
75get_linux_image() {
76 url="$linux_image_url" saveas="Image" fetch_file
77 archive_file "Image"
78 url="$linux_busybox_initrd_url" saveas="ramdisk.img" fetch_file
79 archive_file "ramdisk.img"
80}
81
Fathi Boudra422bf772019-12-02 11:10:16 +020082gen_recovery_image32() {
83 url="$juno32_recovery_root" gen_recovery_image "$@"
84}
85
Zelalem219df412020-05-17 19:21:20 -050086gen_recovery_image32_oe() {
87 url="$juno32_recovery_root_oe" gen_recovery_image "$@"
88}
89
Fathi Boudra422bf772019-12-02 11:10:16 +020090gen_recovery_image() {
91 local zip_dir="$workspace/juno_recovery"
92 local zip_file="${zip_dir}.zip"
93 local url="${url:-$juno_recovery_root}"
94
95 saveas="$zip_dir" url="$url" fetch_directory
96 if [ "$*" ]; then
Andre Przywaracb154792021-12-03 13:24:03 +000097 # Replace files needed for this test. Copying them first so
98 # that the subsequent copy can replace it if necessary.
99 url="$scp_bl1_url" saveas="$zip_dir/SOFTWARE/scp_bl1.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200100 cp -f "$@" "$zip_dir/SOFTWARE"
101 fi
102
Andre Przywara139d58d2021-12-03 13:39:11 +0000103 # The Linaro recovery image has a bug in the images.txt files, which
104 # puts the U-Boot environment in the wrong place (the address is
105 # relative to the beginning of NOR flash, it's not an absolute MMIO
106 # address). Fix that up so that we can update the environment.
107 sed -ie "s/0x0BFC0000/0x03FC0000/" "$zip_dir"/SITE1/HBI0262?/images.txt
108
Fathi Boudra422bf772019-12-02 11:10:16 +0200109 # If an image.txt file was specified, replace all image.txt file inside
110 # the recovery with the specified one.
111 if upon "$image_txt"; then
112 find "$zip_dir" -name images.txt -exec cp -f "$image_txt" {} \;
113 fi
114
Leonardo Sandoval7fe8e552020-07-30 17:01:29 -0500115 (cd "$zip_dir" && zip -rq "$zip_file" -- *)
Fathi Boudra422bf772019-12-02 11:10:16 +0200116 archive_file "$zip_file"
117}
118
119gen_juno_yaml() {
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500120 local yaml_file="$workspace/juno.yaml"
121 local job_file="$workspace/job.yaml"
Fathi Boudra422bf772019-12-02 11:10:16 +0200122 local payload_type="${payload_type:?}"
123
Nicola Mazzucatoa5192542022-05-13 17:13:24 +0100124 bin_mode="$mode" juno_revision="$juno_revision" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200125 "$ci_root/script/gen_juno_${payload_type}_yaml.sh" > "$yaml_file"
126
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500127 cp "$yaml_file" "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +0200128 archive_file "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500129 archive_file "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +0200130}
131
132juno_aarch32_runtime() {
Fathi Boudra422bf772019-12-02 11:10:16 +0200133 echo "Building BL32 in AArch32 for Juno:"
134 sed 's/^/\t/' < "${config_file:?}"
Manish V Badarkhe224bf182022-03-07 21:14:07 +0000135
136 # Build BL32 for Juno in AArch32. Since build_tf does a realclean, we'll
137 # lose the tools binaries. Build that again for later use.
138 if upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then
139 tf_build_targets="fiptool certtool bl32"
140 else
141 tf_build_targets="fiptool bl32"
142 fi
143
144 tf_build_config="$config_file" tf_build_targets="$tf_build_targets" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200145 build_tf
146
147 # Copy BL32 to a temporary directoy, and update it in the FIP
148 local tmpdir="$(mktempdir)"
149 from="$tf_root/build/juno/$mode" to="$tmpdir" collect_build_artefacts
150 bin_name="tos-fw" src="$tmpdir/bl32.bin" fip_update
151}
152
Fathi Boudra422bf772019-12-02 11:10:16 +0200153set +u