[v4,07/11] Add recipe include for building custom Trusted Firmware A

Message ID eb45da535c56c349a68a0394c75ea0db533cca5e.1606118039.git.jan.kiszka@siemens.com
State Accepted, archived
Headers show
Series Support for building TF-A and OP-TEE, add STM32MP15x board | expand

Commit Message

Jan Kiszka Nov. 22, 2020, 9:53 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Analogously to U-Boot, this adds an include file to be used in custom
TF-A recipes. The typical customization points are TF_A_PLATFORM and
possibly a couple of TF_A_EXTRA_BUILDARGS. The to-be-packaged binaries
can be defined via TF_A_BINARIES.

Debian has a binary package called "arm-trusted-firmware", targeting a
couple of sunxi boards. We do not follow that legacy naming by intention
and rather use the new official one. Debian will probably follow at some
point.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../trusted-firmware-a/files/debian/compat    |  1 +
 .../files/debian/control.tmpl                 | 10 +++++
 .../trusted-firmware-a/files/debian/rules     | 19 ++++++++
 .../trusted-firmware-a-custom.inc             | 43 +++++++++++++++++++
 4 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-bsp/trusted-firmware-a/files/debian/compat
 create mode 100644 meta/recipes-bsp/trusted-firmware-a/files/debian/control.tmpl
 create mode 100755 meta/recipes-bsp/trusted-firmware-a/files/debian/rules
 create mode 100644 meta/recipes-bsp/trusted-firmware-a/trusted-firmware-a-custom.inc

Patch

diff --git a/meta/recipes-bsp/trusted-firmware-a/files/debian/compat b/meta/recipes-bsp/trusted-firmware-a/files/debian/compat
new file mode 100644
index 00000000..f599e28b
--- /dev/null
+++ b/meta/recipes-bsp/trusted-firmware-a/files/debian/compat
@@ -0,0 +1 @@ 
+10
diff --git a/meta/recipes-bsp/trusted-firmware-a/files/debian/control.tmpl b/meta/recipes-bsp/trusted-firmware-a/files/debian/control.tmpl
new file mode 100644
index 00000000..7ffd189d
--- /dev/null
+++ b/meta/recipes-bsp/trusted-firmware-a/files/debian/control.tmpl
@@ -0,0 +1,10 @@ 
+Source: ${PN}
+Section: admin
+Priority: optional
+Standards-Version: 3.9.6
+Build-Depends: ${DEBIAN_BUILD_DEPENDS}
+Maintainer: ISAR project <isar-users@googlegroups.com>
+
+Package: trusted-firmware-a-${TF_A_NAME}
+Architecture: ${DISTRO_ARCH}
+Description: ${DESCRIPTION}, firmware binaries
diff --git a/meta/recipes-bsp/trusted-firmware-a/files/debian/rules b/meta/recipes-bsp/trusted-firmware-a/files/debian/rules
new file mode 100755
index 00000000..70e1dd66
--- /dev/null
+++ b/meta/recipes-bsp/trusted-firmware-a/files/debian/rules
@@ -0,0 +1,19 @@ 
+#!/usr/bin/make -f
+
+# Debian rules for custom Trusted Firmware A build
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2020
+#
+# SPDX-License-Identifier: MIT
+
+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+endif
+
+override_dh_auto_build:
+	CFLAGS= LDFLAGS= $(MAKE) $(PARALLEL_MAKE) PLAT=$(TF_A_PLATFORM) \
+		$(TF_A_EXTRA_BUILDARGS)
+
+%:
+	dh $@
diff --git a/meta/recipes-bsp/trusted-firmware-a/trusted-firmware-a-custom.inc b/meta/recipes-bsp/trusted-firmware-a/trusted-firmware-a-custom.inc
new file mode 100644
index 00000000..1142bfce
--- /dev/null
+++ b/meta/recipes-bsp/trusted-firmware-a/trusted-firmware-a-custom.inc
@@ -0,0 +1,43 @@ 
+# Custom Trusted Firmware A build
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2020
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg
+
+FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:"
+
+SRC_URI += "file://debian/"
+
+DESCRIPTION ?= "Custom Trusted Firmware A"
+
+TF_A_NAME ?= "${MACHINE}"
+TF_A_PLATFORM ?= "unknown"
+TF_A_EXTRA_BUILDARGS ?= ""
+TF_A_BINARIES ?= "release/bl31.bin"
+
+DEBIAN_BUILD_DEPENDS ?= ""
+
+PROVIDES += "trusted-firmware-a-${TF_A_NAME}"
+
+TEMPLATE_FILES = "debian/control.tmpl"
+TEMPLATE_VARS += "TF_A_NAME DEBIAN_BUILD_DEPENDS"
+
+do_prepare_build() {
+    cp -r ${WORKDIR}/debian ${S}/
+
+    deb_add_changelog
+
+    rm -f ${S}/debian/trusted-firmware-a-${TF_A_NAME}.install
+    for binary in ${TF_A_BINARIES}; do
+        echo "build/${TF_A_PLATFORM}/$binary /usr/lib/trusted-firmware-a/${TF_A_NAME}/" >> \
+            ${S}/debian/trusted-firmware-a-${TF_A_NAME}.install
+    done
+}
+
+dpkg_runbuild_prepend() {
+    export TF_A_PLATFORM="${TF_A_PLATFORM}"
+    export TF_A_EXTRA_BUILDARGS="${TF_A_EXTRA_BUILDARGS}"
+}