aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-11-30 10:51:26 +0000
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-12-12 13:28:05 +0000
commit1451f6142c9d03af844d0bc77dace24eca5ff81f (patch)
tree96c7720a3a83f26a341e61662d37ce9dd2ed1c28 /tools
parent855b0b22d0e87441a06e227d7970774c491447e7 (diff)
downloadtf-a-tests-1451f6142c9d03af844d0bc77dace24eca5ff81f.tar.gz
SPM: Makefile: Add targets to build resource description blobs
The targets cactus and ivy now also build the resource description blobs used by Cactus and Ivy. This is done through a new shell script: generate_dtb.sh Example command line to build a package with Cactus and Ivy: CROSS_COMPILE=aarch64-linux-gnu- make PLAT=fvp \ DEBUG=1 LOG_LEVEL=50 TESTS=spm \ tftf cactus ivy trusted_firmware/tools/sptool/sptool \ -o sp_package.bin \ -i cactus.bin:cactus.dtb \ -i ivy.bin:ivy.dtb Also, add a disclaimer to explain that the current implementation of SPM is a prototype that is going to undergo a lot of rework. Change-Id: Iebc3ac28d20019b59f07f70f96fefc030f1a79ce Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/generate_dtb/generate_dtb.sh78
1 files changed, 78 insertions, 0 deletions
diff --git a/tools/generate_dtb/generate_dtb.sh b/tools/generate_dtb/generate_dtb.sh
new file mode 100755
index 000000000..efcc67edd
--- /dev/null
+++ b/tools/generate_dtb/generate_dtb.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2018, 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/
+
+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="$3/$1.dtb"
+
+# 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
+
+echo "\
+/ {
+ memory_regions {
+ text {
+ str = \"Text\";
+ base = <0x0 ${TEXT_START}ULL>;
+ size = <0x0 (${TEXT_END}ULL - ${TEXT_START}ULL)>;
+ attr = <RD_MEM_NORMAL_CODE>;
+ };
+ rodata {
+ str = \"RO Data\";
+ base = <0x0 (${RODATA_START}ULL)>;
+ size = <0x0 (${RODATA_END}ULL - ${RODATA_START}ULL)>;
+ attr = <RD_MEM_NORMAL_RODATA>;
+ };
+ rwdata {
+ str = \"Data\";
+ base = <0x0 ${DATA_START}ULL>;
+ size = <0x0 (${DATA_END}ULL - ${DATA_START}ULL)>;
+ attr = <RD_MEM_NORMAL_DATA>;
+ };
+ bss {
+ str = \"BSS\";
+ base = <0x0 ${BSS_START}ULL>;
+ size = <0x0 (${BSS_END}ULL - ${BSS_START}ULL)>;
+ attr = <RD_MEM_NORMAL_BSS>;
+ };
+ };
+};" > "$EXTRA_DTS"
+
+cat "$ORIGINAL_DTS" "$EXTRA_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} -DAARCH64
+dtc -I dts -O dtb "$PREPROCESSED_DTS" > "$GENERATED_DTB"