blob: 9d51ba550531c3f69e7cd657a5a7e0fb4709dab1 [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",
71 "package": "tl_pkg"
Karl Meakine69d1282023-03-07 17:10:07 +000072EOF
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010073 PARTITION_ALREADY_PRESENT=true
74fi
Karl Meakine69d1282023-03-07 17:10:07 +000075
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010076if [ $IVY_PRESENT == "true" ]; then
77 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
Karl Meakine69d1282023-03-07 17:10:07 +000078 echo -ne "\t},\n\n" >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010079 fi
Karl Meakine69d1282023-03-07 17:10:07 +000080
81 cat >> "$GENERATED_JSON" << EOF
82"ivy" : {
83 "image": "ivy.bin",
84 "pm": "ivy-sel0.dts",
85 "physical-load-address": "0x7600000",
J-Alvescd46f272024-11-25 11:18:34 +000086 "owner": "Plat",
87 "package": "tl_pkg"
Karl Meakine69d1282023-03-07 17:10:07 +000088}
89EOF
90
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010091 PARTITION_ALREADY_PRESENT=true
92elif [ $IVY_SHIM_PRESENT == "true" ]; then
93 if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
Karl Meakine69d1282023-03-07 17:10:07 +000094 echo -ne "\t},\n\n" >> "$GENERATED_JSON"
Daniel Boulbyf6c288e2022-07-25 14:07:57 +010095 fi
Karl Meakine69d1282023-03-07 17:10:07 +000096cat >> "$GENERATED_JSON" << EOF
97"ivy" : {
98 "image": "ivy.bin",
99 "pm": "ivy-sel1.dts",
100 "physical-load-address": "0x7600000",
J-Alvescd46f272024-11-25 11:18:34 +0000101 "owner": "Plat",
102 "package":"tl_pkg"
Karl Meakine69d1282023-03-07 17:10:07 +0000103}
104EOF
105
Daniel Boulbyf6c288e2022-07-25 14:07:57 +0100106 PARTITION_ALREADY_PRESENT=true
Karl Meakine69d1282023-03-07 17:10:07 +0000107else
108 echo -ne "\t},\n" >> "$GENERATED_JSON"
Manish Pandey270ee152020-03-16 22:25:40 +0000109fi
Olivier Deprez6baf5b82021-05-14 19:04:40 +0200110
Daniel Boulbyf6c288e2022-07-25 14:07:57 +0100111echo -e "\n}" >> "$GENERATED_JSON"