Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 4 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: BSD-3-Clause |
| 7 | # |
| 8 | |
| 9 | # Generate a JSON file which will be fed to TF-A as SPM_LAYOUT_FILE to package |
| 10 | # Secure Partitions as part of FIP. |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 11 | # Note the script will append the partition to the existing layout file. |
| 12 | # If you wish to only generate a layout file with this partition first run |
| 13 | # "make realclean" to remove the existing file. |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 14 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 15 | # $1 = Platform built path |
| 16 | # $2.. = List of Secure Partitions |
| 17 | # Output = $1/sp_layout.json |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 18 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 19 | GENERATED_JSON=$1/sp_layout.json |
| 20 | shift # Shift arguments 1 |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 21 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 22 | PARTITION_ALREADY_PRESENT=false |
Daniel Boulby | a285826 | 2022-07-05 11:03:37 +0100 | [diff] [blame] | 23 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 24 | CACTUS_PRESENT=false |
| 25 | IVY_PRESENT=false |
| 26 | IVY_SHIM_PRESENT=false |
| 27 | |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 28 | for target in "$@"; do |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 29 | case $target in |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 30 | cactus) CACTUS_PRESENT=true ;; |
| 31 | ivy) IVY_PRESENT=true ;; |
| 32 | ivy_shim) IVY_SHIM_PRESENT=true ;; |
| 33 | *) echo "Invalid target $target"; exit 1 ;; |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 34 | esac |
| 35 | done |
| 36 | |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 37 | echo -e "{" > "$GENERATED_JSON" |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 38 | |
| 39 | # To demonstrate communication between SP's, two cactus S-EL1 instances used. |
Max Shvetsov | 93119e3 | 2020-07-01 14:09:48 +0100 | [diff] [blame] | 40 | # To also test mapping of the RXTX region a third cactus S-EL1 instance is used. |
| 41 | # cactus-primary, cactus-secondary and cactus-tertiary have same binary but |
| 42 | # different partition manifests. |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 43 | if [ $CACTUS_PRESENT == "true" ]; then |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 44 | cat >> "$GENERATED_JSON" << EOF |
| 45 | "cactus-primary" : { |
| 46 | "image": { |
| 47 | "file": "cactus.bin", |
| 48 | "offset":"0x2000" |
| 49 | }, |
| 50 | "pm": { |
| 51 | "file": "cactus.dts", |
| 52 | "offset": "0x1000" |
| 53 | }, |
| 54 | "physical-load-address": "0x7000000", |
| 55 | "owner": "SiP" |
| 56 | }, |
| 57 | |
| 58 | "cactus-secondary" : { |
| 59 | "image": "cactus.bin", |
| 60 | "pm": "cactus-secondary.dts", |
| 61 | "physical-load-address": "0x7100000", |
J-Alves | cd46f27 | 2024-11-25 11:18:34 +0000 | [diff] [blame] | 62 | "owner": "Plat", |
| 63 | "package": "tl_pkg" |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 64 | }, |
| 65 | |
| 66 | "cactus-tertiary" : { |
| 67 | "image": "cactus.bin", |
| 68 | "pm": "cactus-tertiary.dts", |
| 69 | "physical-load-address": "0x7200000", |
J-Alves | cd46f27 | 2024-11-25 11:18:34 +0000 | [diff] [blame] | 70 | "owner": "Plat", |
Kathleen Capella | e8a17a9 | 2024-12-05 18:28:29 -0500 | [diff] [blame] | 71 | "package": "tl_pkg", |
Kathleen Capella | e8a17a9 | 2024-12-05 18:28:29 -0500 | [diff] [blame] | 72 | "size": "0x300000" |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 73 | EOF |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 74 | PARTITION_ALREADY_PRESENT=true |
| 75 | fi |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 76 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 77 | if [ $IVY_PRESENT == "true" ]; then |
| 78 | if [ $PARTITION_ALREADY_PRESENT == "true" ]; then |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 79 | echo -ne "\t},\n\n" >> "$GENERATED_JSON" |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 80 | fi |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 81 | |
| 82 | cat >> "$GENERATED_JSON" << EOF |
| 83 | "ivy" : { |
| 84 | "image": "ivy.bin", |
| 85 | "pm": "ivy-sel0.dts", |
| 86 | "physical-load-address": "0x7600000", |
J-Alves | cd46f27 | 2024-11-25 11:18:34 +0000 | [diff] [blame] | 87 | "owner": "Plat", |
| 88 | "package": "tl_pkg" |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 89 | } |
| 90 | EOF |
| 91 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 92 | PARTITION_ALREADY_PRESENT=true |
| 93 | elif [ $IVY_SHIM_PRESENT == "true" ]; then |
| 94 | if [ $PARTITION_ALREADY_PRESENT == "true" ]; then |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 95 | echo -ne "\t},\n\n" >> "$GENERATED_JSON" |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 96 | fi |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 97 | cat >> "$GENERATED_JSON" << EOF |
| 98 | "ivy" : { |
| 99 | "image": "ivy.bin", |
| 100 | "pm": "ivy-sel1.dts", |
| 101 | "physical-load-address": "0x7600000", |
J-Alves | cd46f27 | 2024-11-25 11:18:34 +0000 | [diff] [blame] | 102 | "owner": "Plat", |
Kathleen Capella | e8a17a9 | 2024-12-05 18:28:29 -0500 | [diff] [blame] | 103 | "package":"tl_pkg", |
| 104 | "size": "0x100000" |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 105 | } |
| 106 | EOF |
| 107 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 108 | PARTITION_ALREADY_PRESENT=true |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 109 | else |
| 110 | echo -ne "\t},\n" >> "$GENERATED_JSON" |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 111 | fi |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 112 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 113 | echo -e "\n}" >> "$GENERATED_JSON" |