Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
Manish V Badarkhe | 224bf18 | 2022-03-07 21:14:07 +0000 | [diff] [blame] | 3 | # Copyright (c) 2019-2022 Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | set -u |
| 9 | |
Maksims Svecovs | a6c4dc2 | 2021-10-21 12:01:17 +0100 | [diff] [blame] | 10 | # Pre-built SCP/MCP binaries |
Jayanth Dodderi Chidanand | cd8da66 | 2022-04-06 14:11:00 +0100 | [diff] [blame] | 11 | scp_bl1_url="$scp_mcp_downloads/juno/release/juno-bl1-bypass.bin" |
| 12 | scp_bl2_url="$scp_mcp_downloads/juno/release/juno-bl2.bin" |
Alexei Fedorov | 812ba0a | 2021-04-27 18:50:47 +0100 | [diff] [blame] | 13 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 14 | psci_reset2_scp_bl2_url="$tfa_downloads/psci_reset2/scp_bl2.bin" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 15 | uboot_bl33_url="$linaro_release/juno-latest-oe-uboot/SOFTWARE/bl33-uboot.bin" |
Andre Przywara | 139d58d | 2021-12-03 13:39:11 +0000 | [diff] [blame] | 16 | ml_uboot_bl33_url="$tfa_downloads/linux_boot/u-boot-juno.bin" |
| 17 | uboot_env_url="$tfa_downloads/linux_boot/u-boot-env.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 18 | optee_fip_url="$linaro_release/juno-ack-android-uboot/SOFTWARE/fip.bin" |
| 19 | |
Andre Przywara | 139d58d | 2021-12-03 13:39:11 +0000 | [diff] [blame] | 20 | linux_image_url="$tfa_downloads/linux_boot/Image.gz" |
| 21 | # Busybox based initrd |
| 22 | linux_busybox_initrd_url="$tfa_downloads/linux_boot/initbb.img" |
| 23 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 24 | juno_recovery_root="$linaro_release/juno-latest-oe-uboot" |
| 25 | |
| 26 | uboot32_fip_url="$linaro_release/juno32-latest-oe-uboot/SOFTWARE/fip.bin" |
| 27 | juno32_recovery_root="$linaro_release/juno32-latest-busybox-uboot" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 28 | juno32_recovery_root_oe="$linaro_release/juno32-latest-oe-uboot" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 29 | |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 30 | juno_rootfs_url="${juno_rootfs_url:-$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz}" |
| 31 | juno32_rootfs_url="${juno32_rootfs_url:-$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 32 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 33 | get_optee_bin() { |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 34 | local tmpdir="$(mktempdir)" |
| 35 | |
| 36 | pushd "$tmpdir" |
| 37 | extract_fip "$optee_fip_url" |
| 38 | mv "tos-fw.bin" "bl32.bin" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 39 | archive_file "bl32.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 40 | popd |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | get_scp_bl2_bin() { |
| 44 | url="$scp_bl2_url" saveas="scp_bl2.bin" fetch_file |
| 45 | archive_file "scp_bl2.bin" |
| 46 | } |
| 47 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 48 | get_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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 53 | get_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 | |
| 63 | get_uboot_bin() { |
| 64 | url="$uboot_bl33_url" saveas="uboot.bin" fetch_file |
| 65 | archive_file "uboot.bin" |
| 66 | } |
| 67 | |
Andre Przywara | 139d58d | 2021-12-03 13:39:11 +0000 | [diff] [blame] | 68 | get_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 | |
| 75 | get_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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 82 | gen_recovery_image32() { |
| 83 | url="$juno32_recovery_root" gen_recovery_image "$@" |
| 84 | } |
| 85 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 86 | gen_recovery_image32_oe() { |
| 87 | url="$juno32_recovery_root_oe" gen_recovery_image "$@" |
| 88 | } |
| 89 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 90 | gen_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 Przywara | cb15479 | 2021-12-03 13:24:03 +0000 | [diff] [blame] | 97 | # 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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 100 | cp -f "$@" "$zip_dir/SOFTWARE" |
| 101 | fi |
| 102 | |
Andre Przywara | 139d58d | 2021-12-03 13:39:11 +0000 | [diff] [blame] | 103 | # 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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 109 | # 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 Sandoval | 7fe8e55 | 2020-07-30 17:01:29 -0500 | [diff] [blame] | 115 | (cd "$zip_dir" && zip -rq "$zip_file" -- *) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 116 | archive_file "$zip_file" |
| 117 | } |
| 118 | |
| 119 | gen_juno_yaml() { |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 120 | local yaml_file="$workspace/juno.yaml" |
| 121 | local job_file="$workspace/job.yaml" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 122 | local payload_type="${payload_type:?}" |
| 123 | |
Nicola Mazzucato | a519254 | 2022-05-13 17:13:24 +0100 | [diff] [blame] | 124 | bin_mode="$mode" juno_revision="$juno_revision" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 125 | "$ci_root/script/gen_juno_${payload_type}_yaml.sh" > "$yaml_file" |
| 126 | |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 127 | cp "$yaml_file" "$job_file" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 128 | archive_file "$yaml_file" |
Leonardo Sandoval | be690bd | 2020-10-12 17:59:39 -0500 | [diff] [blame] | 129 | archive_file "$job_file" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | juno_aarch32_runtime() { |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 133 | echo "Building BL32 in AArch32 for Juno:" |
| 134 | sed 's/^/\t/' < "${config_file:?}" |
Manish V Badarkhe | 224bf18 | 2022-03-07 21:14:07 +0000 | [diff] [blame] | 135 | |
| 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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 145 | 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 Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 153 | set +u |