blob: 1e0797b069e4663f280cbe9b790fee94ab325aae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/bash
#
# Copyright (c) 2018-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Generate a DTB file from a base DTS file and the MAP file generated during the
# compilation of a Secure Partition.
# $1 = image_name (lowercase)
# $2 = path/to/file.dts
# $3 = build/$PLAT/$BUILD_TYPE/
# $4 = path to store the dtb generated by this script
ORIGINAL_DTS=$2
MAPFILE="$3/$1/$1.map"
EXTRA_DTS="$3/$1/$1_extra.dts"
COMBINED_DTS="$3/$1/$1_combined.dts"
PREPROCESSED_DTS="$3/$1/$1_preprocessed.dts"
GENERATED_DTB=$4
# Look for the start and end of the sections that are only known in the elf file
# after compiling the partition.
TEXT_START=$(grep __TEXT_START__ $MAPFILE | awk {'print $1'})
TEXT_END=$(grep __TEXT_END__ $MAPFILE | awk {'print $1'})
RODATA_START=$(grep __RODATA_START__ $MAPFILE | awk {'print $1'})
RODATA_END=$(grep __RODATA_END__ $MAPFILE | awk {'print $1'})
DATA_START=$(grep __DATA_START__ $MAPFILE | awk {'print $1'})
DATA_END=$(grep __DATA_END__ $MAPFILE | awk {'print $1'})
BSS_START=$(grep __BSS_START__ $MAPFILE | awk {'print $1'})
BSS_END=$(grep __BSS_END__ $MAPFILE | awk {'print $1'})
# Inject new sections to the base DTS
# Memory region generation discarded
cat "$ORIGINAL_DTS" > "$COMBINED_DTS"
INCLUDES="-I spm/cactus
-I spm/ivy
-I spm/include
-I include/lib"
cpp -x c -P -o "$PREPROCESSED_DTS" "$COMBINED_DTS" ${INCLUDES}
dtc -I dts -O dtb "$PREPROCESSED_DTS" > "$GENERATED_DTB"
|