1#!/bin/sh
2#
3# script to generate FIT image source for 64-bit sunxi boards with
4# ARM Trusted Firmware and multiple device trees (given on the command line)
5#
6# usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
7
8[ -z "$BL31" ] && BL31="bl31.bin"
9
10if [ ! -f $BL31 ]; then
11	echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2
12	echo "Please read the section on ARM Trusted Firmware (ATF) in board/sunxi/README.sunxi64" >&2
13	BL31=/dev/null
14fi
15
16cat << __HEADER_EOF
17/dts-v1/;
18
19/ {
20	description = "Configuration to load ATF before U-Boot";
21	#address-cells = <1>;
22
23	images {
24		uboot@1 {
25			description = "U-Boot (64-bit)";
26			data = /incbin/("u-boot-nodtb.bin");
27			type = "standalone";
28			arch = "arm64";
29			compression = "none";
30			load = <0x4a000000>;
31		};
32		atf@1 {
33			description = "ARM Trusted Firmware";
34			data = /incbin/("$BL31");
35			type = "firmware";
36			arch = "arm64";
37			compression = "none";
38			load = <0x44000>;
39			entry = <0x44000>;
40		};
41__HEADER_EOF
42
43cnt=1
44for dtname in $*
45do
46	cat << __FDT_IMAGE_EOF
47		fdt@$cnt {
48			description = "$(basename $dtname .dtb)";
49			data = /incbin/("$dtname");
50			type = "flat_dt";
51			compression = "none";
52		};
53__FDT_IMAGE_EOF
54	cnt=$((cnt+1))
55done
56
57cat << __CONF_HEADER_EOF
58	};
59	configurations {
60		default = "config@1";
61
62__CONF_HEADER_EOF
63
64cnt=1
65for dtname in $*
66do
67	cat << __CONF_SECTION_EOF
68		config@$cnt {
69			description = "$(basename $dtname .dtb)";
70			firmware = "uboot@1";
71			loadables = "atf@1";
72			fdt = "fdt@$cnt";
73		};
74__CONF_SECTION_EOF
75	cnt=$((cnt+1))
76done
77
78cat << __ITS_EOF
79	};
80};
81__ITS_EOF
82