blob: 463b110e9d6b46f2a72a4c48fe108fc7a4a42b6a [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
Karl Meakine69d1282023-03-07 17:10:07 +000028for target in "$@"; do
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010029 case $target in
Karl Meakine69d1282023-03-07 17:10:07 +000030 cactus) CACTUS_PRESENT=true ;;
31 ivy) IVY_PRESENT=true ;;
32 ivy_shim) IVY_SHIM_PRESENT=true ;;
33 *) echo "Invalid target $target"; exit 1 ;;
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010034 esac
35done
36
Karl Meakine69d1282023-03-07 17:10:07 +000037echo -e "{" > "$GENERATED_JSON"
Manish Pandey270ee152020-03-16 22:25:40 +000038
39# To demonstrate communication between SP's, two cactus S-EL1 instances used.
Max Shvetsov93119e32020-07-01 14:09:48 +010040# 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 Boulbyf6c288e2022-07-25 14:07:57 +010043if [ $CACTUS_PRESENT == "true" ]; then
Karl Meakine69d1282023-03-07 17:10:07 +000044 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-Alvescd46f272024-11-25 11:18:34 +000062 "owner": "Plat",
63 "package": "tl_pkg"
Karl Meakine69d1282023-03-07 17:10:07 +000064},
65
66"cactus-tertiary" : {
67 "image": "cactus.bin",
68 "pm": "cactus-tertiary.dts",
69 "physical-load-address": "0x7200000",
J-Alvescd46f272024-11-25 11:18:34 +000070 "owner": "Plat",
Kathleen Capellae8a17a92024-12-05 18:28:29 -050071 "package": "tl_pkg",
Kathleen Capellae8a17a92024-12-05 18:28:29 -050072 "size": "0x300000"
Karl Meakine69d1282023-03-07 17:10:07 +000073EOF
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010074 PARTITION_ALREADY_PRESENT=true
75fi
Karl Meakine69d1282023-03-07 17:10:07 +000076
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010077if [ $IVY_PRESENT == "true" ]; then
78 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
Karl Meakine69d1282023-03-07 17:10:07 +000079 echo -ne "\t},\n\n" >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010080 fi
Karl Meakine69d1282023-03-07 17:10:07 +000081
82 cat >> "$GENERATED_JSON" << EOF
83"ivy" : {
84 "image": "ivy.bin",
85 "pm": "ivy-sel0.dts",
86 "physical-load-address": "0x7600000",
J-Alvescd46f272024-11-25 11:18:34 +000087 "owner": "Plat",
88 "package": "tl_pkg"
Karl Meakine69d1282023-03-07 17:10:07 +000089}
90EOF
91
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010092 PARTITION_ALREADY_PRESENT=true
93elif [ $IVY_SHIM_PRESENT == "true" ]; then
94 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
Karl Meakine69d1282023-03-07 17:10:07 +000095 echo -ne "\t},\n\n" >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010096 fi
Karl Meakine69d1282023-03-07 17:10:07 +000097cat >> "$GENERATED_JSON" << EOF
98"ivy" : {
99 "image": "ivy.bin",
100 "pm": "ivy-sel1.dts",
101 "physical-load-address": "0x7600000",
J-Alvescd46f272024-11-25 11:18:34 +0000102 "owner": "Plat",
Kathleen Capellae8a17a92024-12-05 18:28:29 -0500103 "package":"tl_pkg",
104 "size": "0x100000"
Karl Meakine69d1282023-03-07 17:10:07 +0000105}
106EOF
107
Daniel Boulbyf6c288e2022-07-25 14:07:57 +0100108 PARTITION_ALREADY_PRESENT=true
Karl Meakine69d1282023-03-07 17:10:07 +0000109else
110 echo -ne "\t},\n" >> "$GENERATED_JSON"
Manish Pandey270ee152020-03-16 22:25:40 +0000111fi
Olivier Deprez6baf5b82021-05-14 19:04:40 +0200112
Daniel Boulbyf6c288e2022-07-25 14:07:57 +0100113echo -e "\n}" >> "$GENERATED_JSON"