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 | |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 15 | # $1 = Secure Partition |
Arunachalam Ganapathy | 51be1fe | 2020-09-22 13:25:21 +0100 | [diff] [blame] | 16 | # $2 = Platform built path |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 17 | # $3 = Ivy Shim present |
Arunachalam Ganapathy | 51be1fe | 2020-09-22 13:25:21 +0100 | [diff] [blame] | 18 | # Output = $2/sp_layout.json |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 19 | |
Arunachalam Ganapathy | 51be1fe | 2020-09-22 13:25:21 +0100 | [diff] [blame] | 20 | GENERATED_JSON=$2/sp_layout.json |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 21 | primary_dts="$1.dts" |
| 22 | |
Daniel Boulby | a285826 | 2022-07-05 11:03:37 +0100 | [diff] [blame^] | 23 | if [ "$1" == "ivy" ]; then |
| 24 | if [ "$3" == "1" ]; then |
| 25 | primary_dts="ivy-sel1.dts" |
| 26 | else |
| 27 | primary_dts="ivy-sel0.dts" |
| 28 | fi |
| 29 | fi |
| 30 | |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 31 | # Remove closing bracket and add comma if the dts is already present. |
| 32 | if [ ! -f "$GENERATED_JSON" ]; then |
| 33 | echo -e "{\n" >> "$GENERATED_JSON" |
| 34 | else |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 35 | if [ $(grep "$primary_dts" "$GENERATED_JSON" | wc -l) -eq "0" ]; then |
| 36 | sed -i '$d' "$GENERATED_JSON" |
| 37 | sed -i '$ s/$/,/' "$GENERATED_JSON" |
| 38 | echo -e "\n" >> "$GENERATED_JSON" |
| 39 | else |
| 40 | exit 0 |
| 41 | fi |
| 42 | fi |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 43 | |
| 44 | # To demonstrate communication between SP's, two cactus S-EL1 instances used. |
Max Shvetsov | 93119e3 | 2020-07-01 14:09:48 +0100 | [diff] [blame] | 45 | # To also test mapping of the RXTX region a third cactus S-EL1 instance is used. |
| 46 | # cactus-primary, cactus-secondary and cactus-tertiary have same binary but |
| 47 | # different partition manifests. |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 48 | if [ "$1" == "cactus" ]; then |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 49 | echo -e "\t\"$1-primary\" : {\n \ |
J-Alves | 31d8795 | 2022-04-04 12:34:16 +0100 | [diff] [blame] | 50 | \t\"image\": {\n \ |
| 51 | \t\t\"file\": \"$1.bin\",\n \ |
| 52 | \t\t\"offset\":\"0x2000\"\n\ |
| 53 | \t},\n \ |
| 54 | \t\"pm\": {\n \ |
| 55 | \t\t\"file\": \"$1.dts\",\n \ |
| 56 | \t\t\"offset\":\"0x1000\"\n\ |
| 57 | \t},\n |
Ruari Phipps | 67593f2 | 2020-07-24 16:21:35 +0100 | [diff] [blame] | 58 | \t\"owner\": \"SiP\"\n\t},\n\n\t\"$1-secondary\" : {\n \ |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 59 | \t\"image\": \"$1.bin\",\n \ |
Arunachalam Ganapathy | 51be1fe | 2020-09-22 13:25:21 +0100 | [diff] [blame] | 60 | \t\"pm\": \"$1-secondary.dts\",\n \ |
Max Shvetsov | 93119e3 | 2020-07-01 14:09:48 +0100 | [diff] [blame] | 61 | \t\"owner\": \"Plat\"\n\t},\n\n\t\"$1-tertiary\" : {\n \ |
| 62 | \t\"image\": \"$1.bin\",\n \ |
J-Alves | 31d8795 | 2022-04-04 12:34:16 +0100 | [diff] [blame] | 63 | \t\"pm\": \"$1-tertiary.dts\",\n \ |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 64 | \t\"owner\": \"Plat\"\n\t}" \ |
| 65 | >> "$GENERATED_JSON" |
| 66 | elif [ "$1" == "ivy" ]; then |
| 67 | echo -e "\t\"ivy\" : {\n \ |
Ruari Phipps | 8747ed2 | 2020-09-01 13:32:17 +0100 | [diff] [blame] | 68 | \t\"image\": \"ivy.bin\",\n \ |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 69 | \t\"pm\": \"$primary_dts\",\n \ |
| 70 | \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON" |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 71 | else |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 72 | echo -e "\nWarning: Secure Partition not supported\n" |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 73 | fi |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 74 | |
| 75 | echo -e "}" >> "$GENERATED_JSON" |