blob: 2a17968794c174c513179a938ffa8d8ae19a5025 [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"
Peng Fanf5965b22018-12-21 06:21:29 +000012[ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000"
Peng Fan128e3422018-11-20 10:19:39 +000013
14if [ ! -f $BL31 ]; then
15 echo "ERROR: BL31 file $BL31 NOT found" >&2
16 exit 0
17else
18 echo "$BL31 size: " >&2
Tim Harveyd3476132021-04-06 21:04:09 -070019 stat -c %s $BL31 >&2
Peng Fan128e3422018-11-20 10:19:39 +000020fi
21
22BL32="tee.bin"
23
24if [ ! -f $BL32 ]; then
25 BL32=/dev/null
26else
27 echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2
28 echo "$BL32 size: " >&2
Tim Harveyd3476132021-04-06 21:04:09 -070029 stat -c %s $BL32 >&2
Peng Fan128e3422018-11-20 10:19:39 +000030fi
31
32BL33="u-boot-nodtb.bin"
33
34if [ ! -f $BL33 ]; then
35 echo "ERROR: $BL33 file NOT found" >&2
36 exit 0
37else
38 echo "u-boot-nodtb.bin size: " >&2
Tim Harveyd3476132021-04-06 21:04:09 -070039 stat -c %s u-boot-nodtb.bin >&2
Peng Fan128e3422018-11-20 10:19:39 +000040fi
41
42for dtname in $*
43do
44 echo "$dtname size: " >&2
Tim Harveyd3476132021-04-06 21:04:09 -070045 stat -c %s $dtname >&2
Peng Fan128e3422018-11-20 10:19:39 +000046done
47
48
49cat << __HEADER_EOF
50/dts-v1/;
51
52/ {
53 description = "Configuration to load ATF before U-Boot";
54
55 images {
56 uboot@1 {
57 description = "U-Boot (64-bit)";
Frieder Schrempf796abd02019-08-27 06:24:40 +000058 os = "u-boot";
Peng Fan128e3422018-11-20 10:19:39 +000059 data = /incbin/("$BL33");
60 type = "standalone";
61 arch = "arm64";
62 compression = "none";
Peng Fanf5965b22018-12-21 06:21:29 +000063 load = <$BL33_LOAD_ADDR>;
Peng Fan128e3422018-11-20 10:19:39 +000064 };
Patrick Wildt4c881c02020-05-08 11:59:47 +020065__HEADER_EOF
66
67cnt=1
68for dtname in $*
69do
70 cat << __FDT_IMAGE_EOF
71 fdt@$cnt {
72 description = "$(basename $dtname .dtb)";
73 data = /incbin/("$dtname");
74 type = "flat_dt";
75 compression = "none";
76 };
77__FDT_IMAGE_EOF
78cnt=$((cnt+1))
79done
80
81cat << __HEADER_EOF
Peng Fan128e3422018-11-20 10:19:39 +000082 atf@1 {
83 description = "ARM Trusted Firmware";
Frieder Schrempf796abd02019-08-27 06:24:40 +000084 os = "arm-trusted-firmware";
Peng Fan128e3422018-11-20 10:19:39 +000085 data = /incbin/("$BL31");
86 type = "firmware";
87 arch = "arm64";
88 compression = "none";
89 load = <$ATF_LOAD_ADDR>;
90 entry = <$ATF_LOAD_ADDR>;
91 };
92__HEADER_EOF
93
94if [ -f $BL32 ]; then
95cat << __HEADER_EOF
96 tee@1 {
97 description = "TEE firmware";
98 data = /incbin/("$BL32");
99 type = "firmware";
100 arch = "arm64";
101 compression = "none";
102 load = <$TEE_LOAD_ADDR>;
103 entry = <$TEE_LOAD_ADDR>;
104 };
105__HEADER_EOF
106fi
107
Peng Fan128e3422018-11-20 10:19:39 +0000108cat << __CONF_HEADER_EOF
109 };
110 configurations {
111 default = "config@1";
112
113__CONF_HEADER_EOF
114
115cnt=1
116for dtname in $*
117do
118if [ -f $BL32 ]; then
119cat << __CONF_SECTION_EOF
120 config@$cnt {
121 description = "$(basename $dtname .dtb)";
Ye Lib3f8e3e2020-04-09 01:44:43 -0700122 firmware = "uboot@1";
123 loadables = "atf@1", "tee@1";
Peng Fan128e3422018-11-20 10:19:39 +0000124 fdt = "fdt@$cnt";
125 };
126__CONF_SECTION_EOF
127else
128cat << __CONF_SECTION1_EOF
129 config@$cnt {
130 description = "$(basename $dtname .dtb)";
Ye Lib3f8e3e2020-04-09 01:44:43 -0700131 firmware = "uboot@1";
132 loadables = "atf@1";
Peng Fan128e3422018-11-20 10:19:39 +0000133 fdt = "fdt@$cnt";
134 };
135__CONF_SECTION1_EOF
136fi
137cnt=$((cnt+1))
138done
139
140cat << __ITS_EOF
141 };
142};
143__ITS_EOF