blob: 77f7143263fd8b42e5052927fe972225d043bf94 [file] [log] [blame]
Peng Fan128e3422018-11-20 10:19:39 +00001#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0+
3#
4# script to generate FIT image source for i.MX8MQ 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[ -z "$BL31" ] && BL31="bl31.bin"
10[ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0xfe000000"
11[ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000"
12
13if [ ! -f $BL31 ]; then
14 echo "ERROR: BL31 file $BL31 NOT found" >&2
15 exit 0
16else
17 echo "$BL31 size: " >&2
18 ls -lct $BL31 | awk '{print $5}' >&2
19fi
20
21BL32="tee.bin"
22
23if [ ! -f $BL32 ]; then
24 BL32=/dev/null
25else
26 echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2
27 echo "$BL32 size: " >&2
28 ls -lct $BL32 | awk '{print $5}' >&2
29fi
30
31BL33="u-boot-nodtb.bin"
32
33if [ ! -f $BL33 ]; then
34 echo "ERROR: $BL33 file NOT found" >&2
35 exit 0
36else
37 echo "u-boot-nodtb.bin size: " >&2
38 ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2
39fi
40
41for dtname in $*
42do
43 echo "$dtname size: " >&2
44 ls -lct $dtname | awk '{print $5}' >&2
45done
46
47
48cat << __HEADER_EOF
49/dts-v1/;
50
51/ {
52 description = "Configuration to load ATF before U-Boot";
53
54 images {
55 uboot@1 {
56 description = "U-Boot (64-bit)";
57 data = /incbin/("$BL33");
58 type = "standalone";
59 arch = "arm64";
60 compression = "none";
61 load = <0x40200000>;
62 };
63 atf@1 {
64 description = "ARM Trusted Firmware";
65 data = /incbin/("$BL31");
66 type = "firmware";
67 arch = "arm64";
68 compression = "none";
69 load = <$ATF_LOAD_ADDR>;
70 entry = <$ATF_LOAD_ADDR>;
71 };
72__HEADER_EOF
73
74if [ -f $BL32 ]; then
75cat << __HEADER_EOF
76 tee@1 {
77 description = "TEE firmware";
78 data = /incbin/("$BL32");
79 type = "firmware";
80 arch = "arm64";
81 compression = "none";
82 load = <$TEE_LOAD_ADDR>;
83 entry = <$TEE_LOAD_ADDR>;
84 };
85__HEADER_EOF
86fi
87
88cnt=1
89for dtname in $*
90do
91 cat << __FDT_IMAGE_EOF
92 fdt@$cnt {
93 description = "$(basename $dtname .dtb)";
94 data = /incbin/("$dtname");
95 type = "flat_dt";
96 compression = "none";
97 };
98__FDT_IMAGE_EOF
99cnt=$((cnt+1))
100done
101
102cat << __CONF_HEADER_EOF
103 };
104 configurations {
105 default = "config@1";
106
107__CONF_HEADER_EOF
108
109cnt=1
110for dtname in $*
111do
112if [ -f $BL32 ]; then
113cat << __CONF_SECTION_EOF
114 config@$cnt {
115 description = "$(basename $dtname .dtb)";
116 firmware = "uboot@1";
117 loadables = "atf@1", "tee@1";
118 fdt = "fdt@$cnt";
119 };
120__CONF_SECTION_EOF
121else
122cat << __CONF_SECTION1_EOF
123 config@$cnt {
124 description = "$(basename $dtname .dtb)";
125 firmware = "uboot@1";
126 loadables = "atf@1";
127 fdt = "fdt@$cnt";
128 };
129__CONF_SECTION1_EOF
130fi
131cnt=$((cnt+1))
132done
133
134cat << __ITS_EOF
135 };
136};
137__ITS_EOF