blob: 9ac13ecdbcfda2ae243d7ab43abd2235bf8cb155 [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
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010015# $1 = Platform built path
16# $2.. = List of Secure Partitions
17# Output = $1/sp_layout.json
Manish Pandey270ee152020-03-16 22:25:40 +000018
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010019GENERATED_JSON=$1/sp_layout.json
20shift # Shift arguments 1
Olivier Deprez6baf5b82021-05-14 19:04:40 +020021
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010022PARTITION_ALREADY_PRESENT=false
Daniel Boulbya2858262022-07-05 11:03:37 +010023
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010024CACTUS_PRESENT=false
25IVY_PRESENT=false
26IVY_SHIM_PRESENT=false
27
28for target in "$@"
29do
30 case $target in
31 cactus)
32 CACTUS_PRESENT=true
33 ;;
34 ivy)
35 IVY_PRESENT=true
36 ;;
37 ivy_shim)
38 IVY_SHIM_PRESENT=true
39 ;;
40 *)
41 echo "Invalid target $target"
42 exit 1
43 ;;
44 esac
45done
46
47echo -e "{" > $GENERATED_JSON
Manish Pandey270ee152020-03-16 22:25:40 +000048
49# To demonstrate communication between SP's, two cactus S-EL1 instances used.
Max Shvetsov93119e32020-07-01 14:09:48 +010050# To also test mapping of the RXTX region a third cactus S-EL1 instance is used.
51# cactus-primary, cactus-secondary and cactus-tertiary have same binary but
52# different partition manifests.
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010053if [ $CACTUS_PRESENT == "true" ]; then
54 echo -ne "\t\"cactus-primary\" : {\n \
J-Alves31d87952022-04-04 12:34:16 +010055 \t\"image\": {\n \
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010056 \t\t\"file\": \"cactus.bin\",\n \
J-Alves31d87952022-04-04 12:34:16 +010057 \t\t\"offset\":\"0x2000\"\n\
58 \t},\n \
59 \t\"pm\": {\n \
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010060 \t\t\"file\": \"cactus.dts\",\n \
J-Alves31d87952022-04-04 12:34:16 +010061 \t\t\"offset\":\"0x1000\"\n\
62 \t},\n
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010063 \t\"owner\": \"SiP\"\n\t},\n\n\t\"cactus-secondary\" : {\n \
64 \t\"image\": \"cactus.bin\",\n \
65 \t\"pm\": \"cactus-secondary.dts\",\n \
66 \t\"owner\": \"Plat\"\n\t},\n\n\t\"cactus-tertiary\" : {\n \
67 \t\"image\": \"cactus.bin\",\n \
68 \t\"pm\": \"cactus-tertiary.dts\",\n \
Olivier Deprez6baf5b82021-05-14 19:04:40 +020069 \t\"owner\": \"Plat\"\n\t}" \
70 >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010071 PARTITION_ALREADY_PRESENT=true
72fi
73if [ $IVY_PRESENT == "true" ]; then
74 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
75 echo -ne ",\n\n" >> $GENERATED_JSON
76 fi
77 echo -ne "\t\"ivy\" : {\n \
Ruari Phipps8747ed22020-09-01 13:32:17 +010078 \t\"image\": \"ivy.bin\",\n \
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010079 \t\"pm\": \"ivy-sel0.dts\",\n \
Olivier Deprez6baf5b82021-05-14 19:04:40 +020080 \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010081 PARTITION_ALREADY_PRESENT=true
82elif [ $IVY_SHIM_PRESENT == "true" ]; then
83 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
84 echo -ne ",\n\n" >> $GENERATED_JSON
85 fi
Daniel Boulby427be2a2022-08-01 10:57:37 +010086 echo -ne "\t\"ivy\" : {\n \
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010087 \t\"image\": \"ivy.bin\",\n \
88 \t\"pm\": \"ivy-sel1.dts\",\n \
89 \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON"
90 PARTITION_ALREADY_PRESENT=true
Manish Pandey270ee152020-03-16 22:25:40 +000091fi
Olivier Deprez6baf5b82021-05-14 19:04:40 +020092
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010093echo -e "\n}" >> "$GENERATED_JSON"