blob: 30ee90b6d2525452d85d5cc66f64ce839f492b8e [file] [log] [blame]
johpow0173007872020-07-15 20:01:05 -05001#
2# Copyright (c) 2020, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7LINUX_SOURCE=$1
8TFA_SOURCE=$2
9DTS_LINUX64_JUNO_R1="$LINUX_SOURCE/arch/arm64/boot/dts/arm/juno-r1.dts"
10DTS_LINUX64_SUN50I_A64_PINE64_PLUS="$LINUX_SOURCE/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts"
11DTS_LINUX32_ATLAS7_EVB="$LINUX_SOURCE/arch/arm/boot/dts/atlas7-evb.dts"
12DTS_LINUX32_BCM2837_RPI_3_B_PLUS="$LINUX_SOURCE/arch/arm/boot/dts/bcm2837-rpi-3-b-plus.dts"
13DTS_TEST="test.dts"
14DTS_FVP_BASE_GICV3_PSCI="$TFA_SOURCE/fdts/fvp-base-gicv3-psci.dts"
15
16process_linux_dts()
17{
18 # DTS file path in first argument
19 # DTB file in 2nd argument
20 # Use global LINUX_SOURCE
21 DTS_FILE=$1
22 DTB_FILE=$2
23
24 cpp -I $LINUX_SOURCE/include -x assembler-with-cpp -o $DTS_FILE.preprocessed $DTS_FILE
25 sed -i -e '/stdc-predef.h/d' $DTS_FILE.preprocessed -e 's/1,pci-domain/linux,pci-domain/g' $DTS_FILE.preprocessed
26 dtc -O dtb -o $DTB_FILE -i $DTS_FILE -b 0 $DTS_FILE.preprocessed
27 rm $DTS_FILE.preprocessed
28}
29
30process_tfa_dts()
31{
32 # DTS file path in first argument
33 # DTB file in 2nd argument
34 DTS_FILE=$1
35 DTB_FILE=$2
36 cpp -I $TFA_SOURCE/include -x assembler-with-cpp -o $DTS_FILE.preprocessed $DTS_FILE
37 sed -i -e '/stdc-predef.h/d' $DTS_FILE.preprocessed -e 's/1,pci-domain/linux,pci-domain/g' $DTS_FILE.preprocessed
38 dtc -O dtb -o $DTB_FILE -i $DTS_FILE -b 0 $DTS_FILE.preprocessed
39 rm $DTS_FILE.preprocessed
40}
41
42process_dts()
43{
44 # DTS file path in first argument
45 # DTB file in 2nd argument
46 DTS_FILE=$1
47 DTB_FILE=$2
48 dtc -o $DTB_FILE $DTS_FILE
49}
50
51# basic argument checks
52if [[ ( "$1" == "-h" ) || ( "$1" == "--help" ) ]]; then
53 echo "Usage: $0 [OPTION] path/to/linux/source path/to/tfa/source"
54 echo ""
55 echo " This script will build the necessary DTB files from their"
56 echo " sources in the Linux kernel and TFA repositories. Provide the"
57 echo " path to the Linux source tree as the first argument to this"
58 echo " script and the path to the TFA source tree as the second"
59 echo " argument."
60 echo ""
61 echo " -h, --help print this help text"
62 exit 0
63fi
64if [[ ( -z "$1" ) || ( -z "$2" ) ]]; then
65 echo "Invalid arguments, use -h/--help for more info."
66 exit 1
67fi
68
69# create a folder for new DTB files to be placed in
70mkdir dtb
71
72# generate linux DTB files
73process_linux_dts $DTS_LINUX64_JUNO_R1 dtb/juno-r1.dtb
74process_linux_dts $DTS_LINUX64_SUN50I_A64_PINE64_PLUS dtb/sun50i-a64-pine64-plus.dtb
75process_linux_dts $DTS_LINUX32_ATLAS7_EVB dtb/atlas7-evb.dtb
76process_linux_dts $DTS_LINUX32_BCM2837_RPI_3_B_PLUS dtb/bcm2837-rpi-3-b-plus.dtb
77
78# generate TFA DTB file
79process_tfa_dts $DTS_FVP_BASE_GICV3_PSCI dtb/fvp-base-gicv3-psci.dtb
80
81# generate test DTB file
82process_dts $DTS_TEST dtb/test.dtb