blob: 3a476ced98b1ff7e6ebd2cc314e9a3bdaf8f2893 [file] [log] [blame]
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +05301#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0+
3#
4# script to generate FIT image source for K3 Family boards with
5# ATF, OPTEE, SPL and multiple device trees (given on the command line).
6# Inspired from board/sunxi/mksunxi_fit_atf.sh
7#
Aswath Govindraju0c515092021-06-04 22:00:31 +05308# usage: $0 <atf_load_addr> <dt_name> [<dt_name> [<dt_name] ...]
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +05309
10[ -z "$ATF" ] && ATF="bl31.bin"
11
12if [ ! -f $ATF ]; then
13 echo "WARNING ATF file $ATF NOT found, resulting binary is non-functional" >&2
14 ATF=/dev/null
15fi
16
17[ -z "$TEE" ] && TEE="bl32.bin"
18
19if [ ! -f $TEE ]; then
20 echo "WARNING OPTEE file $TEE NOT found, resulting might be non-functional" >&2
21 TEE=/dev/null
22fi
23
Tero Kristodf5363a2021-06-11 11:45:17 +030024[ -z "$DM" ] && DM="dm.bin"
25
26if [ ! -e $DM ]; then
27 echo "WARNING DM file $DM NOT found, resulting might be non-functional" >&2
28 DM=/dev/null
29fi
30
Andrew F. Davis50836962019-04-12 12:54:46 -040031if [ ! -z "$IS_HS" ]; then
32 HS_APPEND=_HS
33fi
34
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053035cat << __HEADER_EOF
36/dts-v1/;
37
38/ {
39 description = "Configuration to load ATF and SPL";
40 #address-cells = <1>;
41
42 images {
43 atf {
44 description = "ARM Trusted Firmware";
45 data = /incbin/("$ATF");
46 type = "firmware";
47 arch = "arm64";
48 compression = "none";
49 os = "arm-trusted-firmware";
Aswath Govindraju0c515092021-06-04 22:00:31 +053050 load = <$1>;
51 entry = <$1>;
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053052 };
53 tee {
54 description = "OPTEE";
55 data = /incbin/("$TEE");
56 type = "tee";
57 arch = "arm64";
58 compression = "none";
59 os = "tee";
60 load = <0x9e800000>;
61 entry = <0x9e800000>;
62 };
Tero Kristodf5363a2021-06-11 11:45:17 +030063 dm {
64 description = "DM binary";
65 data = /incbin/("$DM");
66 type = "firmware";
67 arch = "arm32";
68 compression = "none";
69 os = "DM";
70 load = <0xa0000000>;
71 entry = <0xa0000000>;
72 };
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053073 spl {
74 description = "SPL (64-bit)";
Andrew F. Davis50836962019-04-12 12:54:46 -040075 data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053076 type = "standalone";
77 os = "U-Boot";
78 arch = "arm64";
79 compression = "none";
80 load = <0x80080000>;
81 entry = <0x80080000>;
82 };
83__HEADER_EOF
84
Aswath Govindraju0c515092021-06-04 22:00:31 +053085# shift through ATF load address in the command line arguments
86shift
87
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053088for dtname in $*
89do
90 cat << __FDT_IMAGE_EOF
91 $(basename $dtname) {
92 description = "$(basename $dtname .dtb)";
Andrew F. Davis50836962019-04-12 12:54:46 -040093 data = /incbin/("$dtname$HS_APPEND");
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +053094 type = "flat_dt";
95 arch = "arm";
96 compression = "none";
97 };
98__FDT_IMAGE_EOF
99done
100
101cat << __CONF_HEADER_EOF
102 };
103 configurations {
104 default = "$(basename $1)";
105
106__CONF_HEADER_EOF
107
108for dtname in $*
109do
110 cat << __CONF_SECTION_EOF
111 $(basename $dtname) {
112 description = "$(basename $dtname .dtb)";
113 firmware = "atf";
Tero Kristodf5363a2021-06-11 11:45:17 +0300114 loadables = "tee", "dm", "spl";
Lokesh Vutla9d4f8c42018-08-27 15:57:14 +0530115 fdt = "$(basename $dtname)";
116 };
117__CONF_SECTION_EOF
118done
119
120cat << __ITS_EOF
121 };
122};
123__ITS_EOF