blob: 92e31849f88d3bb593178de035826df6a8634a16 [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"
11# Can be also done as ${CROSS_COMPILE}readelf -l bl31.elf | awk '/Entry point/ { print $3 }'
12[ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0xfffea000"
13
14if [ -z "$BL33_LOAD_ADDR" ];then
15 BL33_LOAD_ADDR=`awk '/CONFIG_SYS_TEXT_BASE/ { print $3 }' include/generated/autoconf.h`
16fi
17
18DTB_LOAD_ADDR=`awk '/CONFIG_XILINX_OF_BOARD_DTB_ADDR/ { print $3 }' include/generated/autoconf.h`
19if [ ! -z "$DTB_LOAD_ADDR" ]; then
20 DTB_LOAD="load = <$DTB_LOAD_ADDR>;"
21else
22 DTB_LOAD=""
23fi
24
25if [ -z "$*" ]; then
26 DT=arch/arm/dts/${DEVICE_TREE}.dtb
27else
28 DT=$*
29fi
30
31if [ ! -f $BL31 ]; then
Michal Simekcf73de12020-03-23 14:40:52 +010032 echo "WARNING: BL31 file $BL31 NOT found, U-Boot will run in EL3" >&2
Michal Simeka7178b72019-10-02 15:55:57 +020033 BL31=/dev/null
Michal Simeka7178b72019-10-02 15:55:57 +020034fi
35
36cat << __HEADER_EOF
37// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
38
39/dts-v1/;
40
41/ {
42 description = "Configuration to load ATF before U-Boot";
43
44 images {
45 uboot {
46 description = "U-Boot (64-bit)";
47 data = /incbin/("$BL33");
48 type = "firmware";
49 os = "u-boot";
50 arch = "arm64";
51 compression = "none";
52 load = <$BL33_LOAD_ADDR>;
53 entry = <$BL33_LOAD_ADDR>;
54 hash {
55 algo = "md5";
56 };
57 };
Michal Simekcf73de12020-03-23 14:40:52 +010058__HEADER_EOF
59
60if [ -f $BL31 ]; then
61cat << __ATF
Michal Simeka7178b72019-10-02 15:55:57 +020062 atf {
63 description = "ARM Trusted Firmware";
64 data = /incbin/("$BL31");
65 type = "firmware";
66 os = "arm-trusted-firmware";
67 arch = "arm64";
68 compression = "none";
69 load = <$ATF_LOAD_ADDR>;
70 entry = <$ATF_LOAD_ADDR>;
71 hash {
72 algo = "md5";
73 };
74 };
Michal Simekcf73de12020-03-23 14:40:52 +010075__ATF
76fi
Michal Simeka7178b72019-10-02 15:55:57 +020077
78DEFAULT=1
79cnt=1
80for dtname in $DT
81do
82 cat << __FDT_IMAGE_EOF
83 fdt_$cnt {
84 description = "$(basename $dtname .dtb)";
85 data = /incbin/("$dtname");
86 type = "flat_dt";
87 arch = "arm64";
88 compression = "none";
89 $DTB_LOAD
90 hash {
91 algo = "md5";
92 };
93 };
94__FDT_IMAGE_EOF
95
96[ "x$(basename $dtname .dtb)" = "x${DEVICE_TREE}" ] && DEFAULT=$cnt
97
98cnt=$((cnt+1))
99done
100
101cat << __CONF_HEADER_EOF
102 };
103 configurations {
104 default = "config_$DEFAULT";
105
106__CONF_HEADER_EOF
107
108cnt=1
109for dtname in $DT
110do
Michal Simekcf73de12020-03-23 14:40:52 +0100111if [ ! -f $BL31 ]; then
112cat << __CONF_SECTION1_EOF
113 config_$cnt {
114 description = "$(basename $dtname .dtb)";
115 firmware = "uboot";
116 fdt = "fdt_$cnt";
117 };
118__CONF_SECTION1_EOF
119else
Michal Simeka7178b72019-10-02 15:55:57 +0200120cat << __CONF_SECTION1_EOF
121 config_$cnt {
122 description = "$(basename $dtname .dtb)";
123 firmware = "atf";
124 loadables = "uboot";
125 fdt = "fdt_$cnt";
126 };
127__CONF_SECTION1_EOF
Michal Simekcf73de12020-03-23 14:40:52 +0100128fi
129
Michal Simeka7178b72019-10-02 15:55:57 +0200130cnt=$((cnt+1))
131done
132
133cat << __ITS_EOF
134 };
135};
136__ITS_EOF