summaryrefslogtreecommitdiff
path: root/arch/arm/mach-zynqmp/mkimage_fit_atf.sh
blob: 1e770ba111d318fa375dc6fcb141706025c99c93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0+
#
# script to generate FIT image source for Xilinx ZynqMP boards with
# ARM Trusted Firmware and multiple device trees (given on the command line)
#
# usage: $0 <dt_name> [<dt_name> [<dt_name] ...]

BL33="u-boot-nodtb.bin"
[ -z "$BL31" ] && BL31="bl31.bin"
# Can be also done as ${CROSS_COMPILE}readelf -l bl31.elf | awk '/Entry point/ { print $3 }'
[ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0xfffea000"

if [ -z "$BL33_LOAD_ADDR" ];then
	BL33_LOAD_ADDR=`awk '/CONFIG_SYS_TEXT_BASE/ { print $3 }' include/generated/autoconf.h`
fi

DTB_LOAD_ADDR=`awk '/CONFIG_XILINX_OF_BOARD_DTB_ADDR/ { print $3 }' include/generated/autoconf.h`
if [ ! -z "$DTB_LOAD_ADDR" ]; then
	DTB_LOAD="load = <$DTB_LOAD_ADDR>;"
else
	DTB_LOAD=""
fi

if [ -z "$*" ]; then
	DT=arch/arm/dts/${DEVICE_TREE}.dtb
else
	DT=$*
fi

if [ ! -f $BL31 ]; then
	echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2
	BL31=/dev/null
	# But U-Boot proper could be loaded in EL3 by specifying
	# firmware = "uboot";
	# instead of "atf" in config node
fi

cat << __HEADER_EOF
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

/dts-v1/;

/ {
	description = "Configuration to load ATF before U-Boot";

	images {
		uboot {
			description = "U-Boot (64-bit)";
			data = /incbin/("$BL33");
			type = "firmware";
			os = "u-boot";
			arch = "arm64";
			compression = "none";
			load = <$BL33_LOAD_ADDR>;
			entry = <$BL33_LOAD_ADDR>;
			hash {
				algo = "md5";
			};
		};
		atf {
			description = "ARM Trusted Firmware";
			data = /incbin/("$BL31");
			type = "firmware";
			os = "arm-trusted-firmware";
			arch = "arm64";
			compression = "none";
			load = <$ATF_LOAD_ADDR>;
			entry = <$ATF_LOAD_ADDR>;
			hash {
				algo = "md5";
			};
		};
__HEADER_EOF

DEFAULT=1
cnt=1
for dtname in $DT
do
	cat << __FDT_IMAGE_EOF
		fdt_$cnt {
			description = "$(basename $dtname .dtb)";
			data = /incbin/("$dtname");
			type = "flat_dt";
			arch = "arm64";
			compression = "none";
			$DTB_LOAD
			hash {
				algo = "md5";
			};
		};
__FDT_IMAGE_EOF

[ "x$(basename $dtname .dtb)" = "x${DEVICE_TREE}" ] && DEFAULT=$cnt

cnt=$((cnt+1))
done

cat << __CONF_HEADER_EOF
	};
	configurations {
		default = "config_$DEFAULT";

__CONF_HEADER_EOF

cnt=1
for dtname in $DT
do
cat << __CONF_SECTION1_EOF
		config_$cnt {
			description = "$(basename $dtname .dtb)";
			firmware = "atf";
			loadables = "uboot";
			fdt = "fdt_$cnt";
		};
__CONF_SECTION1_EOF
cnt=$((cnt+1))
done

cat << __ITS_EOF
	};
};
__ITS_EOF