blob: 476a6fd936adde257753f9f5282a19743012dfe2 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Harrison Mutai65828182023-03-27 14:18:18 +01003# Copyright (c) 2019-2023 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
Manish V Badarkhefac74d32024-01-29 18:44:03 +000011scp_bl1_url="$scp_mcp_downloads/juno/platform_variant_BOARD/release/juno-bl1-bypass.bin"
12scp_bl2_url="$scp_mcp_downloads/juno/platform_variant_BOARD/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
Andre Przywara139d58d2021-12-03 13:39:11 +000033get_ml_uboot_bin() {
34 url="$ml_uboot_bl33_url" saveas="uboot.bin" fetch_file
35 archive_file "uboot.bin"
36 url="$uboot_env_url" saveas="blank.img" fetch_file
37 archive_file "blank.img"
38}
39
40get_linux_image() {
41 url="$linux_image_url" saveas="Image" fetch_file
42 archive_file "Image"
43 url="$linux_busybox_initrd_url" saveas="ramdisk.img" fetch_file
44 archive_file "ramdisk.img"
45}
46
Fathi Boudra422bf772019-12-02 11:10:16 +020047gen_recovery_image32() {
48 url="$juno32_recovery_root" gen_recovery_image "$@"
49}
50
Zelalem219df412020-05-17 19:21:20 -050051gen_recovery_image32_oe() {
52 url="$juno32_recovery_root_oe" gen_recovery_image "$@"
53}
54
Fathi Boudra422bf772019-12-02 11:10:16 +020055gen_recovery_image() {
56 local zip_dir="$workspace/juno_recovery"
57 local zip_file="${zip_dir}.zip"
58 local url="${url:-$juno_recovery_root}"
59
60 saveas="$zip_dir" url="$url" fetch_directory
61 if [ "$*" ]; then
Andre Przywaracb154792021-12-03 13:24:03 +000062 # Replace files needed for this test. Copying them first so
63 # that the subsequent copy can replace it if necessary.
64 url="$scp_bl1_url" saveas="$zip_dir/SOFTWARE/scp_bl1.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +020065 cp -f "$@" "$zip_dir/SOFTWARE"
66 fi
67
Andre Przywara139d58d2021-12-03 13:39:11 +000068 # The Linaro recovery image has a bug in the images.txt files, which
69 # puts the U-Boot environment in the wrong place (the address is
70 # relative to the beginning of NOR flash, it's not an absolute MMIO
71 # address). Fix that up so that we can update the environment.
72 sed -ie "s/0x0BFC0000/0x03FC0000/" "$zip_dir"/SITE1/HBI0262?/images.txt
73
Fathi Boudra422bf772019-12-02 11:10:16 +020074 # If an image.txt file was specified, replace all image.txt file inside
75 # the recovery with the specified one.
76 if upon "$image_txt"; then
77 find "$zip_dir" -name images.txt -exec cp -f "$image_txt" {} \;
78 fi
79
Leonardo Sandoval7fe8e552020-07-30 17:01:29 -050080 (cd "$zip_dir" && zip -rq "$zip_file" -- *)
Fathi Boudra422bf772019-12-02 11:10:16 +020081 archive_file "$zip_file"
82}
83
84gen_juno_yaml() {
Harrison Mutai65828182023-03-27 14:18:18 +010085 local yaml_file="$workspace/juno.yaml"
86 local job_file="$workspace/job.yaml"
Fathi Boudra422bf772019-12-02 11:10:16 +020087 local payload_type="${payload_type:?}"
88
Nicola Mazzucatoa5192542022-05-13 17:13:24 +010089 bin_mode="$mode" juno_revision="$juno_revision" \
Fathi Boudra422bf772019-12-02 11:10:16 +020090 "$ci_root/script/gen_juno_${payload_type}_yaml.sh" > "$yaml_file"
91
Harrison Mutai65828182023-03-27 14:18:18 +010092 cp "$yaml_file" "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +020093 archive_file "$yaml_file"
Harrison Mutai65828182023-03-27 14:18:18 +010094 archive_file "$job_file"
Fathi Boudra422bf772019-12-02 11:10:16 +020095}
96
97juno_aarch32_runtime() {
Fathi Boudra422bf772019-12-02 11:10:16 +020098 echo "Building BL32 in AArch32 for Juno:"
99 sed 's/^/\t/' < "${config_file:?}"
Manish V Badarkhe224bf182022-03-07 21:14:07 +0000100
101 # Build BL32 for Juno in AArch32. Since build_tf does a realclean, we'll
102 # lose the tools binaries. Build that again for later use.
103 if upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then
104 tf_build_targets="fiptool certtool bl32"
105 else
106 tf_build_targets="fiptool bl32"
107 fi
108
109 tf_build_config="$config_file" tf_build_targets="$tf_build_targets" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200110 build_tf
111
112 # Copy BL32 to a temporary directoy, and update it in the FIP
113 local tmpdir="$(mktempdir)"
114 from="$tf_root/build/juno/$mode" to="$tmpdir" collect_build_artefacts
115 bin_name="tos-fw" src="$tmpdir/bl32.bin" fip_update
116}
117
Fathi Boudra422bf772019-12-02 11:10:16 +0200118set +u