diff mbox series

[3/3] sunxi: replace .its file generator with Dust template

Message ID 20200323140348.26717-4-ynezz@true.cz
State Deferred
Delegated to: Tom Rini
Headers show
Series sunxi: produce working binaries by default | expand

Commit Message

Petr Štetiar March 23, 2020, 2:03 p.m. UTC
Replace current .its file based generator with generic Dust template
based approach, including the proper .its file dependency tracking, so
working images are produced by default.

bl31.bin file is mandatory for functional, usable and bootable binaries,
and currently missing bl31.bin is not hard error, just a warning.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 Kconfig                        |  5 +-
 Makefile                       |  8 ++++
 board/sunxi/mksunxi_fit_atf.sh | 87 ----------------------------------
 board/sunxi/u-boot-its.mk      | 19 ++++++++
 board/sunxi/u-boot.its.dust    | 45 ++++++++++++++++++
 5 files changed, 76 insertions(+), 88 deletions(-)
 delete mode 100755 board/sunxi/mksunxi_fit_atf.sh
 create mode 100644 board/sunxi/u-boot-its.mk
 create mode 100644 board/sunxi/u-boot.its.dust
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 7799a3b19629..ebdc3beddb56 100644
--- a/Kconfig
+++ b/Kconfig
@@ -517,10 +517,13 @@  config SPL_FIT_SOURCE
 	  U-Boot FIT image. This could specify further image to load and/or
 	  execute.
 
+config SPL_FIT_TEMPLATE
+	bool "Use Dust template based .its file generation for U-Boot FIT image"
+	default y if SPL_LOAD_FIT && ARCH_SUNXI
+
 config SPL_FIT_GENERATOR
 	string ".its file generator script for U-Boot FIT image"
 	depends on SPL_FIT
-	default "board/sunxi/mksunxi_fit_atf.sh" if SPL_LOAD_FIT && ARCH_SUNXI
 	default "arch/arm/mach-rockchip/make_fit_atf.py" if SPL_LOAD_FIT && ARCH_ROCKCHIP
 	default "arch/arm/mach-zynqmp/mkimage_fit_atf.sh" if SPL_LOAD_FIT && ARCH_ZYNQMP
 	default "arch/riscv/lib/mkimage_fit_opensbi.sh" if SPL_LOAD_FIT && RISCV
diff --git a/Makefile b/Makefile
index fa687f13a588..131e59a2fe01 100644
--- a/Makefile
+++ b/Makefile
@@ -1290,6 +1290,14 @@  $(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE
 endif
 endif
 
+ifeq ($(CONFIG_SPL_FIT_TEMPLATE),y)
+U_BOOT_ITS := u-boot.its
+include $(srctree)/include/u-boot-its.mk
+sinclude $(srctree)/board/$(BOARDDIR)/u-boot-its.mk
+$(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) $(U_BOOT_ITS_JSON) FORCE
+	$(call cmd,gen_its)
+endif
+
 ifdef CONFIG_SPL_LOAD_FIT
 MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
 	-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
diff --git a/board/sunxi/mksunxi_fit_atf.sh b/board/sunxi/mksunxi_fit_atf.sh
deleted file mode 100755
index 88ad71974706..000000000000
--- a/board/sunxi/mksunxi_fit_atf.sh
+++ /dev/null
@@ -1,87 +0,0 @@ 
-#!/bin/sh
-#
-# script to generate FIT image source for 64-bit sunxi boards with
-# ARM Trusted Firmware and multiple device trees (given on the command line)
-#
-# usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
-
-[ -z "$BL31" ] && BL31="bl31.bin"
-
-if [ ! -f $BL31 ]; then
-	echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2
-	echo "Please read the section on ARM Trusted Firmware (ATF) in board/sunxi/README.sunxi64" >&2
-	BL31=/dev/null
-fi
-
-if grep -q "^CONFIG_MACH_SUN50I_H6=y" .config; then
-	BL31_ADDR=0x104000
-else
-	BL31_ADDR=0x44000
-fi
-
-cat << __HEADER_EOF
-/dts-v1/;
-
-/ {
-	description = "Configuration to load ATF before U-Boot";
-	#address-cells = <1>;
-
-	images {
-		uboot {
-			description = "U-Boot (64-bit)";
-			data = /incbin/("u-boot-nodtb.bin");
-			type = "standalone";
-			arch = "arm64";
-			compression = "none";
-			load = <0x4a000000>;
-		};
-		atf {
-			description = "ARM Trusted Firmware";
-			data = /incbin/("$BL31");
-			type = "firmware";
-			arch = "arm64";
-			compression = "none";
-			load = <$BL31_ADDR>;
-			entry = <$BL31_ADDR>;
-		};
-__HEADER_EOF
-
-cnt=1
-for dtname in $*
-do
-	cat << __FDT_IMAGE_EOF
-		fdt_$cnt {
-			description = "$(basename $dtname .dtb)";
-			data = /incbin/("$dtname");
-			type = "flat_dt";
-			compression = "none";
-		};
-__FDT_IMAGE_EOF
-	cnt=$((cnt+1))
-done
-
-cat << __CONF_HEADER_EOF
-	};
-	configurations {
-		default = "config_1";
-
-__CONF_HEADER_EOF
-
-cnt=1
-for dtname in $*
-do
-	cat << __CONF_SECTION_EOF
-		config_$cnt {
-			description = "$(basename $dtname .dtb)";
-			firmware = "uboot";
-			loadables = "atf";
-			fdt = "fdt_$cnt";
-		};
-__CONF_SECTION_EOF
-	cnt=$((cnt+1))
-done
-
-cat << __ITS_EOF
-	};
-};
-__ITS_EOF
diff --git a/board/sunxi/u-boot-its.mk b/board/sunxi/u-boot-its.mk
new file mode 100644
index 000000000000..c6294f18889f
--- /dev/null
+++ b/board/sunxi/u-boot-its.mk
@@ -0,0 +1,19 @@ 
+BL31 := $(CURDIR)/bl31.bin
+BL31_ADDR := $(if $(CONFIG_MACH_SUN50I_H6),0x104000,0x104000)
+
+$(BL31):
+	$(call check_its_dep,$@,BL31)
+
+U_BOOT_ITS_DEPS += $(BL31)
+
+quiet_cmd_gen_its_json = GENITS_JSON  $@
+define cmd_gen_its_json
+	echo '{ \
+		"bl31": "$(BL31)", \
+		"load": "$(BL31_ADDR)", \
+		"dtbs": [ \
+			$(call gen_its_json_dtbs) \
+		] \
+	}' > $@
+endef
+
diff --git a/board/sunxi/u-boot.its.dust b/board/sunxi/u-boot.its.dust
new file mode 100644
index 000000000000..50d14e02e52f
--- /dev/null
+++ b/board/sunxi/u-boot.its.dust
@@ -0,0 +1,45 @@ 
+/dts-v1/;
+
+/ {
+	description = "Configuration to load ATF before U-Boot";
+	#address-cells = <1>;
+
+	images {
+		uboot {
+			description = "U-Boot (64-bit)";
+			data = /incbin/("u-boot-nodtb.bin");
+			type = "standalone";
+			arch = "arm64";
+			compression = "none";
+			load = <0x4a000000>;
+		};
+		atf {
+			description = "ARM Trusted Firmware";
+			data = /incbin/("{bl31}");
+			type = "firmware";
+			arch = "arm64";
+			compression = "none";
+			load = <{load}>;
+			entry = <{load}>;
+		};
+{#dtbs}
+		fdt_{@idx}{.}{/idx} {
+			description = "{name}";
+			data = /incbin/("{path}");
+			type = "flat_dt";
+			compression = "none";
+		};
+{/dtbs}
+	};
+	configurations {
+		default = "config_0";
+{#dtbs}
+		config_{@idx}{.}{/idx} {
+			description = "{name}";
+			firmware = "uboot";
+			loadables = "atf";
+			fdt = "fdt_{@idx}{.}{/idx}";
+		};
+{/dtbs}
+	};
+};