blob: 8a14517aba107b7b894c582be6549145e6e7e6e6 [file] [log] [blame]
Manish Pandey270ee152020-03-16 22:25:40 +00001#!/bin/bash
2
3#
Olivier Deprez6baf5b82021-05-14 19:04:40 +02004# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Manish Pandey270ee152020-03-16 22:25:40 +00005#
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 Deprez6baf5b82021-05-14 19:04:40 +020011# 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 Pandey270ee152020-03-16 22:25:40 +000014
Olivier Deprez6baf5b82021-05-14 19:04:40 +020015# $1 = Secure Partition
Arunachalam Ganapathy51be1fe2020-09-22 13:25:21 +010016# $2 = Platform built path
Olivier Deprez6baf5b82021-05-14 19:04:40 +020017# $3 = Ivy Shim present
Arunachalam Ganapathy51be1fe2020-09-22 13:25:21 +010018# Output = $2/sp_layout.json
Manish Pandey270ee152020-03-16 22:25:40 +000019
Arunachalam Ganapathy51be1fe2020-09-22 13:25:21 +010020GENERATED_JSON=$2/sp_layout.json
Olivier Deprez6baf5b82021-05-14 19:04:40 +020021primary_dts="$1.dts"
22
Daniel Boulbya2858262022-07-05 11:03:37 +010023if [ "$1" == "ivy" ]; then
24 if [ "$3" == "1" ]; then
25 primary_dts="ivy-sel1.dts"
26 else
27 primary_dts="ivy-sel0.dts"
28 fi
29fi
30
Olivier Deprez6baf5b82021-05-14 19:04:40 +020031# Remove closing bracket and add comma if the dts is already present.
32if [ ! -f "$GENERATED_JSON" ]; then
33 echo -e "{\n" >> "$GENERATED_JSON"
34else
Olivier Deprez6baf5b82021-05-14 19:04:40 +020035 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
42fi
Manish Pandey270ee152020-03-16 22:25:40 +000043
44# To demonstrate communication between SP's, two cactus S-EL1 instances used.
Max Shvetsov93119e32020-07-01 14:09:48 +010045# 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 Pandey270ee152020-03-16 22:25:40 +000048if [ "$1" == "cactus" ]; then
Olivier Deprez6baf5b82021-05-14 19:04:40 +020049 echo -e "\t\"$1-primary\" : {\n \
J-Alves31d87952022-04-04 12:34:16 +010050 \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 Phipps67593f22020-07-24 16:21:35 +010058 \t\"owner\": \"SiP\"\n\t},\n\n\t\"$1-secondary\" : {\n \
Manish Pandey270ee152020-03-16 22:25:40 +000059 \t\"image\": \"$1.bin\",\n \
Arunachalam Ganapathy51be1fe2020-09-22 13:25:21 +010060 \t\"pm\": \"$1-secondary.dts\",\n \
Max Shvetsov93119e32020-07-01 14:09:48 +010061 \t\"owner\": \"Plat\"\n\t},\n\n\t\"$1-tertiary\" : {\n \
62 \t\"image\": \"$1.bin\",\n \
J-Alves31d87952022-04-04 12:34:16 +010063 \t\"pm\": \"$1-tertiary.dts\",\n \
Olivier Deprez6baf5b82021-05-14 19:04:40 +020064 \t\"owner\": \"Plat\"\n\t}" \
65 >> "$GENERATED_JSON"
66elif [ "$1" == "ivy" ]; then
67 echo -e "\t\"ivy\" : {\n \
Ruari Phipps8747ed22020-09-01 13:32:17 +010068 \t\"image\": \"ivy.bin\",\n \
Olivier Deprez6baf5b82021-05-14 19:04:40 +020069 \t\"pm\": \"$primary_dts\",\n \
70 \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON"
Manish Pandey270ee152020-03-16 22:25:40 +000071else
Olivier Deprez6baf5b82021-05-14 19:04:40 +020072 echo -e "\nWarning: Secure Partition not supported\n"
Manish Pandey270ee152020-03-16 22:25:40 +000073fi
Olivier Deprez6baf5b82021-05-14 19:04:40 +020074
75echo -e "}" >> "$GENERATED_JSON"