sunxi: Silence warning about non-static inline function
[oweals/u-boot.git] / arch / arm / mach-zynqmp / mkimage_fit_atf.sh
1 #!/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
9 BL33="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
14 if [ -z "$BL33_LOAD_ADDR" ];then
15         BL33_LOAD_ADDR=`awk '/CONFIG_SYS_TEXT_BASE/ { print $3 }' include/generated/autoconf.h`
16 fi
17
18 DTB_LOAD_ADDR=`awk '/CONFIG_XILINX_OF_BOARD_DTB_ADDR/ { print $3 }' include/generated/autoconf.h`
19 if [ ! -z "$DTB_LOAD_ADDR" ]; then
20         DTB_LOAD="load = <$DTB_LOAD_ADDR>;"
21 else
22         DTB_LOAD=""
23 fi
24
25 if [ -z "$*" ]; then
26         DT=arch/arm/dts/${DEVICE_TREE}.dtb
27 else
28         DT=$*
29 fi
30
31 if [ ! -f $BL31 ]; then
32         echo "WARNING: BL31 file $BL31 NOT found, U-Boot will run in EL3" >&2
33         BL31=/dev/null
34 fi
35
36 cat << __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                 };
58 __HEADER_EOF
59
60 if [ -f $BL31 ]; then
61 cat << __ATF
62                 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                 };
75 __ATF
76 fi
77
78 DEFAULT=1
79 cnt=1
80 for dtname in $DT
81 do
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
98 cnt=$((cnt+1))
99 done
100
101 cat << __CONF_HEADER_EOF
102         };
103         configurations {
104                 default = "config_$DEFAULT";
105
106 __CONF_HEADER_EOF
107
108 cnt=1
109 for dtname in $DT
110 do
111 if [ ! -f $BL31 ]; then
112 cat << __CONF_SECTION1_EOF
113                 config_$cnt {
114                         description = "$(basename $dtname .dtb)";
115                         firmware = "uboot";
116                         fdt = "fdt_$cnt";
117                 };
118 __CONF_SECTION1_EOF
119 else
120 cat << __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
128 fi
129
130 cnt=$((cnt+1))
131 done
132
133 cat << __ITS_EOF
134         };
135 };
136 __ITS_EOF