blob: 1e770ba111d318fa375dc6fcb141706025c99c93 [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
32 echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2
33 BL31=/dev/null
34 # But U-Boot proper could be loaded in EL3 by specifying
35 # firmware = "uboot";
36 # instead of "atf" in config node
37fi
38
39cat << __HEADER_EOF
40// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
41
42/dts-v1/;
43
44/ {
45 description = "Configuration to load ATF before U-Boot";
46
47 images {
48 uboot {
49 description = "U-Boot (64-bit)";
50 data = /incbin/("$BL33");
51 type = "firmware";
52 os = "u-boot";
53 arch = "arm64";
54 compression = "none";
55 load = <$BL33_LOAD_ADDR>;
56 entry = <$BL33_LOAD_ADDR>;
57 hash {
58 algo = "md5";
59 };
60 };
61 atf {
62 description = "ARM Trusted Firmware";
63 data = /incbin/("$BL31");
64 type = "firmware";
65 os = "arm-trusted-firmware";
66 arch = "arm64";
67 compression = "none";
68 load = <$ATF_LOAD_ADDR>;
69 entry = <$ATF_LOAD_ADDR>;
70 hash {
71 algo = "md5";
72 };
73 };
74__HEADER_EOF
75
76DEFAULT=1
77cnt=1
78for dtname in $DT
79do
80 cat << __FDT_IMAGE_EOF
81 fdt_$cnt {
82 description = "$(basename $dtname .dtb)";
83 data = /incbin/("$dtname");
84 type = "flat_dt";
85 arch = "arm64";
86 compression = "none";
87 $DTB_LOAD
88 hash {
89 algo = "md5";
90 };
91 };
92__FDT_IMAGE_EOF
93
94[ "x$(basename $dtname .dtb)" = "x${DEVICE_TREE}" ] && DEFAULT=$cnt
95
96cnt=$((cnt+1))
97done
98
99cat << __CONF_HEADER_EOF
100 };
101 configurations {
102 default = "config_$DEFAULT";
103
104__CONF_HEADER_EOF
105
106cnt=1
107for dtname in $DT
108do
109cat << __CONF_SECTION1_EOF
110 config_$cnt {
111 description = "$(basename $dtname .dtb)";
112 firmware = "atf";
113 loadables = "uboot";
114 fdt = "fdt_$cnt";
115 };
116__CONF_SECTION1_EOF
117cnt=$((cnt+1))
118done
119
120cat << __ITS_EOF
121 };
122};
123__ITS_EOF