Skip to contentSkip to conversation

k3-am642-evm-u-boot: Use binman to generate u-boot.img and tispl.bin

PATCH In review Roger Quadros 4 participants 17 messages May 9, 2022 – Jun 11, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover k3-am642-evm-u-boot: Use binman to generate u-boot.img and tispl.bin

Hi,

This series introduces ti-secure entry type for binman.

It switches from using custom tool tools/k3_fit_atf.sh to binman for generating boot images for AM64 for both HS and non-HS devices.

cheers,
-roger

Roger Quadros (3):
tools: binman: add ti-secure entry type
tools/fdtgrep: Include __symbols__ table
k3-am642-evm-u-boot: Use binman to generate u-boot.img and tispl.bin

 Makefile                              |   1 +
 arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++
 arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 +
 arch/arm/mach-k3/Kconfig              |   1 +
 arch/arm/mach-k3/config.mk            |   7 +
 tools/binman/entries.rst              |  15 ++
 tools/binman/etype/ti_secure.py       |  59 +++++++
 tools/binman/ftest.py                 |   7 +
 tools/binman/test/225_ti_secure.dts   |  14 ++
 tools/fdtgrep.c                       |   4 +
 10 files changed, 341 insertions(+)
 create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi
 create mode 100644 tools/binman/etype/ti_secure.py
 create mode 100644 tools/binman/test/225_ti_secure.dts
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 tools: binman: add ti-secure entry type

This entry type is used to create a secured binary for use with K3 High Security (HS) devices.

This allows us to no longer depend on k3_fit_atf.sh for A53 SPL and u-boot image generation for HS devices.

We still depend on the availability of an external tool provided by the TI_SECURE_DEV_PKG environment variable to secure the binaries.

---
 Makefile                            |  1 +
 tools/binman/entries.rst            | 15 ++++++++
 tools/binman/etype/ti_secure.py     | 59 +++++++++++++++++++++++++++++
 tools/binman/ftest.py               |  7 ++++
 tools/binman/test/225_ti_secure.dts | 14 +++++++
 5 files changed, 96 insertions(+)
 create mode 100644 tools/binman/etype/ti_secure.py
 create mode 100644 tools/binman/test/225_ti_secure.dts
Makefile +1 -0
index ad83d60dc3..d9aac41d60 100644
@@ -1328,6 +1328,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
 		$(foreach f,$(BINMAN_INDIRS),-I $(f)) \
 		-a atf-bl31-path=${BL31} \
 		-a tee-os-path=${TEE} \
+		-a ti-secure-dev-pkg-path=${TI_SECURE_DEV_PKG} \
 		-a opensbi-path=${OPENSBI} \
 		-a default-dt=$(default_dt) \
 		-a scp-path=$(SCP) \
tools/binman/entries.rst +15 -0
index 484cde5c80..c9faad51b6 100644
@@ -1788,3 +1788,18 @@ may be used instead.
 
 
 
+Entry: ti-secure: Entry containing a Secured binary blob
+--------------------------------------------------------
+
+Properties / Entry arguments:
+    - filename: Filename of file to sign and read into entry
+
+Texas Instruments High-Security (HS) devices need secure binaries to be
+provided. This entry uses an external tool to append a x509 certificate
+to the file provided in the filename property and places it in the entry.
+
+The path for the external tool is fetched from TI_SECURE_DEV_PKG
+environment variable.
+
+
+
tools/binman/etype/ti_secure.py new file +59 -0

59 lines not on this page · raw message

tools/binman/ftest.py +7 -0
index 8f00db6945..996e4d9aa6 100644
@@ -91,6 +91,7 @@ SCP_DATA              = b'scp'
 TEST_FDT1_DATA        = b'fdt1'
 TEST_FDT2_DATA        = b'test-fdt2'
 ENV_DATA              = b'var1=1\nvar2="2"'
+TI_UNSECURE_DATA      = b'this is some unsecure data'
 
 # Subdirectory of the input dir to use to put test FDTs
 TEST_FDT_SUBDIR       = 'fdts'
@@ -201,6 +202,7 @@ class TestFunctional(unittest.TestCase):
                                       TEST_FDT2_DATA)
 
         TestFunctional._MakeInputFile('env.txt', ENV_DATA)
+        TestFunctional._MakeInputFile('ti_unsecure.bin', TI_UNSECURE_DATA)
 
         cls.have_lz4 = comp_util.HAVE_LZ4
 
@@ -5321,6 +5323,11 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self.assertIn("Node '/binman/fit': Unknown operation 'unknown'",
                       str(exc.exception))
 
+    def testPackTisecure(self):
+        """Test that an image with a TI secured binary can be created"""
+        data = self._DoReadFile('225_ti_secure.dts')
+        securedata = tools.ReadFile('ti_unsecure.bin_HS')
+        self.assertGreater(len(securedata), len(data))
 
 if __name__ == "__main__":
     unittest.main()
tools/binman/test/225_ti_secure.dts new file +14 -0
new file mode 100644
index 0000000000..1a9f4374f9
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		ti-secure {
+			filename = "ti_unsecure.bin";
+		};
+	};
+};
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 tools/fdtgrep: Include __symbols__ table

In reply to Roger Quadros

This is required for overlays to work at SPL.

---
 tools/fdtgrep.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/fdtgrep.c +4 -0
index 641d6a2e3e..d904f679ae 100644
@@ -1230,6 +1230,10 @@ int main(int argc, char *argv[])
 		disp.fout = stdout;
 	}
 
+	/* include symbol table */
+	if (value_add(&disp, &disp.value_head, FDT_IS_NODE, 1, "/__symbols__"))
+		usage("Cannot add __symbols__ value");
+
 	/* Run the grep and output the results */
 	ret = do_fdtgrep(&disp, filename);
 	if (disp.output_fname)
Signature · 1 line
2.17.1
#6 lore raw

PATCH 3/3 k3-am642-evm-u-boot: Use binman to generate u-boot.img and tispl.bin

In reply to Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
 arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++
 arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 +
 arch/arm/mach-k3/Kconfig              |   1 +
 arch/arm/mach-k3/config.mk            |   7 +
 4 files changed, 241 insertions(+)
 create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi
arch/arm/dts/k3-am642-evm-binman.dtsi new file +230 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+	binman: binman {
+		multiple-images;
+	};
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+	ti-spl {
+		filename = TISPL;
+		pad-byte = <0xff>;
+
+		fit {
+			description = "Configuration to load ATF and SPL";
+			#address-cells = <1>;
+
+			images {
+
+				atf {
+					description = "ARM Trusted Firmware";
+					type = "firmware";
+					arch = "arm64";
+					compression = "none";
+					os = "arm-trusted-firmware";
+					load = <CONFIG_K3_ATF_LOAD_ADDR>;
+					entry = <CONFIG_K3_ATF_LOAD_ADDR>;
+					atf-bl31 {
+						filename = "bl31.bin";
+					};
+				};
+
+				tee {
+					description = "OPTEE";
+					type = "tee";
+					arch = "arm64";
+					compression = "none";
+					os = "tee";
+					load = <0x9e800000>;
+					entry = <0x9e800000>;
+					tee-os {
+						filename = "tee-pager_v2.bin";
+					};
+				};
+
+				dm {
+					description = "DM binary";
+					type = "firmware";
+					arch = "arm32";
+					compression = "none";
+					os = "DM";
+					load = <0x89000000>;
+					entry = <0x89000000>;
+					blob-ext {
+						filename = "/dev/null";
+					};
+				};
+
+				spl {
+					description = "SPL (64-bit)";
+					type = "standalone";
+					os = "U-Boot";
+					arch = "arm64";
+					compression = "none";
+					load = <0x80080000>;
+					entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_NODTB;
+					};
+				};
+
+				fdt-1 {
+					description = "k3-am642-evm";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_AM642_EVM_DTB;
+					};
+				};
+
+				fdt-2 {
+					description = "k3-am642-sk";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_AM642_SK_DTB;
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-1";
+
+				conf-1 {
+					description = "k3-am642-evm";
+					firmware = "atf";
+					loadables = "tee", "dm", "spl";
+					fdt = "fdt-1";
+				};
+
+				conf-2 {
+					description = "k3-am642-sk";
+					firmware = "atf";
+					loadables = "tee", "dm", "spl";
+					fdt = "fdt-2";
+				};
+			};
+		};
+	};
+};
+
+&binman {
+	u-boot {
+		filename = UBOOT_IMG;
+		pad-byte = <0xff>;
+
+		fit {
+			description = "FIT image with multiple configurations";
+
+			images {
+				uboot {
+					description = "U-Boot for am64x board";
+					type = "firmware";
+					os = "u-boot";
+					arch = "arm";
+					compression = "none";
+					load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = UBOOT_NODTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+
+				fdt-1 {
+					description = "k3-am642-evm";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = AM642_EVM_DTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+
+				fdt-2 {
+					description = "k3-am642-sk";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = AM642_SK_DTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-1";
+
+				conf-1 {
+					description = "k3-am642-evm";
+					firmware = "uboot";
+					loadables = "uboot";
+					fdt = "fdt-1";
+				};
+
+				conf-2 {
+					description = "k3-am642-sk";
+					firmware = "uboot";
+					loadables = "uboot";
+					fdt = "fdt-2";
+				};
+			};
+		};
+	};
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
 /*
  * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
  */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
 
 / {
 	chosen {
arch/arm/mach-k3/Kconfig +1 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2
 
 config SOC_K3_AM642
 	bool "TI's K3 based AM642 SoC Family Support"
+	select BINMAN if TARGET_AM642_A53_EVM
 
 endchoice
 
arch/arm/mach-k3/config.mk +7 -0
index da458bcfb2..d2c490818a 100644
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE
 INPUTS-y	+= tiboot3.bin
 endif
 
+ifndef CONFIG_BINMAN
 ifdef CONFIG_ARM64
 
 ifeq ($(CONFIG_SOC_K3_J721E),)
@@ -77,9 +78,11 @@ cmd_k3_mkits = \
 $(SPL_ITS): FORCE
 	$(call cmd,k3_mkits)
 endif
+endif
 
 else
 
+ifndef CONFIG_BINMAN
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
 INPUTS-y	+= u-boot.img_HS
 else
@@ -87,4 +90,8 @@ INPUTS-y	+= u-boot.img
 endif
 endif
 
+endif
+
+ifndef CONFIG_BINMAN
 include $(srctree)/arch/arm/mach-k3/config_secure.mk
+endif
Signature · 1 line
2.17.1
#16 lore raw
In reply to Roger Quadros
Quoted 16 lines · Roger Quadros

Hi,

This series introduces ti-secure entry type for binman.

It switches from using custom tool tools/k3_fit_atf.sh to binman for generating boot images for AM64 for both HS and non-HS devices.

cheers,
-roger

Roger Quadros (3):
tools: binman: add ti-secure entry type
tools/fdtgrep: Include __symbols__ table
k3-am642-evm-u-boot: Use binman to generate u-boot.img and tispl.bin

Quoted 14 lines
 Makefile                              |   1 +
 arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++
 arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 +
 arch/arm/mach-k3/Kconfig              |   1 +
 arch/arm/mach-k3/config.mk            |   7 +
 tools/binman/entries.rst              |  15 ++
 tools/binman/etype/ti_secure.py       |  59 +++++++
 tools/binman/ftest.py                 |   7 +
 tools/binman/test/225_ti_secure.dts   |  14 ++
 tools/fdtgrep.c                       |   4 +
 10 files changed, 341 insertions(+)
 create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi
 create mode 100644 tools/binman/etype/ti_secure.py
 create mode 100644 tools/binman/test/225_ti_secure.dts

Adding the other binman maintainer..

Signature · 1 line
Tom
#7 lore raw
In reply to Roger Quadros
Quoted 64 lines · Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
  arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++
  arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 +
  arch/arm/mach-k3/Kconfig              |   1 +
  arch/arm/mach-k3/config.mk            |   7 +
  4 files changed, 241 insertions(+)

create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi

arch/arm/dts/k3-am642-evm-binman.dtsi new file +41 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+	binman: binman {
+		multiple-images;
+	};
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+	ti-spl {
+		filename = TISPL;
+		pad-byte = <0xff>;
+
+		fit {
+			description = "Configuration to load ATF and SPL";
+			#address-cells = <1>;
+
+			images {
+
+				atf {

arch/arm/dts/k3-am642-evm-binman.dtsi line 51

Quoted 10 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +10 -0
+					description = "ARM Trusted Firmware";
+					type = "firmware";
+					arch = "arm64";
+					compression = "none";
+					os = "arm-trusted-firmware";
+					load = <CONFIG_K3_ATF_LOAD_ADDR>;
+					entry = <CONFIG_K3_ATF_LOAD_ADDR>;
+					atf-bl31 {
+						filename = "bl31.bin";
+					};

On HS, bl31.bin and the below TEE and DM images must also be signed before being packaged into tispl.bin.
Can we add signing here?

Andrew

Quoted 238 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +179 -0
+				};
+
+				tee {
+					description = "OPTEE";
+					type = "tee";
+					arch = "arm64";
+					compression = "none";
+					os = "tee";
+					load = <0x9e800000>;
+					entry = <0x9e800000>;
+					tee-os {
+						filename = "tee-pager_v2.bin";
+					};
+				};
+
+				dm {
+					description = "DM binary";
+					type = "firmware";
+					arch = "arm32";
+					compression = "none";
+					os = "DM";
+					load = <0x89000000>;
+					entry = <0x89000000>;
+					blob-ext {
+						filename = "/dev/null";
+					};
+				};
+
+				spl {
+					description = "SPL (64-bit)";
+					type = "standalone";
+					os = "U-Boot";
+					arch = "arm64";
+					compression = "none";
+					load = <0x80080000>;
+					entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_NODTB;
+					};
+				};
+
+				fdt-1 {
+					description = "k3-am642-evm";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_AM642_EVM_DTB;
+					};
+				};
+
+				fdt-2 {
+					description = "k3-am642-sk";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = SPL_AM642_SK_DTB;
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-1";
+
+				conf-1 {
+					description = "k3-am642-evm";
+					firmware = "atf";
+					loadables = "tee", "dm", "spl";
+					fdt = "fdt-1";
+				};
+
+				conf-2 {
+					description = "k3-am642-sk";
+					firmware = "atf";
+					loadables = "tee", "dm", "spl";
+					fdt = "fdt-2";
+				};
+			};
+		};
+	};
+};
+
+&binman {
+	u-boot {
+		filename = UBOOT_IMG;
+		pad-byte = <0xff>;
+
+		fit {
+			description = "FIT image with multiple configurations";
+
+			images {
+				uboot {
+					description = "U-Boot for am64x board";
+					type = "firmware";
+					os = "u-boot";
+					arch = "arm";
+					compression = "none";
+					load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = UBOOT_NODTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+
+				fdt-1 {
+					description = "k3-am642-evm";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = AM642_EVM_DTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+
+				fdt-2 {
+					description = "k3-am642-sk";
+					type = "flat_dt";
+					arch = "arm";
+					compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+					ti-secure {
+#else
+					blob {
+#endif
+						filename = AM642_SK_DTB;
+					};
+					hash {
+						algo = "crc32";
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-1";
+
+				conf-1 {
+					description = "k3-am642-evm";
+					firmware = "uboot";
+					loadables = "uboot";
+					fdt = "fdt-1";
+				};
+
+				conf-2 {
+					description = "k3-am642-sk";
+					firmware = "uboot";
+					loadables = "uboot";
+					fdt = "fdt-2";
+				};
+			};
+		};
+	};
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
  /*
   * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
   */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
 
  / {
  	chosen {
arch/arm/mach-k3/Kconfig +1 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2
 
  config SOC_K3_AM642
  	bool "TI's K3 based AM642 SoC Family Support"
+	select BINMAN if TARGET_AM642_A53_EVM
 
  endchoice
 
arch/arm/mach-k3/config.mk +7 -0
index da458bcfb2..d2c490818a 100644
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE
  INPUTS-y	+= tiboot3.bin
  endif
 
+ifndef CONFIG_BINMAN
  ifdef CONFIG_ARM64
 
  ifeq ($(CONFIG_SOC_K3_J721E),)
@@ -77,9 +78,11 @@ cmd_k3_mkits = \
  $(SPL_ITS): FORCE
  	$(call cmd,k3_mkits)
  endif
+endif
 
  else
 
+ifndef CONFIG_BINMAN
  ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
  INPUTS-y	+= u-boot.img_HS
  else
@@ -87,4 +90,8 @@ INPUTS-y	+= u-boot.img
  endif
  endif
 
+endif
+
+ifndef CONFIG_BINMAN
  include $(srctree)/arch/arm/mach-k3/config_secure.mk
+endif
#8 lore raw

Hi Andrew,

Quoted 72 lines · Andrew Davis
Quoted 71 lines · Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
  arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++ arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 + arch/arm/mach-k3/Kconfig              |   1 + arch/arm/mach-k3/config.mk            |   7 +

  4 files changed, 241 insertions(+)

  create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi

arch/arm/dts/k3-am642-evm-binman.dtsi new file +48 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+    binman: binman {
+        multiple-images;
+    };
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+    ti-spl {
+        filename = TISPL;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "Configuration to load ATF and SPL";
+            #address-cells = <1>;
+
+            images {
+
+                atf {
+                    description = "ARM Trusted Firmware";
+                    type = "firmware";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "arm-trusted-firmware";
+                    load = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    entry = <CONFIG_K3_ATF_LOAD_ADDR>;
Quoted 8 lines

arch/arm/dts/k3-am642-evm-binman.dtsi line 51

Quoted 3 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +3 -0
+                    atf-bl31 {
+                        filename = "bl31.bin";
+                    };

On HS, bl31.bin and the below TEE and DM images must also be signed before being packaged into tispl.bin.
Can we add signing here?

I'm wondering how this is working as is on HS boards.

Another thing to note is that the atf and tee entries take into consideration the below environment variables

                -a atf-bl31-path=${BL31} \
                -a tee-os-path=${TEE} \

How do we continue to support that while adding the signing bits?

cheers,
-roger

Quoted 233 lines

Andrew

Quoted 229 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +179 -0
+                };
+
+                tee {
+                    description = "OPTEE";
+                    type = "tee";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "tee";
+                    load = <0x9e800000>;
+                    entry = <0x9e800000>;
+                    tee-os {
+                        filename = "tee-pager_v2.bin";
+                    };
+                };
+
+                dm {
+                    description = "DM binary";
+                    type = "firmware";
+                    arch = "arm32";
+                    compression = "none";
+                    os = "DM";
+                    load = <0x89000000>;
+                    entry = <0x89000000>;
+                    blob-ext {
+                        filename = "/dev/null";
+                    };
+                };
+
+                spl {
+                    description = "SPL (64-bit)";
+                    type = "standalone";
+                    os = "U-Boot";
+                    arch = "arm64";
+                    compression = "none";
+                    load = <0x80080000>;
+                    entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_NODTB;
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_EVM_DTB;
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_SK_DTB;
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+
+&binman {
+    u-boot {
+        filename = UBOOT_IMG;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "FIT image with multiple configurations";
+
+            images {
+                uboot {
+                    description = "U-Boot for am64x board";
+                    type = "firmware";
+                    os = "u-boot";
+                    arch = "arm";
+                    compression = "none";
+                    load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = UBOOT_NODTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_EVM_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_SK_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
   /*
    * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
    */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
     / {
       chosen {
arch/arm/mach-k3/Kconfig +0 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2

    config SOC_K3_AM642
      bool "TI's K3 based AM642 SoC Family Support"
+    select BINMAN if TARGET_AM642_A53_EVM
    endchoice
  diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk index da458bcfb2..d2c490818a 100644

arch/arm/mach-k3/config.mk +0 -0
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE

  INPUTS-y    += tiboot3.bin
  endif
  +ifndef CONFIG_BINMAN
  ifdef CONFIG_ARM64
    ifeq ($(CONFIG_SOC_K3_J721E),)

arch/arm/mach-k3/config.mk +0 -0
@@ -77,9 +78,11 @@ cmd_k3_mkits = \

  $(SPL_ITS): FORCE
      $(call cmd,k3_mkits)
  endif
+endif
    else
  +ifndef CONFIG_BINMAN
  ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
  INPUTS-y    += u-boot.img_HS
  else

arch/arm/mach-k3/config.mk +0 -0
@@ -87,4 +90,8 @@ INPUTS-y    += u-boot.img

  endif
  endif
  +endif

arch/arm/mach-k3/config.mk +2 -0
+
+ifndef CONFIG_BINMAN

  include $(srctree)/arch/arm/mach-k3/config_secure.mk +endif

#9 lore raw
Quoted 84 lines · Roger Quadros

Hi Andrew,

Quoted 72 lines · Andrew Davis
Quoted 71 lines · Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
   arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++
   arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 +
   arch/arm/mach-k3/Kconfig              |   1 +
   arch/arm/mach-k3/config.mk            |   7 +
   4 files changed, 241 insertions(+)

  create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi

arch/arm/dts/k3-am642-evm-binman.dtsi new file +48 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+    binman: binman {
+        multiple-images;
+    };
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+    ti-spl {
+        filename = TISPL;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "Configuration to load ATF and SPL";
+            #address-cells = <1>;
+
+            images {
+
+                atf {
+                    description = "ARM Trusted Firmware";
+                    type = "firmware";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "arm-trusted-firmware";
+                    load = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    entry = <CONFIG_K3_ATF_LOAD_ADDR>;
Quoted 8 lines

arch/arm/dts/k3-am642-evm-binman.dtsi line 51

Quoted 3 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +3 -0
+                    atf-bl31 {
+                        filename = "bl31.bin";
+                    };

On HS, bl31.bin and the below TEE and DM images must also be signed before being packaged into tispl.bin.
Can we add signing here?

Quoted 2 lines

I'm wondering how this is working as is on HS boards.

Today we manually sign those two before we feed them to U-Boot build. I'd like to fix that and have them signed along with all the other parts here when packaging them together.

Quoted 7 lines

Another thing to note is that the atf and tee entries take into consideration the below environment variables

                 -a atf-bl31-path=${BL31} \
                 -a tee-os-path=${TEE} \

How do we continue to support that while adding the signing bits?

That's my question also, I'm not sure how we would make the type 'ti-secure' while also changing their path names, seems like a limitation currently of using etypes to do the signing, since we can do path renames from command line.

Andrew

Quoted 236 lines

cheers,
-roger

Quoted 233 lines

Andrew

Quoted 229 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +179 -0
+                };
+
+                tee {
+                    description = "OPTEE";
+                    type = "tee";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "tee";
+                    load = <0x9e800000>;
+                    entry = <0x9e800000>;
+                    tee-os {
+                        filename = "tee-pager_v2.bin";
+                    };
+                };
+
+                dm {
+                    description = "DM binary";
+                    type = "firmware";
+                    arch = "arm32";
+                    compression = "none";
+                    os = "DM";
+                    load = <0x89000000>;
+                    entry = <0x89000000>;
+                    blob-ext {
+                        filename = "/dev/null";
+                    };
+                };
+
+                spl {
+                    description = "SPL (64-bit)";
+                    type = "standalone";
+                    os = "U-Boot";
+                    arch = "arm64";
+                    compression = "none";
+                    load = <0x80080000>;
+                    entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_NODTB;
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_EVM_DTB;
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_SK_DTB;
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+
+&binman {
+    u-boot {
+        filename = UBOOT_IMG;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "FIT image with multiple configurations";
+
+            images {
+                uboot {
+                    description = "U-Boot for am64x board";
+                    type = "firmware";
+                    os = "u-boot";
+                    arch = "arm";
+                    compression = "none";
+                    load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = UBOOT_NODTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_EVM_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_SK_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
   /*
    * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
    */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
     / {
       chosen {
arch/arm/mach-k3/Kconfig +1 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2
     config SOC_K3_AM642
       bool "TI's K3 based AM642 SoC Family Support"
+    select BINMAN if TARGET_AM642_A53_EVM
     endchoice
   diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk

index da458bcfb2..d2c490818a 100644

arch/arm/mach-k3/config.mk +4 -0
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE
   INPUTS-y    += tiboot3.bin
   endif
   +ifndef CONFIG_BINMAN
   ifdef CONFIG_ARM64
     ifeq ($(CONFIG_SOC_K3_J721E),)
@@ -77,9 +78,11 @@ cmd_k3_mkits = \
   $(SPL_ITS): FORCE
       $(call cmd,k3_mkits)
   endif
+endif
     else
   +ifndef CONFIG_BINMAN
   ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
   INPUTS-y    += u-boot.img_HS
   else
@@ -87,4 +90,8 @@ INPUTS-y    += u-boot.img
   endif
   endif
   +endif
+
+ifndef CONFIG_BINMAN
   include $(srctree)/arch/arm/mach-k3/config_secure.mk
+endif
#10 lore raw
Quoted 85 lines · Andrew Davis
Quoted 84 lines · Roger Quadros

Hi Andrew,

Quoted 80 lines · Andrew Davis
Quoted 64 lines · Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
   arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++ arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 + arch/arm/mach-k3/Kconfig              |   1 + arch/arm/mach-k3/config.mk            |   7 +

   4 files changed, 241 insertions(+)

   create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi

arch/arm/dts/k3-am642-evm-binman.dtsi new file +41 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+    binman: binman {
+        multiple-images;
+    };
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+    ti-spl {
+        filename = TISPL;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "Configuration to load ATF and SPL";
+            #address-cells = <1>;
+
+            images {
+
+                atf {

arch/arm/dts/k3-am642-evm-binman.dtsi line 51

Quoted 10 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +10 -0
+                    description = "ARM Trusted Firmware";
+                    type = "firmware";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "arm-trusted-firmware";
+                    load = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    entry = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    atf-bl31 {
+                        filename = "bl31.bin";
+                    };

On HS, bl31.bin and the below TEE and DM images must also be signed before being packaged into tispl.bin.
Can we add signing here?

Quoted 8 lines
Quoted 2 lines

I'm wondering how this is working as is on HS boards.

Today we manually sign those two before we feed them to U-Boot build. I'd like to fix that and have them signed along with all the other parts here when packaging them together.

OK. Then this is new feature. Do you mind if I make a separate patch for it? But first I need to figure out what to do ;)

Quoted 6 lines
Quoted 6 lines

Another thing to note is that the atf and tee entries take into consideration the below environment variables
                 -a atf-bl31-path=${BL31} \
                 -a tee-os-path=${TEE} \

Quoted 8 lines
Quoted 2 lines

How do we continue to support that while adding the signing bits?

That's my question also, I'm not sure how we would make the type 'ti-secure' while also changing their path names, seems like a limitation currently of using etypes to do the signing, since we can do path renames from command line.

Simon,

Any thoughts on how to get the new ti-secure etype work with atf-bl31 and tee-os etypes so that it can take the data output of those entries and create a signed binary with filenames from those entries or atf-bl31-path and tee-os-path?

Can something like this work?

	ti-secure {
		atf-bl31 {
			filename = "bl31.bin";
		};
	}

We could probably get rid of filename property from ti-secure etype and use blob for regular files.

	ti-secure {
		blob {
			filename = "somefile.ext";
		}
	}

cheers,
-roger

Quoted 240 lines

Andrew

Quoted 236 lines

cheers,
-roger

Quoted 233 lines

Andrew

Quoted 229 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +179 -0
+                };
+
+                tee {
+                    description = "OPTEE";
+                    type = "tee";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "tee";
+                    load = <0x9e800000>;
+                    entry = <0x9e800000>;
+                    tee-os {
+                        filename = "tee-pager_v2.bin";
+                    };
+                };
+
+                dm {
+                    description = "DM binary";
+                    type = "firmware";
+                    arch = "arm32";
+                    compression = "none";
+                    os = "DM";
+                    load = <0x89000000>;
+                    entry = <0x89000000>;
+                    blob-ext {
+                        filename = "/dev/null";
+                    };
+                };
+
+                spl {
+                    description = "SPL (64-bit)";
+                    type = "standalone";
+                    os = "U-Boot";
+                    arch = "arm64";
+                    compression = "none";
+                    load = <0x80080000>;
+                    entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_NODTB;
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_EVM_DTB;
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_SK_DTB;
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+
+&binman {
+    u-boot {
+        filename = UBOOT_IMG;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "FIT image with multiple configurations";
+
+            images {
+                uboot {
+                    description = "U-Boot for am64x board";
+                    type = "firmware";
+                    os = "u-boot";
+                    arch = "arm";
+                    compression = "none";
+                    load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = UBOOT_NODTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_EVM_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_SK_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
    /*
     * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
     */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
      / {
        chosen {
arch/arm/mach-k3/Kconfig +0 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2

     config SOC_K3_AM642
       bool "TI's K3 based AM642 SoC Family Support"
+    select BINMAN if TARGET_AM642_A53_EVM
     endchoice
   diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk index da458bcfb2..d2c490818a 100644

arch/arm/mach-k3/config.mk +0 -0
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE

   INPUTS-y    += tiboot3.bin
   endif
   +ifndef CONFIG_BINMAN
   ifdef CONFIG_ARM64
     ifeq ($(CONFIG_SOC_K3_J721E),)

arch/arm/mach-k3/config.mk +0 -0
@@ -77,9 +78,11 @@ cmd_k3_mkits = \

   $(SPL_ITS): FORCE
       $(call cmd,k3_mkits)
   endif
+endif
     else
   +ifndef CONFIG_BINMAN
   ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
   INPUTS-y    += u-boot.img_HS
   else

arch/arm/mach-k3/config.mk +0 -0
@@ -87,4 +90,8 @@ INPUTS-y    += u-boot.img

   endif
   endif
   +endif

arch/arm/mach-k3/config.mk +2 -0
+
+ifndef CONFIG_BINMAN

   include $(srctree)/arch/arm/mach-k3/config_secure.mk +endif

#11 lore raw
Quoted 128 lines · Roger Quadros
Quoted 85 lines · Andrew Davis
Quoted 84 lines · Roger Quadros

Hi Andrew,

Quoted 80 lines · Andrew Davis
Quoted 64 lines · Roger Quadros

Introduce k3-am642-evm-binman.dtsi to provide binman configuration.

R5 build is still not converted to use binman so restrict binman.dtsi to A53 builds only.

This patch also take care of building Secure (HS) images using binman instead of tools/k3_fit_atf.sh if CONFIG_BINMAN is set.

---
   arch/arm/dts/k3-am642-evm-binman.dtsi | 230 ++++++++++++++++++++++++++ arch/arm/dts/k3-am642-evm-u-boot.dtsi |   3 + arch/arm/mach-k3/Kconfig              |   1 + arch/arm/mach-k3/config.mk            |   7 +

   4 files changed, 241 insertions(+)

   create mode 100644 arch/arm/dts/k3-am642-evm-binman.dtsi

arch/arm/dts/k3-am642-evm-binman.dtsi new file +41 -0
new file mode 100644
index 0000000000..9e85ef41b0
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+    binman: binman {
+        multiple-images;
+    };
+};
+
+#ifdef CONFIG_TARGET_AM642_A53_EVM
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+#define TISPL "tispl.bin_HS"
+#define UBOOT_IMG "u-boot.img_HS"
+#else
+#define TISPL "tispl.bin"
+#define UBOOT_IMG "u-boot.img"
+#endif
+
+#define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
+#define SPL_AM642_EVM_DTB "spl/dts/k3-am642-evm.dtb"
+#define SPL_AM642_SK_DTB "spl/dts/k3-am642-sk.dtb"
+
+#define UBOOT_NODTB "u-boot-nodtb.bin"
+#define AM642_EVM_DTB "arch/arm/dts/k3-am642-evm.dtb"
+#define AM642_SK_DTB "arch/arm/dts/k3-am642-sk.dtb"
+
+&binman {
+    ti-spl {
+        filename = TISPL;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "Configuration to load ATF and SPL";
+            #address-cells = <1>;
+
+            images {
+
+                atf {

arch/arm/dts/k3-am642-evm-binman.dtsi line 51

Quoted 10 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +10 -0
+                    description = "ARM Trusted Firmware";
+                    type = "firmware";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "arm-trusted-firmware";
+                    load = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    entry = <CONFIG_K3_ATF_LOAD_ADDR>;
+                    atf-bl31 {
+                        filename = "bl31.bin";
+                    };

On HS, bl31.bin and the below TEE and DM images must also be signed before being packaged into tispl.bin.
Can we add signing here?

Quoted 8 lines
Quoted 2 lines

I'm wondering how this is working as is on HS boards.

Today we manually sign those two before we feed them to U-Boot build. I'd like to fix that and have them signed along with all the other parts here when packaging them together.

OK. Then this is new feature. Do you mind if I make a separate patch for it? But first I need to figure out what to do ;)

Quoted 6 lines
Quoted 6 lines

Another thing to note is that the atf and tee entries take into consideration the below environment variables
                 -a atf-bl31-path=${BL31} \
                 -a tee-os-path=${TEE} \

Quoted 8 lines
Quoted 2 lines

How do we continue to support that while adding the signing bits?

That's my question also, I'm not sure how we would make the type 'ti-secure' while also changing their path names, seems like a limitation currently of using etypes to do the signing, since we can do path renames from command line.

Simon,

Any thoughts on how to get the new ti-secure etype work with atf-bl31 and tee-os etypes so that it can take the data output of those entries and create a signed binary with filenames from those entries or atf-bl31-path and tee-os-path?

Can something like this work?

	ti-secure {
		atf-bl31 {
			filename = "bl31.bin";
		};
	}
Quoted 8 lines

We could probably get rid of filename property from ti-secure etype and use blob for regular files.

	ti-secure {
		blob {
			filename = "somefile.ext";
		}
	}

Adding in Alper as well..

Quoted 244 lines

cheers,
-roger

Quoted 240 lines

Andrew

Quoted 236 lines

cheers,
-roger

Quoted 233 lines

Andrew

Quoted 229 lines
arch/arm/dts/k3-am642-evm-binman.dtsi new file +179 -0
+                };
+
+                tee {
+                    description = "OPTEE";
+                    type = "tee";
+                    arch = "arm64";
+                    compression = "none";
+                    os = "tee";
+                    load = <0x9e800000>;
+                    entry = <0x9e800000>;
+                    tee-os {
+                        filename = "tee-pager_v2.bin";
+                    };
+                };
+
+                dm {
+                    description = "DM binary";
+                    type = "firmware";
+                    arch = "arm32";
+                    compression = "none";
+                    os = "DM";
+                    load = <0x89000000>;
+                    entry = <0x89000000>;
+                    blob-ext {
+                        filename = "/dev/null";
+                    };
+                };
+
+                spl {
+                    description = "SPL (64-bit)";
+                    type = "standalone";
+                    os = "U-Boot";
+                    arch = "arm64";
+                    compression = "none";
+                    load = <0x80080000>;
+                    entry = <0x80080000>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_NODTB;
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_EVM_DTB;
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = SPL_AM642_SK_DTB;
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "atf";
+                    loadables = "tee", "dm", "spl";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+
+&binman {
+    u-boot {
+        filename = UBOOT_IMG;
+        pad-byte = <0xff>;
+
+        fit {
+            description = "FIT image with multiple configurations";
+
+            images {
+                uboot {
+                    description = "U-Boot for am64x board";
+                    type = "firmware";
+                    os = "u-boot";
+                    arch = "arm";
+                    compression = "none";
+                    load = <CONFIG_SYS_TEXT_BASE>;
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = UBOOT_NODTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-1 {
+                    description = "k3-am642-evm";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_EVM_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+
+                fdt-2 {
+                    description = "k3-am642-sk";
+                    type = "flat_dt";
+                    arch = "arm";
+                    compression = "none";
+#ifdef CONFIG_TI_SECURE_DEVICE
+                    ti-secure {
+#else
+                    blob {
+#endif
+                        filename = AM642_SK_DTB;
+                    };
+                    hash {
+                        algo = "crc32";
+                    };
+                };
+            };
+
+            configurations {
+                default = "conf-1";
+
+                conf-1 {
+                    description = "k3-am642-evm";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-1";
+                };
+
+                conf-2 {
+                    description = "k3-am642-sk";
+                    firmware = "uboot";
+                    loadables = "uboot";
+                    fdt = "fdt-2";
+                };
+            };
+        };
+    };
+};
+#endif
arch/arm/dts/k3-am642-evm-u-boot.dtsi +3 -0
index 03688a51a3..db0a529f0f 100644
@@ -2,6 +2,9 @@
    /*
     * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
     */
+#include <config.h>
+
+#include "k3-am642-evm-binman.dtsi"
      / {
        chosen {
arch/arm/mach-k3/Kconfig +0 -0
index a01bf23514..a4c561254d 100644
@@ -15,6 +15,7 @@ config SOC_K3_J721S2

     config SOC_K3_AM642
       bool "TI's K3 based AM642 SoC Family Support"
+    select BINMAN if TARGET_AM642_A53_EVM
     endchoice
   diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk index da458bcfb2..d2c490818a 100644

arch/arm/mach-k3/config.mk +0 -0
@@ -47,6 +47,7 @@ tiboot3.bin: image_check FORCE

   INPUTS-y    += tiboot3.bin
   endif
   +ifndef CONFIG_BINMAN
   ifdef CONFIG_ARM64
     ifeq ($(CONFIG_SOC_K3_J721E),)

arch/arm/mach-k3/config.mk +0 -0
@@ -77,9 +78,11 @@ cmd_k3_mkits = \

   $(SPL_ITS): FORCE
       $(call cmd,k3_mkits)
   endif
+endif
     else
   +ifndef CONFIG_BINMAN
   ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
   INPUTS-y    += u-boot.img_HS
   else

arch/arm/mach-k3/config.mk +0 -0
@@ -87,4 +90,8 @@ INPUTS-y    += u-boot.img

   endif
   endif
   +endif

arch/arm/mach-k3/config.mk +2 -0
+
+ifndef CONFIG_BINMAN

   include $(srctree)/arch/arm/mach-k3/config_secure.mk +endif

Signature · 1 line
Tom
#12 lore raw
Quoted 14 lines · Tom Rini
Quoted 13 lines · Roger Quadros

Any thoughts on how to get the new ti-secure etype work with atf-bl31 and tee-os etypes so that it can take the data output of those entries and create a signed binary with filenames from those entries or atf-bl31-path and tee-os-path?

Can something like this work?

	ti-secure {
		atf-bl31 {
			filename = "bl31.bin";
		};
	}
Quoted 8 lines
Quoted 8 lines

We could probably get rid of filename property from ti-secure etype and use blob for regular files.

	ti-secure {
		blob {
			filename = "somefile.ext";
		}
	}

This would definitely work, see etype/mkimage.py for example. I'd prefer to know the file-format details (and maybe replicate them in binman) if you could afford to publish them, though...

Sorry I couldn't look at either series yet, but I see mentions of k3_fit_atf.sh, so let me point out another series [1][2] that might also interest you:

[1] [RESEND, RFC 0/8] Integration of sysfw and tispl with U-Boot
https://lore.kernel.org/u-boot/[email protected]/

[2] [PATCH RFC v2 00/11] Integration of sysfw, tispl and tiboot3
https://lore.kernel.org/u-boot/[email protected]/

Quoted 3 lines

Adding in Alper as well..

#13 lore raw

Hi,

Quoted 24 lines · Alper Nebi Yasak
Quoted 14 lines · Tom Rini
Quoted 13 lines · Roger Quadros

Any thoughts on how to get the new ti-secure etype work with atf-bl31 and tee-os etypes so that it can take the data output of those entries and create a signed binary with filenames from those entries or atf-bl31-path and tee-os-path?

Can something like this work?

	ti-secure {
		atf-bl31 {
			filename = "bl31.bin";
		};
	}
Quoted 8 lines
Quoted 8 lines

We could probably get rid of filename property from ti-secure etype and use blob for regular files.

	ti-secure {
		blob {
			filename = "somefile.ext";
		}
	}
Quoted 3 lines

This would definitely work, see etype/mkimage.py for example. I'd prefer to know the file-format details (and maybe replicate them in binman) if you could afford to publish them, though...

This is a question to Nishanth/Andrew.

Quoted 11 lines

Sorry I couldn't look at either series yet, but I see mentions of k3_fit_atf.sh, so let me point out another series [1][2] that might also interest you:

[1] [RESEND, RFC 0/8] Integration of sysfw and tispl with U-Boot
https://lore.kernel.org/u-boot/[email protected]/

[2] [PATCH RFC v2 00/11] Integration of sysfw, tispl and tiboot3
https://lore.kernel.org/u-boot/[email protected]/

Thanks for this pointer. I will review those patches and see how we can consolidate.

cheers,
-roger

#14 lore raw
Quoted 27 lines · Roger Quadros

Hi,

Quoted 24 lines · Alper Nebi Yasak
Quoted 22 lines · Tom Rini
Quoted 21 lines · Roger Quadros

Any thoughts on how to get the new ti-secure etype work with atf-bl31 and tee-os etypes so that it can take the data output of those entries and create a signed binary with filenames from those entries or atf-bl31-path and tee-os-path?

Can something like this work?

	ti-secure {
		atf-bl31 {
			filename = "bl31.bin";
		};
	}

We could probably get rid of filename property from ti-secure etype and use blob for regular files.

	ti-secure {
		blob {
			filename = "somefile.ext";
		}
	}
Quoted 6 lines
Quoted 3 lines

This would definitely work, see etype/mkimage.py for example. I'd prefer to know the file-format details (and maybe replicate them in binman) if you could afford to publish them, though...

This is a question to Nishanth/Andrew.

What file format are we talking about here? If it is the signed format, it's an attached x509 certificate, that is already published [0] and the tools to make it are public [1].

There is also an effort to replicate some of this in binman too [2].

Thanks,
Andrew

[0] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/security/sec_cert_format.html
[1] https://git.ti.com/cgit/security-development-tools/core-secdev-k3
[2] https://lore.kernel.org/all/20220510200511.GK3901321@bill-the-cat/T/

Quoted 17 lines
Quoted 11 lines

Sorry I couldn't look at either series yet, but I see mentions of k3_fit_atf.sh, so let me point out another series [1][2] that might also interest you:

[1] [RESEND, RFC 0/8] Integration of sysfw and tispl with U-Boot
https://lore.kernel.org/u-boot/[email protected]/

[2] [PATCH RFC v2 00/11] Integration of sysfw, tispl and tiboot3
https://lore.kernel.org/u-boot/[email protected]/

Thanks for this pointer. I will review those patches and see how we can consolidate.

cheers,
-roger

#15 lore raw
Quoted 11 lines · Andrew Davis
Quoted 6 lines · Roger Quadros
Quoted 3 lines · Alper Nebi Yasak

This would definitely work, see etype/mkimage.py for example. I'd prefer to know the file-format details (and maybe replicate them in binman) if you could afford to publish them, though...

This is a question to Nishanth/Andrew.

What file format are we talking about here? If it is the signed format, it's an attached x509 certificate, that is already published [0] and the tools to make it are public [1].

Thanks, I meant this. I saw 'secure-binary-image.sh' in the first patch, which lead me to 'doc/README.ti-secure', which mentions NDA and logins, so I stopped looking there.

Quoted 8 lines

There is also an effort to replicate some of this in binman too [2].

Thanks,
Andrew

[0] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/security/sec_cert_format.html
[1] https://git.ti.com/cgit/security-development-tools/core-secdev-k3
[2] https://lore.kernel.org/all/20220510200511.GK3901321@bill-the-cat/T/

#4 lore raw

Re: [u-boot PATCH 2/3] tools/fdtgrep: Include __symbols__ table

Quoted 8 lines · Tom Rini
Quoted 3 lines · Roger Quadros

This is required for overlays to work at SPL.

This breaks booting my dra7xx_evm and I get no output in SPL.

Thanks for checking. I'll try to debug what's wrong using beagle_x15. Is SPL size increase to blame?

Maybe we should enable this only based on some config symbol?

cheers,
-roger

#5 lore raw

Re: [u-boot PATCH 2/3] tools/fdtgrep: Include __symbols__ table

Quoted 7 lines · Roger Quadros
Quoted 6 lines · Tom Rini
Quoted 3 lines · Roger Quadros

This is required for overlays to work at SPL.

Quoted 7 lines
Quoted 2 lines

This breaks booting my dra7xx_evm and I get no output in SPL.

Thanks for checking. I'll try to debug what's wrong using beagle_x15. Is SPL size increase to blame?

Maybe we should enable this only based on some config symbol?

We're likely running out of memory space in one way or another, yes. So making this opt-in when needed rather than default is probably best.

Signature · 1 line
Tom