Add buildroot external packages repository
Adds external packages repository for buildroot containing:
* Packing for optee_client, optee_examples, optee_test and optee_benchmark
* Configs and a script to assembly defconfigs needed for buildroot
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/br-ext/Config.in b/br-ext/Config.in
new file mode 100644
index 0000000..52f2a62
--- /dev/null
+++ b/br-ext/Config.in
@@ -0,0 +1,4 @@
+source "$BR2_EXTERNAL_OPTEE_PATH/package/optee_client/Config.in"
+source "$BR2_EXTERNAL_OPTEE_PATH/package/optee_test/Config.in"
+source "$BR2_EXTERNAL_OPTEE_PATH/package/optee_examples/Config.in"
+source "$BR2_EXTERNAL_OPTEE_PATH/package/optee_benchmark/Config.in"
diff --git a/br-ext/configs/optee_aarch32 b/br-ext/configs/optee_aarch32
new file mode 100644
index 0000000..a7f8886
--- /dev/null
+++ b/br-ext/configs/optee_aarch32
@@ -0,0 +1,5 @@
+# Architecture
+BR2_arm=y
+BR2_cortex_a15=y
+BR2_ARM_FPU_VFPV3D16=y
+BR2_ARM_INSTRUCTIONS_THUMB2=y
diff --git a/br-ext/configs/optee_aarch64 b/br-ext/configs/optee_aarch64
new file mode 100644
index 0000000..d740c58
--- /dev/null
+++ b/br-ext/configs/optee_aarch64
@@ -0,0 +1,2 @@
+# Architecture
+BR2_aarch64=y
diff --git a/br-ext/configs/optee_examples b/br-ext/configs/optee_examples
new file mode 100644
index 0000000..5d10dd8
--- /dev/null
+++ b/br-ext/configs/optee_examples
@@ -0,0 +1 @@
+BR2_PACKAGE_OPTEE_EXAMPLES=y
diff --git a/br-ext/configs/optee_generic b/br-ext/configs/optee_generic
new file mode 100644
index 0000000..d56b5c9
--- /dev/null
+++ b/br-ext/configs/optee_generic
@@ -0,0 +1,7 @@
+BR2_CCACHE=y
+BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot, type root to login"
+
+BR2_TARGET_ROOTFS_CPIO=y
+BR2_TARGET_ROOTFS_CPIO_GZIP=y
+BR2_PACKAGE_HOST_E2FSPROGS=y
+BR2_PACKAGE_OPTEE_CLIENT=y
diff --git a/br-ext/configs/optee_test b/br-ext/configs/optee_test
new file mode 100644
index 0000000..cb14791
--- /dev/null
+++ b/br-ext/configs/optee_test
@@ -0,0 +1 @@
+BR2_PACKAGE_OPTEE_TEST=y
diff --git a/br-ext/configs/toolchain-aarch32 b/br-ext/configs/toolchain-aarch32
new file mode 100644
index 0000000..95fbfcf
--- /dev/null
+++ b/br-ext/configs/toolchain-aarch32
@@ -0,0 +1,9 @@
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
+BR2_TOOLCHAIN_EXTERNAL_PATH="%TOP_DIR%/toolchains/aarch32"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-linux-gnueabihf"
+BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+
diff --git a/br-ext/configs/toolchain-aarch64 b/br-ext/configs/toolchain-aarch64
new file mode 100644
index 0000000..24906be
--- /dev/null
+++ b/br-ext/configs/toolchain-aarch64
@@ -0,0 +1,9 @@
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
+BR2_TOOLCHAIN_EXTERNAL_PATH="%TOP_DIR%/toolchains/aarch64"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="aarch64-linux-gnu"
+BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+
diff --git a/br-ext/external.desc b/br-ext/external.desc
new file mode 100644
index 0000000..02582f5
--- /dev/null
+++ b/br-ext/external.desc
@@ -0,0 +1,2 @@
+name: OPTEE
+desc: OP-TEE br2-external tree
diff --git a/br-ext/external.mk b/br-ext/external.mk
new file mode 100644
index 0000000..fcf49b2
--- /dev/null
+++ b/br-ext/external.mk
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_OPTEE_PATH)/package/*/*.mk))
diff --git a/br-ext/package/optee_benchmark/Config.in b/br-ext/package/optee_benchmark/Config.in
new file mode 100644
index 0000000..5928d5a
--- /dev/null
+++ b/br-ext/package/optee_benchmark/Config.in
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_OPTEE_BENCHMARK
+ bool "optee_benchmark"
+ select BR2_PACKAGE_LIBYAML
+ help
+ http://github.org/OP-TEE/optee_benchmark
+
+if BR2_PACKAGE_OPTEE_BENCHMARK
+config BR2_PACKAGE_OPTEE_BENCHMARK_SITE
+ string "OP-TEE benchmark path"
+ default ""
+ help
+ The path to the source directory of OP-TEE benchmark
+endif
diff --git a/br-ext/package/optee_benchmark/optee_benchmark.mk b/br-ext/package/optee_benchmark/optee_benchmark.mk
new file mode 100644
index 0000000..6763489
--- /dev/null
+++ b/br-ext/package/optee_benchmark/optee_benchmark.mk
@@ -0,0 +1,8 @@
+OPTEE_BENCHMARK_VERSION = 1.0
+OPTEE_BENCHMARK_SOURCE = local
+OPTEE_BENCHMARK_SITE = $(BR2_PACKAGE_OPTEE_BENCHMARK_SITE)
+OPTEE_BENCHMARK_SITE_METHOD = local
+OPTEE_BENCHMARK_INSTALL_STAGING = YES
+OPTEE_BENCHMARK_DEPENDENCIES = optee_client libyaml
+
+$(eval $(cmake-package))
diff --git a/br-ext/package/optee_client/Config.in b/br-ext/package/optee_client/Config.in
new file mode 100644
index 0000000..435b6ee
--- /dev/null
+++ b/br-ext/package/optee_client/Config.in
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_OPTEE_CLIENT
+ bool "optee_client"
+ help
+ http://github.org/OP-TEE/optee_client
+
+if BR2_PACKAGE_OPTEE_CLIENT
+config BR2_PACKAGE_OPTEE_CLIENT_SITE
+ string "OP-TEE client path"
+ default ""
+ help
+ The path to the source directory of OP-TEE client
+endif
diff --git a/br-ext/package/optee_client/S30optee b/br-ext/package/optee_client/S30optee
new file mode 100755
index 0000000..c893243
--- /dev/null
+++ b/br-ext/package/optee_client/S30optee
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# /etc/init.d/optee
+#
+# Start/stop tee-supplicant (OP-TEE normal world daemon)
+#
+case "$1" in
+ start)
+ if [ -e /usr/sbin/tee-supplicant -a -e /dev/teepriv0 ]; then
+ echo "Starting tee-supplicant..."
+ /usr/sbin/tee-supplicant &
+ exit 0
+ else
+ echo "tee-supplicant or TEE device not found"
+ exit 1
+ fi
+
+ ;;
+ stop)
+ killall tee-supplicant
+ ;;
+ status)
+ cat /dev/teepriv0 2>&1 | grep -q "Device or resource busy" || not="not "
+ echo "tee-supplicant is ${not}active"
+ ;;
+esac
diff --git a/br-ext/package/optee_client/optee_client.mk b/br-ext/package/optee_client/optee_client.mk
new file mode 100644
index 0000000..0b38010
--- /dev/null
+++ b/br-ext/package/optee_client/optee_client.mk
@@ -0,0 +1,16 @@
+OPTEE_CLIENT_VERSION = 1.0
+OPTEE_CLIENT_SOURCE = local
+OPTEE_CLIENT_SITE = $(BR2_PACKAGE_OPTEE_CLIENT_SITE)
+OPTEE_CLIENT_SITE_METHOD = local
+OPTEE_CLIENT_INSTALL_STAGING = YES
+
+define OPTEE_CLIENT_INSTALL_SUPPLICANT_SCRIPT
+ $(INSTALL) -m 0755 -D $(OPTEE_CLIENT_PKGDIR)/S30optee \
+ $(TARGET_DIR)/etc/init.d/S30optee
+endef
+
+define OPTEE_CLIENT_INSTALL_INIT_SYSV
+ $(OPTEE_CLIENT_INSTALL_SUPPLICANT_SCRIPT)
+endef
+
+$(eval $(cmake-package))
diff --git a/br-ext/package/optee_examples/Config.in b/br-ext/package/optee_examples/Config.in
new file mode 100644
index 0000000..cd7e3fc
--- /dev/null
+++ b/br-ext/package/optee_examples/Config.in
@@ -0,0 +1,26 @@
+config BR2_PACKAGE_OPTEE_EXAMPLES
+ bool "optee_examples"
+ help
+ http://github.org/OP-TEE/optee_examples
+
+if BR2_PACKAGE_OPTEE_EXAMPLES
+
+config BR2_PACKAGE_OPTEE_EXAMPLES_SITE
+ string "OP-TEE examples path"
+ default ""
+ help
+ The path to the source directory of OP-TEE examples
+
+config BR2_PACKAGE_OPTEE_EXAMPLES_SDK
+ string "OPTEE SDK path"
+ default ""
+ help
+ some help
+
+config BR2_PACKAGE_OPTEE_EXAMPLES_CROSS_COMPILE
+ string "OPTEE cross compiler"
+ default ""
+ help
+ some help
+
+endif
diff --git a/br-ext/package/optee_examples/optee_examples.mk b/br-ext/package/optee_examples/optee_examples.mk
new file mode 100644
index 0000000..dd6491d
--- /dev/null
+++ b/br-ext/package/optee_examples/optee_examples.mk
@@ -0,0 +1,28 @@
+OPTEE_EXAMPLES_VERSION = 1.0
+OPTEE_EXAMPLES_SOURCE = local
+OPTEE_EXAMPLES_SITE = $(BR2_PACKAGE_OPTEE_EXAMPLES_SITE)
+OPTEE_EXAMPLES_SITE_METHOD = local
+OPTEE_EXAMPLES_INSTALL_STAGING = YES
+OPTEE_EXAMPLES_DEPENDENCIES = optee_client
+OPTEE_EXAMPLES_SDK = $(BR2_PACKAGE_OPTEE_EXAMPLES_SDK)
+OPTEE_EXAMPLES_CONF_OPTS = -DOPTEE_EXAMPLES_SDK=$(OPTEE_EXAMPLES_SDK)
+
+define OPTEE_EXAMPLES_BUILD_TAS
+ @$(foreach f,$(wildcard $(@D)/*/ta/Makefile), \
+ $(MAKE) CROSS_COMPILE="$(shell echo $(BR2_PACKAGE_OPTEE_EXAMPLES_CROSS_COMPILE))" \
+ O=out TA_DEV_KIT_DIR=$(OPTEE_EXAMPLES_SDK) V=1 \
+ $(TARGET_CONFIGURE_OPTS) -C $(dir $f) all &&) true
+endef
+
+define OPTEE_EXAMPLES_INSTALL_TAS
+ @$(foreach f,$(wildcard $(@D)/*/ta/out/*.ta), \
+ mkdir -p $(TARGET_DIR)/lib/optee_armtz && \
+ $(INSTALL) -v -p --mode=444 \
+ --target-directory=$(TARGET_DIR)/lib/optee_armtz $f \
+ &&) true
+endef
+
+OPTEE_EXAMPLES_POST_BUILD_HOOKS += OPTEE_EXAMPLES_BUILD_TAS
+OPTEE_EXAMPLES_POST_INSTALL_TARGET_HOOKS += OPTEE_EXAMPLES_INSTALL_TAS
+
+$(eval $(cmake-package))
diff --git a/br-ext/package/optee_test/Config.in b/br-ext/package/optee_test/Config.in
new file mode 100644
index 0000000..8a435d1
--- /dev/null
+++ b/br-ext/package/optee_test/Config.in
@@ -0,0 +1,27 @@
+config BR2_PACKAGE_OPTEE_TEST
+ bool "optee_test"
+ select BR2_PACKAGE_OPTEE_CLIENT
+ help
+ http://github.org/OP-TEE/optee_test
+
+if BR2_PACKAGE_OPTEE_TEST
+
+config BR2_PACKAGE_OPTEE_TEST_SITE
+ string "OP-TEE test path"
+ default ""
+ help
+ The path to the source directory of OP-TEE test
+
+config BR2_PACKAGE_OPTEE_TEST_SDK
+ string "OPTEE SDK path"
+ default ""
+ help
+ some help
+
+config BR2_PACKAGE_OPTEE_TEST_CROSS_COMPILE
+ string "OPTEE cross compiler"
+ default ""
+ help
+ some help
+
+endif
diff --git a/br-ext/package/optee_test/optee_test.mk b/br-ext/package/optee_test/optee_test.mk
new file mode 100644
index 0000000..797f6ac
--- /dev/null
+++ b/br-ext/package/optee_test/optee_test.mk
@@ -0,0 +1,28 @@
+OPTEE_TEST_VERSION = 1.0
+OPTEE_TEST_SOURCE = local
+OPTEE_TEST_SITE = $(BR2_PACKAGE_OPTEE_TEST_SITE)
+OPTEE_TEST_SITE_METHOD = local
+OPTEE_TEST_INSTALL_STAGING = YES
+OPTEE_TEST_DEPENDENCIES = optee_client
+OPTEE_TEST_SDK = $(BR2_PACKAGE_OPTEE_TEST_SDK)
+OPTEE_TEST_CONF_OPTS = -DOPTEE_TEST_SDK=$(OPTEE_TEST_SDK)
+
+define OPTEE_TEST_BUILD_TAS
+ @$(foreach f,$(wildcard $(@D)/ta/*/Makefile), \
+ $(MAKE) CROSS_COMPILE="$(shell echo $(BR2_PACKAGE_OPTEE_TEST_CROSS_COMPILE))" \
+ O=out TA_DEV_KIT_DIR=$(OPTEE_TEST_SDK) \
+ $(TARGET_CONFIGURE_OPTS) -C $(dir $f) all &&) true
+endef
+
+define OPTEE_TEST_INSTALL_TAS
+ @$(foreach f,$(wildcard $(@D)/ta/*/out/*.ta), \
+ mkdir -p $(TARGET_DIR)/lib/optee_armtz && \
+ $(INSTALL) -v -p --mode=444 \
+ --target-directory=$(TARGET_DIR)/lib/optee_armtz $f \
+ &&) true
+endef
+
+OPTEE_TEST_POST_BUILD_HOOKS += OPTEE_TEST_BUILD_TAS
+OPTEE_TEST_POST_INSTALL_TARGET_HOOKS += OPTEE_TEST_INSTALL_TAS
+
+$(eval $(cmake-package))
diff --git a/br-ext/scripts/make_def_config.py b/br-ext/scripts/make_def_config.py
new file mode 100644
index 0000000..be30ec5
--- /dev/null
+++ b/br-ext/scripts/make_def_config.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2018, Linaro Limited
+
+import argparse
+import shutil
+import os
+import re
+
+def get_args():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--br', required=True,
+ help='Path to buildroot tree')
+ parser.add_argument('--out', required=True,
+ help='Path to buildroot out directory')
+ parser.add_argument('--top-dir', required=True,
+ help='Replaces %TOP_DIR% in defconfig files')
+ parser.add_argument('--br-ext-optee', required=True,
+ help='Path the OP-TEE external buildroot tree')
+ parser.add_argument('--br-defconfig', required=True, action='append',
+ help='Buildroot defconfig file')
+ parser.add_argument('--make-cmd', required=True,
+ help='Make command')
+ return parser.parse_args()
+
+def concatenate_files(top_dir, dst, srcs):
+ with open(dst, 'w') as outfile:
+ for fname in srcs:
+ with open(fname) as infile:
+ for line in infile:
+ outfile.write(line.replace('%TOP_DIR%', top_dir))
+
+def main():
+ args = get_args()
+
+ if not os.path.isdir(args.out):
+ os.makedirs(args.out)
+
+ concatenate_files(args.top_dir, args.out + '/defconfig', args.br_defconfig)
+
+ if os.path.isabs(args.out):
+ out = args.out
+ else:
+ out = '../' + args.out
+
+ if os.path.isabs(args.br_ext_optee):
+ br_ext_optee = args.br_ext_optee
+ else:
+ br_ext_optee = '../' + args.br_ext_optee
+
+ os.execlp(args.make_cmd, args.make_cmd, '-C', args.br, 'O=' + out,
+ 'BR2_EXTERNAL=' + br_ext_optee,
+ 'BR2_DEFCONFIG=' + out + '/defconfig', 'defconfig')
+
+if __name__ == "__main__":
+ main()