blob: 564c2a05dacafae5be542dc873f14943a8cdac1d [file] [log] [blame]
Antonio Nino Diaz1451f612018-11-30 10:51:26 +00001#!/bin/bash
2
3#
Olivier Deprez48e6d262020-03-13 18:04:17 +01004# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Antonio Nino Diaz1451f612018-11-30 10:51:26 +00005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8
9# Generate a DTB file from a base DTS file and the MAP file generated during the
10# compilation of a Secure Partition.
11
12# $1 = image_name (lowercase)
13# $2 = path/to/file.dts
14# $3 = build/$PLAT/$BUILD_TYPE/
15
16ORIGINAL_DTS=$2
17MAPFILE="$3/$1/$1.map"
18EXTRA_DTS="$3/$1/$1_extra.dts"
19COMBINED_DTS="$3/$1/$1_combined.dts"
20PREPROCESSED_DTS="$3/$1/$1_preprocessed.dts"
21GENERATED_DTB="$3/$1.dtb"
22
23# Look for the start and end of the sections that are only known in the elf file
24# after compiling the partition.
25
26TEXT_START=$(grep __TEXT_START__ $MAPFILE | awk {'print $1'})
27TEXT_END=$(grep __TEXT_END__ $MAPFILE | awk {'print $1'})
28
29RODATA_START=$(grep __RODATA_START__ $MAPFILE | awk {'print $1'})
30RODATA_END=$(grep __RODATA_END__ $MAPFILE | awk {'print $1'})
31
32DATA_START=$(grep __DATA_START__ $MAPFILE | awk {'print $1'})
33DATA_END=$(grep __DATA_END__ $MAPFILE | awk {'print $1'})
34
35BSS_START=$(grep __BSS_START__ $MAPFILE | awk {'print $1'})
36BSS_END=$(grep __BSS_END__ $MAPFILE | awk {'print $1'})
37
38# Inject new sections to the base DTS
39
Olivier Deprez48e6d262020-03-13 18:04:17 +010040# Memory region generation discarded
Antonio Nino Diaz1451f612018-11-30 10:51:26 +000041
Olivier Deprez48e6d262020-03-13 18:04:17 +010042cat "$ORIGINAL_DTS" > "$COMBINED_DTS"
Antonio Nino Diaz1451f612018-11-30 10:51:26 +000043
44INCLUDES="-I spm/cactus
45 -I spm/ivy
Antonio Nino Diaz26b38642019-03-28 13:16:04 +000046 -I spm/quark
Antonio Nino Diaz1451f612018-11-30 10:51:26 +000047 -I spm/include
48 -I include/lib"
49
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -060050cpp -x c -P -o "$PREPROCESSED_DTS" "$COMBINED_DTS" ${INCLUDES}
Antonio Nino Diaz1451f612018-11-30 10:51:26 +000051dtc -I dts -O dtb "$PREPROCESSED_DTS" > "$GENERATED_DTB"