Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame^] | 4 | # Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 5 | # |
| 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/ |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame^] | 15 | # $4 = path to store the dtb generated by this script |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 16 | |
| 17 | ORIGINAL_DTS=$2 |
| 18 | MAPFILE="$3/$1/$1.map" |
| 19 | EXTRA_DTS="$3/$1/$1_extra.dts" |
| 20 | COMBINED_DTS="$3/$1/$1_combined.dts" |
| 21 | PREPROCESSED_DTS="$3/$1/$1_preprocessed.dts" |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame^] | 22 | GENERATED_DTB=$4 |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 23 | |
| 24 | # Look for the start and end of the sections that are only known in the elf file |
| 25 | # after compiling the partition. |
| 26 | |
| 27 | TEXT_START=$(grep __TEXT_START__ $MAPFILE | awk {'print $1'}) |
| 28 | TEXT_END=$(grep __TEXT_END__ $MAPFILE | awk {'print $1'}) |
| 29 | |
| 30 | RODATA_START=$(grep __RODATA_START__ $MAPFILE | awk {'print $1'}) |
| 31 | RODATA_END=$(grep __RODATA_END__ $MAPFILE | awk {'print $1'}) |
| 32 | |
| 33 | DATA_START=$(grep __DATA_START__ $MAPFILE | awk {'print $1'}) |
| 34 | DATA_END=$(grep __DATA_END__ $MAPFILE | awk {'print $1'}) |
| 35 | |
| 36 | BSS_START=$(grep __BSS_START__ $MAPFILE | awk {'print $1'}) |
| 37 | BSS_END=$(grep __BSS_END__ $MAPFILE | awk {'print $1'}) |
| 38 | |
| 39 | # Inject new sections to the base DTS |
| 40 | |
Olivier Deprez | 48e6d26 | 2020-03-13 18:04:17 +0100 | [diff] [blame] | 41 | # Memory region generation discarded |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 42 | |
Olivier Deprez | 48e6d26 | 2020-03-13 18:04:17 +0100 | [diff] [blame] | 43 | cat "$ORIGINAL_DTS" > "$COMBINED_DTS" |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 44 | |
| 45 | INCLUDES="-I spm/cactus |
| 46 | -I spm/ivy |
Antonio Nino Diaz | 26b3864 | 2019-03-28 13:16:04 +0000 | [diff] [blame] | 47 | -I spm/quark |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 48 | -I spm/include |
| 49 | -I include/lib" |
| 50 | |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 51 | cpp -x c -P -o "$PREPROCESSED_DTS" "$COMBINED_DTS" ${INCLUDES} |
Antonio Nino Diaz | 1451f61 | 2018-11-30 10:51:26 +0000 | [diff] [blame] | 52 | dtc -I dts -O dtb "$PREPROCESSED_DTS" > "$GENERATED_DTB" |