blob: 72a8a3eb771490246f41453e00e604f615fefd64 [file] [log] [blame]
Michal Simeka7178b72019-10-02 15:55:57 +02001#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0+
3#
4# script to generate FIT image source for Xilinx ZynqMP boards with
5# ARM Trusted Firmware and multiple device trees (given on the command line)
6#
7# usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
8
9BL33="u-boot-nodtb.bin"
10[ -z "$BL31" ] && BL31="bl31.bin"
Michal Simekf0887502021-05-31 11:13:45 +020011BL31_ELF="${BL31%.*}.elf"
12[ -f ${BL31_ELF} ] && ATF_LOAD_ADDR=`${CROSS_COMPILE}readelf -l "${BL31_ELF}" | \
13awk '/Entry point/ { print $3 }'`
14
Michal Simeka7178b72019-10-02 15:55:57 +020015[ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0xfffea000"
Michal Simek48bd9ba2021-06-07 12:37:32 +020016ATF_LOAD_ADDR_LOW=`printf 0x%x $((ATF_LOAD_ADDR & 0xffffffff))`
17ATF_LOAD_ADDR_HIGH=`printf 0x%x $((ATF_LOAD_ADDR >> 32))`
Michal Simeka7178b72019-10-02 15:55:57 +020018
Michal Simekf0887502021-05-31 11:13:45 +020019[ -z "$BL32" ] && BL32="tee.bin"
20BL32_ELF="${BL32%.*}.elf"
21[ -f ${BL32_ELF} ] && TEE_LOAD_ADDR=`${CROSS_COMPILE}readelf -l "${BL32_ELF}" | \
22awk '/Entry point/ { print $3 }'`
23
24[ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0x60000000"
Michal Simek48bd9ba2021-06-07 12:37:32 +020025TEE_LOAD_ADDR_LOW=`printf 0x%x $((TEE_LOAD_ADDR & 0xffffffff))`
26TEE_LOAD_ADDR_HIGH=`printf 0x%x $((TEE_LOAD_ADDR >> 32))`
Michal Simekf0887502021-05-31 11:13:45 +020027
Michal Simeka7178b72019-10-02 15:55:57 +020028if [ -z "$BL33_LOAD_ADDR" ];then
29 BL33_LOAD_ADDR=`awk '/CONFIG_SYS_TEXT_BASE/ { print $3 }' include/generated/autoconf.h`
30fi
Michal Simek48bd9ba2021-06-07 12:37:32 +020031BL33_LOAD_ADDR_LOW=`printf 0x%x $((BL33_LOAD_ADDR & 0xffffffff))`
32BL33_LOAD_ADDR_HIGH=`printf 0x%x $((BL33_LOAD_ADDR >> 32))`
Michal Simeka7178b72019-10-02 15:55:57 +020033
34DTB_LOAD_ADDR=`awk '/CONFIG_XILINX_OF_BOARD_DTB_ADDR/ { print $3 }' include/generated/autoconf.h`
35if [ ! -z "$DTB_LOAD_ADDR" ]; then
Michal Simek48bd9ba2021-06-07 12:37:32 +020036 DTB_LOAD_ADDR_LOW=`printf 0x%x $((DTB_LOAD_ADDR & 0xffffffff))`
37 DTB_LOAD_ADDR_HIGH=`printf 0x%x $((DTB_LOAD_ADDR >> 32))`
38 DTB_LOAD="load = <$DTB_LOAD_ADDR_HIGH $DTB_LOAD_ADDR_LOW>;"
Michal Simeka7178b72019-10-02 15:55:57 +020039else
40 DTB_LOAD=""
41fi
42
43if [ -z "$*" ]; then
44 DT=arch/arm/dts/${DEVICE_TREE}.dtb
45else
46 DT=$*
47fi
48
49if [ ! -f $BL31 ]; then
Michal Simekcf73de12020-03-23 14:40:52 +010050 echo "WARNING: BL31 file $BL31 NOT found, U-Boot will run in EL3" >&2
Michal Simeka7178b72019-10-02 15:55:57 +020051 BL31=/dev/null
Michal Simeka7178b72019-10-02 15:55:57 +020052fi
53
54cat << __HEADER_EOF
55// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
56
57/dts-v1/;
58
59/ {
Michal Simek367eb802021-08-19 14:17:37 +020060 description = "Configuration for Xilinx ZynqMP SoC";
Michal Simeka7178b72019-10-02 15:55:57 +020061
62 images {
63 uboot {
64 description = "U-Boot (64-bit)";
65 data = /incbin/("$BL33");
66 type = "firmware";
67 os = "u-boot";
68 arch = "arm64";
69 compression = "none";
Michal Simek48bd9ba2021-06-07 12:37:32 +020070 load = <$BL33_LOAD_ADDR_HIGH $BL33_LOAD_ADDR_LOW>;
71 entry = <$BL33_LOAD_ADDR_HIGH $BL33_LOAD_ADDR_LOW>;
Michal Simeka7178b72019-10-02 15:55:57 +020072 hash {
73 algo = "md5";
74 };
75 };
Michal Simekcf73de12020-03-23 14:40:52 +010076__HEADER_EOF
77
78if [ -f $BL31 ]; then
79cat << __ATF
Michal Simeka7178b72019-10-02 15:55:57 +020080 atf {
Michal Simek367eb802021-08-19 14:17:37 +020081 description = "Trusted Firmware-A";
Michal Simeka7178b72019-10-02 15:55:57 +020082 data = /incbin/("$BL31");
83 type = "firmware";
84 os = "arm-trusted-firmware";
85 arch = "arm64";
86 compression = "none";
Michal Simek48bd9ba2021-06-07 12:37:32 +020087 load = <$ATF_LOAD_ADDR_HIGH $ATF_LOAD_ADDR_LOW>;
88 entry = <$ATF_LOAD_ADDR_HIGH $ATF_LOAD_ADDR_LOW>;
Michal Simeka7178b72019-10-02 15:55:57 +020089 hash {
90 algo = "md5";
91 };
92 };
Michal Simekcf73de12020-03-23 14:40:52 +010093__ATF
94fi
Michal Simeka7178b72019-10-02 15:55:57 +020095
Michal Simekf0887502021-05-31 11:13:45 +020096if [ -f $BL32 ]; then
97cat << __TEE
98 tee {
99 description = "TEE firmware";
100 data = /incbin/("$BL32");
101 type = "firmware";
102 os = "tee";
103 arch = "arm64";
104 compression = "none";
Michal Simek48bd9ba2021-06-07 12:37:32 +0200105 load = <$TEE_LOAD_ADDR_HIGH $TEE_LOAD_ADDR_LOW>;
106 entry = <$TEE_LOAD_ADDR_HIGH $TEE_LOAD_ADDR_LOW>;
Michal Simekf0887502021-05-31 11:13:45 +0200107 hash {
108 algo = "md5";
109 };
110 };
111__TEE
112fi
113
Michal Simek3c99ab52021-08-19 12:02:57 +0200114MULTI_DTB=`awk '/CONFIG_MULTI_DTB_FIT / { print $3 }' include/generated/autoconf.h`
115
116if [ 1"$MULTI_DTB" -eq 11 ]; then
117 cat << __FDT_IMAGE_EOF
118 fdt_1 {
119 description = "Multi DTB fit image";
120 data = /incbin/("fit-dtb.blob");
121 type = "flat_dt";
122 arch = "arm64";
123 compression = "none";
124 $DTB_LOAD
125 hash {
126 algo = "md5";
127 };
128 };
129 };
130 configurations {
131 default = "config_1";
132__FDT_IMAGE_EOF
133
134if [ ! -f $BL31 ]; then
135cat << __CONF_SECTION1_EOF
136 config_1 {
137 description = "Multi DTB without TF-A";
138 firmware = "uboot";
139 loadables = "fdt_1";
140 };
141__CONF_SECTION1_EOF
142else
143cat << __CONF_SECTION1_EOF
144 config_1 {
145 description = "Multi DTB with TF-A";
146 firmware = "atf";
147 loadables = "uboot", "fdt_1";
148 };
149__CONF_SECTION1_EOF
150fi
151
152cat << __ITS_EOF
153 };
154};
155__ITS_EOF
156
157else
158
Michal Simeka7178b72019-10-02 15:55:57 +0200159DEFAULT=1
160cnt=1
161for dtname in $DT
162do
163 cat << __FDT_IMAGE_EOF
164 fdt_$cnt {
165 description = "$(basename $dtname .dtb)";
166 data = /incbin/("$dtname");
167 type = "flat_dt";
168 arch = "arm64";
169 compression = "none";
170 $DTB_LOAD
171 hash {
172 algo = "md5";
173 };
174 };
175__FDT_IMAGE_EOF
176
177[ "x$(basename $dtname .dtb)" = "x${DEVICE_TREE}" ] && DEFAULT=$cnt
178
179cnt=$((cnt+1))
180done
181
182cat << __CONF_HEADER_EOF
183 };
184 configurations {
185 default = "config_$DEFAULT";
186
187__CONF_HEADER_EOF
188
189cnt=1
190for dtname in $DT
191do
Michal Simekcf73de12020-03-23 14:40:52 +0100192if [ ! -f $BL31 ]; then
193cat << __CONF_SECTION1_EOF
194 config_$cnt {
195 description = "$(basename $dtname .dtb)";
196 firmware = "uboot";
197 fdt = "fdt_$cnt";
198 };
199__CONF_SECTION1_EOF
200else
Michal Simekf0887502021-05-31 11:13:45 +0200201if [ -f $BL32 ]; then
202cat << __CONF_SECTION1_EOF
203 config_$cnt {
204 description = "$(basename $dtname .dtb)";
205 firmware = "atf";
206 loadables = "uboot", "tee";
207 fdt = "fdt_$cnt";
208 };
209__CONF_SECTION1_EOF
210else
Michal Simeka7178b72019-10-02 15:55:57 +0200211cat << __CONF_SECTION1_EOF
212 config_$cnt {
213 description = "$(basename $dtname .dtb)";
214 firmware = "atf";
215 loadables = "uboot";
216 fdt = "fdt_$cnt";
217 };
218__CONF_SECTION1_EOF
Michal Simekcf73de12020-03-23 14:40:52 +0100219fi
Michal Simekf0887502021-05-31 11:13:45 +0200220fi
Michal Simekcf73de12020-03-23 14:40:52 +0100221
Michal Simeka7178b72019-10-02 15:55:57 +0200222cnt=$((cnt+1))
223done
224
225cat << __ITS_EOF
226 };
227};
228__ITS_EOF
Michal Simek3c99ab52021-08-19 12:02:57 +0200229
230fi