blob: 88ad71974706614014619d0f1cb08fa16e68f0ab [file] [log] [blame]
Andre Przywara4c160892017-04-26 01:32:46 +01001#!/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
Tom Rini6475fc92017-05-22 15:40:11 -040010if [ ! -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
Icenowy Zheng1e6d7262018-07-21 16:20:23 +080016if grep -q "^CONFIG_MACH_SUN50I_H6=y" .config; then
17 BL31_ADDR=0x104000
18else
19 BL31_ADDR=0x44000
20fi
21
Andre Przywara4c160892017-04-26 01:32:46 +010022cat << __HEADER_EOF
23/dts-v1/;
24
25/ {
26 description = "Configuration to load ATF before U-Boot";
27 #address-cells = <1>;
28
29 images {
Andre Przywara2f23b1d2017-12-04 02:05:11 +000030 uboot {
Andre Przywara4c160892017-04-26 01:32:46 +010031 description = "U-Boot (64-bit)";
32 data = /incbin/("u-boot-nodtb.bin");
33 type = "standalone";
34 arch = "arm64";
35 compression = "none";
36 load = <0x4a000000>;
37 };
Andre Przywara2f23b1d2017-12-04 02:05:11 +000038 atf {
Andre Przywara4c160892017-04-26 01:32:46 +010039 description = "ARM Trusted Firmware";
40 data = /incbin/("$BL31");
41 type = "firmware";
42 arch = "arm64";
43 compression = "none";
Icenowy Zheng1e6d7262018-07-21 16:20:23 +080044 load = <$BL31_ADDR>;
45 entry = <$BL31_ADDR>;
Andre Przywara4c160892017-04-26 01:32:46 +010046 };
47__HEADER_EOF
48
49cnt=1
50for dtname in $*
51do
52 cat << __FDT_IMAGE_EOF
Andre Przywara2f23b1d2017-12-04 02:05:11 +000053 fdt_$cnt {
Andre Przywara4c160892017-04-26 01:32:46 +010054 description = "$(basename $dtname .dtb)";
55 data = /incbin/("$dtname");
56 type = "flat_dt";
57 compression = "none";
58 };
59__FDT_IMAGE_EOF
60 cnt=$((cnt+1))
61done
62
63cat << __CONF_HEADER_EOF
64 };
65 configurations {
Andre Przywara2f23b1d2017-12-04 02:05:11 +000066 default = "config_1";
Andre Przywara4c160892017-04-26 01:32:46 +010067
68__CONF_HEADER_EOF
69
70cnt=1
71for dtname in $*
72do
73 cat << __CONF_SECTION_EOF
Andre Przywara2f23b1d2017-12-04 02:05:11 +000074 config_$cnt {
Andre Przywara4c160892017-04-26 01:32:46 +010075 description = "$(basename $dtname .dtb)";
Andre Przywara2f23b1d2017-12-04 02:05:11 +000076 firmware = "uboot";
77 loadables = "atf";
78 fdt = "fdt_$cnt";
Andre Przywara4c160892017-04-26 01:32:46 +010079 };
80__CONF_SECTION_EOF
81 cnt=$((cnt+1))
82done
83
84cat << __ITS_EOF
85 };
86};
87__ITS_EOF