colibri_imx6: fix video stdout in default environment
[oweals/u-boot.git] / tools / k3_fit_atf.sh
1 #!/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 #
8 # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
9
10 [ -z "$ATF" ] && ATF="bl31.bin"
11
12 if [ ! -f $ATF ]; then
13         echo "WARNING ATF file $ATF NOT found, resulting binary is non-functional" >&2
14         ATF=/dev/null
15 fi
16
17 [ -z "$TEE" ] && TEE="bl32.bin"
18
19 if [ ! -f $TEE ]; then
20         echo "WARNING OPTEE file $TEE NOT found, resulting might be non-functional" >&2
21         TEE=/dev/null
22 fi
23
24 if [ ! -z "$IS_HS" ]; then
25         HS_APPEND=_HS
26 fi
27
28 cat << __HEADER_EOF
29 /dts-v1/;
30
31 / {
32         description = "Configuration to load ATF and SPL";
33         #address-cells = <1>;
34
35         images {
36                 atf {
37                         description = "ARM Trusted Firmware";
38                         data = /incbin/("$ATF");
39                         type = "firmware";
40                         arch = "arm64";
41                         compression = "none";
42                         os = "arm-trusted-firmware";
43                         load = <0x70000000>;
44                         entry = <0x70000000>;
45                 };
46                 tee {
47                         description = "OPTEE";
48                         data = /incbin/("$TEE");
49                         type = "tee";
50                         arch = "arm64";
51                         compression = "none";
52                         os = "tee";
53                         load = <0x9e800000>;
54                         entry = <0x9e800000>;
55                 };
56                 spl {
57                         description = "SPL (64-bit)";
58                         data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
59                         type = "standalone";
60                         os = "U-Boot";
61                         arch = "arm64";
62                         compression = "none";
63                         load = <0x80080000>;
64                         entry = <0x80080000>;
65                 };
66 __HEADER_EOF
67
68 for dtname in $*
69 do
70         cat << __FDT_IMAGE_EOF
71                 $(basename $dtname) {
72                         description = "$(basename $dtname .dtb)";
73                         data = /incbin/("$dtname$HS_APPEND");
74                         type = "flat_dt";
75                         arch = "arm";
76                         compression = "none";
77                 };
78 __FDT_IMAGE_EOF
79 done
80
81 cat << __CONF_HEADER_EOF
82         };
83         configurations {
84                 default = "$(basename $1)";
85
86 __CONF_HEADER_EOF
87
88 for dtname in $*
89 do
90         cat << __CONF_SECTION_EOF
91                 $(basename $dtname) {
92                         description = "$(basename $dtname .dtb)";
93                         firmware = "atf";
94                         loadables = "tee", "spl";
95                         fdt = "$(basename $dtname)";
96                 };
97 __CONF_SECTION_EOF
98 done
99
100 cat << __ITS_EOF
101         };
102 };
103 __ITS_EOF