mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-02 12:49:03 +00:00
tee/optee_client: Consolidate libteec and optee_supplicant
Merges build file structure so that both libteec and optee_supplicant are under the same nuttx-app directory. This better reflects external source repo structrure (optee_client containing both libteec and tee-supplicant) and avoids a case where build of supplicant was attempted before libteec, leading to a missing .zip file (zip file was only downloaded by libteec, but order of builds was not enforced). Signed-off-by: George Poulios <gpoulios@census-labs.com>
This commit is contained in:
parent
099c8ff58e
commit
f3dc21755f
12 changed files with 175 additions and 345 deletions
|
|
@ -1,53 +0,0 @@
|
||||||
############################################################################
|
|
||||||
# apps/tee/libteec/Makefile
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# Copyright (C) 2023 Xiaomi Corporation
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
include $(APPDIR)/Make.defs
|
|
||||||
|
|
||||||
LIBTEEC_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBTEEC_VERSION)))
|
|
||||||
LIBTEEC_URL ?= "https://github.com/OP-TEE/optee_client/archive/refs/tags"
|
|
||||||
LIBTEEC_ZIP = $(LIBTEEC_VERSION).zip
|
|
||||||
LIBTEEC_UNPACKNAME = optee_client
|
|
||||||
UNPACK ?= unzip -q -o
|
|
||||||
|
|
||||||
CSRCS += optee_client/libteec/src/tee_client_api.c
|
|
||||||
CSRCS += optee_client/libteec/src/teec_trace.c
|
|
||||||
|
|
||||||
$(LIBTEEC_ZIP):
|
|
||||||
@echo "Downloading: $(LIBTEEC_URL)/$(LIBTEEC_ZIP)"
|
|
||||||
$(Q) $(call DOWNLOAD,$(LIBTEEC_URL),$(LIBTEEC_ZIP))
|
|
||||||
|
|
||||||
$(LIBTEEC_UNPACKNAME): $(LIBTEEC_ZIP)
|
|
||||||
@echo "Unpacking: $(LIBTEEC_ZIP) -> $(LIBTEEC_UNPACKNAME)"
|
|
||||||
$(Q) $(UNPACK) $(LIBTEEC_ZIP)
|
|
||||||
$(Q) mv $(LIBTEEC_UNPACKNAME)-$(LIBTEEC_VERSION) $(LIBTEEC_UNPACKNAME)
|
|
||||||
$(Q) echo "Patching $(LIBTEEC_UNPACKNAME)"
|
|
||||||
$(Q) patch -p1 -d $(LIBTEEC_UNPACKNAME) < 0001-libteec-NuttX.patch
|
|
||||||
$(Q) touch $(LIBTEEC_UNPACKNAME)
|
|
||||||
|
|
||||||
ifeq ($(wildcard $(LIBTEEC_UNPACKNAME)/.git),)
|
|
||||||
context:: $(LIBTEEC_UNPACKNAME)
|
|
||||||
|
|
||||||
distclean::
|
|
||||||
$(call DELDIR, $(LIBTEEC_UNPACKNAME))
|
|
||||||
$(call DELFILE, $(LIBTEEC_ZIP))
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
|
||||||
|
|
@ -26,14 +26,17 @@ if(CONFIG_LIBTEEC)
|
||||||
if(NOT EXISTS ${OPTEE_CLIENT_DIR})
|
if(NOT EXISTS ${OPTEE_CLIENT_DIR})
|
||||||
set(OPTEE_CLIENT_URL
|
set(OPTEE_CLIENT_URL
|
||||||
https://github.com/OP-TEE/optee_client/archive/refs/tags)
|
https://github.com/OP-TEE/optee_client/archive/refs/tags)
|
||||||
set(OPTEE_CLIENT_VER ${CONFIG_LIBTEEC_VERSION})
|
set(OPTEE_CLIENT_VER ${CONFIG_OPTEE_CLIENT_VERSION})
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
optee_client_fetch
|
optee_client_fetch
|
||||||
URL ${OPTEE_CLIENT_URL}/${OPTEE_CLIENT_VER}.zip SOURCE_DIR
|
URL ${OPTEE_CLIENT_URL}/${OPTEE_CLIENT_VER}.zip SOURCE_DIR
|
||||||
${OPTEE_CLIENT_DIR} BINARY_DIR
|
${OPTEE_CLIENT_DIR} BINARY_DIR
|
||||||
${CMAKE_BINARY_DIR}/tee/libteec/optee_client
|
${CMAKE_BINARY_DIR}/tee/optee_client/optee_client
|
||||||
PATCH_COMMAND patch -p1 -d ${OPTEE_CLIENT_DIR} <
|
PATCH_COMMAND
|
||||||
${CMAKE_CURRENT_LIST_DIR}/0001-libteec-NuttX.patch
|
patch -p1 -d ${OPTEE_CLIENT_DIR} <
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/0001-libteec-NuttX.patch && patch -p1 -d
|
||||||
|
${OPTEE_CLIENT_DIR} <
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/0002-tee-supplicant-port-to-nuttx.patch
|
||||||
DOWNLOAD_NO_PROGRESS true
|
DOWNLOAD_NO_PROGRESS true
|
||||||
TIMEOUT 30)
|
TIMEOUT 30)
|
||||||
|
|
||||||
|
|
@ -53,8 +56,7 @@ if(CONFIG_LIBTEEC)
|
||||||
|
|
||||||
target_sources(libteec PRIVATE optee_client/libteec/src/tee_client_api.c
|
target_sources(libteec PRIVATE optee_client/libteec/src/tee_client_api.c
|
||||||
optee_client/libteec/src/teec_trace.c)
|
optee_client/libteec/src/teec_trace.c)
|
||||||
target_include_directories(libteec
|
target_include_directories(libteec PUBLIC ${OPTEE_CLIENT_DIR}/libteec/include)
|
||||||
PRIVATE ${OPTEE_CLIENT_DIR}/libteec/include)
|
|
||||||
target_compile_definitions(libteec PUBLIC BINARY_PREFIX=\"TEEC\")
|
target_compile_definitions(libteec PUBLIC BINARY_PREFIX=\"TEEC\")
|
||||||
|
|
||||||
if(CONFIG_DEBUG_INFO)
|
if(CONFIG_DEBUG_INFO)
|
||||||
|
|
@ -68,4 +70,46 @@ if(CONFIG_LIBTEEC)
|
||||||
target_compile_definitions(libteec PUBLIC DEBUGLEVEL=1)
|
target_compile_definitions(libteec PUBLIC DEBUGLEVEL=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
if(CONFIG_OPTEE_SUPPLICANT)
|
||||||
|
|
||||||
|
# Source files for supplicant
|
||||||
|
set(SUPPLICANT_SRCS
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_supplicant.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/handle.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/hmac_sha2.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/sha2.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/sd_notify.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/teec_ta_load.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_supp_fs.c
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/rpmb.c)
|
||||||
|
|
||||||
|
set(SUPPLICANT_DEFS
|
||||||
|
TEEC_LOAD_PATH=\"/bin\" TEE_FS_PARENT_PATH=\"/data/tee\"
|
||||||
|
DEBUGLEVEL_${CONFIG_OPTEE_SUPPLICANT_LOG_LEVEL})
|
||||||
|
|
||||||
|
if(CONFIG_OPTEE_GP_SOCKETS)
|
||||||
|
list(APPEND SUPPLICANT_SRCS
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_socket.c)
|
||||||
|
list(APPEND SUPPLICANT_DEFS CFG_GP_SOCKETS=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add the application
|
||||||
|
nuttx_add_application(
|
||||||
|
NAME
|
||||||
|
${CONFIG_OPTEE_SUPPLICANT_PROGNAME}
|
||||||
|
SRCS
|
||||||
|
${SUPPLICANT_SRCS}
|
||||||
|
INCLUDE_DIRECTORIES
|
||||||
|
${OPTEE_CLIENT_DIR}/tee-supplicant/src
|
||||||
|
DEFINITIONS
|
||||||
|
${SUPPLICANT_DEFS}
|
||||||
|
STACKSIZE
|
||||||
|
${CONFIG_OPTEE_SUPPLICANT_STACKSIZE}
|
||||||
|
PRIORITY
|
||||||
|
${CONFIG_OPTEE_SUPPLICANT_PRIORITY}
|
||||||
|
DEPENDS
|
||||||
|
libteec)
|
||||||
|
|
||||||
|
endif() # CONFIG_OPTEE_SUPPLICANT
|
||||||
|
|
||||||
|
endif() # CONFIG_LIBTEEC
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
############################################################################
|
############################################################################
|
||||||
# apps/tee/libteec/Kconfig
|
# apps/tee/optee_client/Kconfig
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
@ -38,8 +38,39 @@ config LIBTEEC
|
||||||
|
|
||||||
if LIBTEEC
|
if LIBTEEC
|
||||||
|
|
||||||
config LIBTEEC_VERSION
|
config OPTEE_CLIENT_VERSION
|
||||||
string "optee_client version (4.6.0)"
|
string "optee_client version (4.6.0)"
|
||||||
default "4.6.0"
|
default "4.6.0"
|
||||||
|
|
||||||
endif # LIBTEEC
|
endif # LIBTEEC
|
||||||
|
|
||||||
|
config OPTEE_SUPPLICANT
|
||||||
|
bool "OP-TEE supplicant"
|
||||||
|
depends on LIBTEEC
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enable OP-TEE supplicant from https://github.com/OP-TEE/optee_client.
|
||||||
|
|
||||||
|
if OPTEE_SUPPLICANT
|
||||||
|
|
||||||
|
config OPTEE_SUPPLICANT_PROGNAME
|
||||||
|
string "Program name"
|
||||||
|
default "optee_supplicant"
|
||||||
|
---help---
|
||||||
|
This is the name of the program that will be used when the NSH ELF
|
||||||
|
program is installed.
|
||||||
|
|
||||||
|
config OPTEE_SUPPLICANT_PRIORITY
|
||||||
|
int "OP-TEE supplicant task priority"
|
||||||
|
default 100
|
||||||
|
|
||||||
|
config OPTEE_SUPPLICANT_STACKSIZE
|
||||||
|
int "OP-TEE supplicant stack size"
|
||||||
|
default DEFAULT_TASK_STACKSIZE
|
||||||
|
|
||||||
|
config OPTEE_SUPPLICANT_LOG_LEVEL
|
||||||
|
int "Log level for the supplicant (0‑4)"
|
||||||
|
range 0 4
|
||||||
|
default 0
|
||||||
|
|
||||||
|
endif # OPTEE_SUPPLICANT
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
############################################################################
|
############################################################################
|
||||||
# apps/tee/libteec/Make.defs
|
# apps/tee/optee_client/Make.defs
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
# Copyright (C) 2023 Xiaomi Corporation
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
|
|
@ -20,9 +18,9 @@
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_LIBTEEC),)
|
ifneq ($(CONFIG_LIBTEEC),)
|
||||||
CONFIGURED_APPS += $(APPDIR)/tee/libteec
|
CONFIGURED_APPS += $(APPDIR)/tee/optee_client
|
||||||
|
|
||||||
FLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/libteec/optee_client/libteec/include
|
FLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/optee_client/optee_client/libteec/include
|
||||||
FLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\""
|
FLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\""
|
||||||
|
|
||||||
ifneq ($(CONFIG_DEBUG_INFO),)
|
ifneq ($(CONFIG_DEBUG_INFO),)
|
||||||
|
|
@ -40,7 +38,4 @@ AFLAGS += $(FLAGS)
|
||||||
CFLAGS += $(FLAGS)
|
CFLAGS += $(FLAGS)
|
||||||
CXXFLAGS += $(FLAGS)
|
CXXFLAGS += $(FLAGS)
|
||||||
|
|
||||||
DEPPATH += --dep-path libteec
|
|
||||||
VPATH += :libteec
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
88
tee/optee_client/Makefile
Normal file
88
tee/optee_client/Makefile
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
############################################################################
|
||||||
|
# apps/tee/optee_client/Makefile
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
|
||||||
|
OPTEE_CLIENT_VERSION = $(patsubst "%",%,$(strip $(CONFIG_OPTEE_CLIENT_VERSION)))
|
||||||
|
OPTEE_CLIENT_URL ?= "https://github.com/OP-TEE/optee_client/archive/refs/tags"
|
||||||
|
OPTEE_CLIENT_ZIP = $(OPTEE_CLIENT_VERSION).zip
|
||||||
|
OPTEE_CLIENT_UNPACKNAME = optee_client
|
||||||
|
UNPACK ?= unzip -q -o
|
||||||
|
|
||||||
|
DEPPATH += --dep-path $(OPTEE_CLIENT_UNPACKNAME)/libteec/src
|
||||||
|
VPATH += $(OPTEE_CLIENT_UNPACKNAME)/libteec/src
|
||||||
|
|
||||||
|
CSRCS += tee_client_api.c
|
||||||
|
CSRCS += teec_trace.c
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_OPTEE_SUPPLICANT),)
|
||||||
|
DEPPATH += --dep-path $(OPTEE_CLIENT_UNPACKNAME)/tee-supplicant/src
|
||||||
|
VPATH += $(OPTEE_CLIENT_UNPACKNAME)/tee-supplicant/src
|
||||||
|
|
||||||
|
PROGNAME += ${CONFIG_OPTEE_SUPPLICANT_PROGNAME}
|
||||||
|
PRIORITY += $(CONFIG_OPTEE_SUPPLICANT_PRIORITY)
|
||||||
|
STACKSIZE += $(CONFIG_OPTEE_SUPPLICANT_STACKSIZE)
|
||||||
|
MODULE += $(CONFIG_OPTEE_SUPPLICANT)
|
||||||
|
MAINSRC += tee_supplicant.c
|
||||||
|
|
||||||
|
CSRCS += handle.c
|
||||||
|
CSRCS += hmac_sha2.c
|
||||||
|
CSRCS += sha2.c
|
||||||
|
CSRCS += sd_notify.c
|
||||||
|
CSRCS += teec_ta_load.c
|
||||||
|
CSRCS += tee_supp_fs.c
|
||||||
|
CSRCS += rpmb.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_GP_SOCKETS),1)
|
||||||
|
CSRCS += tee_socket.c
|
||||||
|
FLAGS += ${DEFINE_PREFIX}CFG_GP_SOCKETS=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
FLAGS += ${INCDIR_PREFIX}optee_client/tee-supplicant/src
|
||||||
|
FLAGS += ${DEFINE_PREFIX}TEEC_LOAD_PATH=\"/bin\"
|
||||||
|
FLAGS += ${DEFINE_PREFIX}TEE_FS_PARENT_PATH=\"/data/tee\"
|
||||||
|
FLAGS += ${DEFINE_PREFIX}DEBUGLEVEL_$(CONFIG_OPTEE_SUPPLICANT_LOG_LEVEL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
AFLAGS += $(FLAGS)
|
||||||
|
CFLAGS += $(FLAGS)
|
||||||
|
CXXFLAGS += $(FLAGS)
|
||||||
|
|
||||||
|
$(OPTEE_CLIENT_ZIP):
|
||||||
|
@echo "Downloading: $(OPTEE_CLIENT_URL)/$(OPTEE_CLIENT_ZIP)"
|
||||||
|
$(Q) $(call DOWNLOAD,$(OPTEE_CLIENT_URL),$(OPTEE_CLIENT_ZIP))
|
||||||
|
|
||||||
|
$(OPTEE_CLIENT_UNPACKNAME): $(OPTEE_CLIENT_ZIP)
|
||||||
|
@echo "Unpacking: $(OPTEE_CLIENT_ZIP) -> $(OPTEE_CLIENT_UNPACKNAME)"
|
||||||
|
$(Q) $(UNPACK) $(OPTEE_CLIENT_ZIP)
|
||||||
|
$(Q) mv $(OPTEE_CLIENT_UNPACKNAME)-$(OPTEE_CLIENT_VERSION) $(OPTEE_CLIENT_UNPACKNAME)
|
||||||
|
$(Q) echo "Patching $(OPTEE_CLIENT_UNPACKNAME)"
|
||||||
|
$(Q) patch -p1 -d $(OPTEE_CLIENT_UNPACKNAME) < 0001-libteec-NuttX.patch
|
||||||
|
$(Q) patch -p1 -d $(OPTEE_CLIENT_UNPACKNAME) < 0002-tee-supplicant-port-to-nuttx.patch
|
||||||
|
$(Q) touch $(OPTEE_CLIENT_UNPACKNAME)
|
||||||
|
|
||||||
|
ifeq ($(wildcard $(OPTEE_CLIENT_UNPACKNAME)/.git),)
|
||||||
|
context:: $(OPTEE_CLIENT_UNPACKNAME)
|
||||||
|
|
||||||
|
distclean::
|
||||||
|
$(call DELDIR, $(OPTEE_CLIENT_UNPACKNAME))
|
||||||
|
$(call DELFILE, $(OPTEE_CLIENT_ZIP))
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
# ##############################################################################
|
|
||||||
# apps/tee/optee_supplicant/CMakeLists.txt
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# Copyright (C) 2023 Xiaomi Corporation
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
# use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
# the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations under
|
|
||||||
# the License.
|
|
||||||
#
|
|
||||||
# ##############################################################################
|
|
||||||
|
|
||||||
if(CONFIG_OPTEE_SUPPLICANT)
|
|
||||||
|
|
||||||
# Versions must match
|
|
||||||
set(LIBTEEC_VERSION ${CONFIG_LIBTEEC_VERSION})
|
|
||||||
set(OPTEE_SUPPLICANT_VERSION ${CONFIG_OPTEE_SUPPLICANT_VERSION})
|
|
||||||
if(NOT "${OPTEE_SUPPLICANT_VERSION}" STREQUAL "${LIBTEEC_VERSION}")
|
|
||||||
message(
|
|
||||||
FATAL_ERROR
|
|
||||||
"OPTEE supplicant version (${OPTEE_SUPPLICANT_VERSION}) does not match libteec version (${LIBTEEC_VERSION}).\n"
|
|
||||||
"Please set CONFIG_OPTEE_SUPPLICANT_VERSION to ${LIBTEEC_VERSION} in your config."
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Determine paths
|
|
||||||
set(OPTEE_CLIENT_DIR ${CMAKE_CURRENT_LIST_DIR}/optee_client)
|
|
||||||
set(OPTEE_CLIENT_ZIP
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/../libteec/${LIBTEEC_VERSION}.zip)
|
|
||||||
set(PATCH_FILE
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/0001-tee-supplicant-port-to-nuttx.patch)
|
|
||||||
|
|
||||||
# Unpack only if not already present
|
|
||||||
if(NOT EXISTS "${OPTEE_CLIENT_DIR}")
|
|
||||||
message(
|
|
||||||
STATUS
|
|
||||||
"Unpacking OP-TEE client from ${OPTEE_CLIENT_ZIP} to ${OPTEE_CLIENT_DIR}"
|
|
||||||
)
|
|
||||||
# Ensure output dir exists
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/_optee_unpack)
|
|
||||||
# Extract zip
|
|
||||||
file(ARCHIVE_EXTRACT INPUT ${OPTEE_CLIENT_ZIP} OUTPUT_DIR
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/_optee_unpack)
|
|
||||||
# Rename unpacked folder to optee_client
|
|
||||||
file(RENAME
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/_optee_unpack/optee_client-${LIBTEEC_VERSION}
|
|
||||||
${OPTEE_CLIENT_DIR})
|
|
||||||
file(REMOVE_RECURSE ${CMAKE_CURRENT_LIST_DIR}/_optee_unpack)
|
|
||||||
# Apply patch
|
|
||||||
execute_process(
|
|
||||||
COMMAND patch -p1 -d ${OPTEE_CLIENT_DIR} -i ${PATCH_FILE}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
RESULT_VARIABLE patch_result)
|
|
||||||
if(NOT patch_result EQUAL 0)
|
|
||||||
message(
|
|
||||||
FATAL_ERROR
|
|
||||||
"Failed to apply patch ${PATCH_FILE} to optee_client sources.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Source files for supplicant
|
|
||||||
set(SUPPLICANT_SRCS
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_supplicant.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/handle.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/hmac_sha2.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/sha2.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/sd_notify.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/teec_ta_load.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_supp_fs.c
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/rpmb.c)
|
|
||||||
|
|
||||||
if(CONFIG_OPTEE_GP_SOCKETS)
|
|
||||||
list(APPEND SUPPLICANT_SRCS
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src/tee_socket.c)
|
|
||||||
add_compile_definitions(CFG_GP_SOCKETS=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compiler flags
|
|
||||||
set(SUPPLICANT_CFLAGS
|
|
||||||
${INCDIR_PREFIX}${OPTEE_CLIENT_DIR}/tee-supplicant/src
|
|
||||||
${DEFINE_PREFIX}TEEC_LOAD_PATH=\"/bin\"
|
|
||||||
${DEFINE_PREFIX}TEE_FS_PARENT_PATH=\"/data/tee\"
|
|
||||||
${DEFINE_PREFIX}DEBUGLEVEL_${CONFIG_OPTEE_SUPPLICANT_LOG_LEVEL})
|
|
||||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:${SUPPLICANT_CFLAGS}>)
|
|
||||||
|
|
||||||
# Expose public headers for other apps
|
|
||||||
set_property(
|
|
||||||
TARGET nuttx
|
|
||||||
APPEND
|
|
||||||
PROPERTY NUTTX_INCLUDE_DIRECTORIES ${OPTEE_CLIENT_DIR}/libteec/include)
|
|
||||||
|
|
||||||
# Add the application
|
|
||||||
nuttx_add_application(
|
|
||||||
NAME
|
|
||||||
${CONFIG_OPTEE_SUPPLICANT_PROGNAME}
|
|
||||||
SRCS
|
|
||||||
${SUPPLICANT_SRCS}
|
|
||||||
INCLUDES
|
|
||||||
${OPTEE_CLIENT_DIR}/libteec/include
|
|
||||||
${OPTEE_CLIENT_DIR}/tee-supplicant/src
|
|
||||||
STACKSIZE
|
|
||||||
${CONFIG_OPTEE_SUPPLICANT_STACKSIZE}
|
|
||||||
PRIORITY
|
|
||||||
${CONFIG_OPTEE_SUPPLICANT_PRIORITY}
|
|
||||||
REQUIRES
|
|
||||||
libteec)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
############################################################################
|
|
||||||
# apps/tee/optee_supplicant/Kconfig
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# Copyright (C) 2023 Xiaomi Corporation
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT
|
|
||||||
bool "OP-TEE supplicant"
|
|
||||||
depends on LIBTEEC
|
|
||||||
default n
|
|
||||||
---help---
|
|
||||||
Enable OP-TEE supplicant from https://github.com/OP-TEE/optee_client.
|
|
||||||
|
|
||||||
if OPTEE_SUPPLICANT
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT_PROGNAME
|
|
||||||
string "Program name"
|
|
||||||
default "optee_supplicant"
|
|
||||||
---help---
|
|
||||||
This is the name of the program that will be used when the NSH ELF
|
|
||||||
program is installed.
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT_PRIORITY
|
|
||||||
int "OP-TEE supplicant task priority"
|
|
||||||
default 100
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT_STACKSIZE
|
|
||||||
int "OP-TEE supplicant stack size"
|
|
||||||
default DEFAULT_TASK_STACKSIZE
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT_VERSION
|
|
||||||
string "optee_client version (4.6.0)"
|
|
||||||
default "4.6.0"
|
|
||||||
|
|
||||||
config OPTEE_SUPPLICANT_LOG_LEVEL
|
|
||||||
int "Log level for the supplicant (0‑4)"
|
|
||||||
range 0 4
|
|
||||||
default 0
|
|
||||||
endif # OPTEE_SUPPLICANT
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
############################################################################
|
|
||||||
# apps/tee/optee_supplicant/Make.defs
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
|
||||||
# this work for additional information regarding copyright ownership. The
|
|
||||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance with the
|
|
||||||
# License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
ifneq ($(CONFIG_OPTEE_SUPPLICANT),)
|
|
||||||
CONFIGURED_APPS += $(APPDIR)/tee/optee_supplicant
|
|
||||||
endif
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
############################################################################
|
|
||||||
# apps/tee/optee_supplicant/Makefile
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# Copyright (C) 2023 Xiaomi Corporation
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
include $(APPDIR)/Make.defs
|
|
||||||
|
|
||||||
PROGNAME = ${CONFIG_OPTEE_SUPPLICANT_PROGNAME}
|
|
||||||
PRIORITY = $(CONFIG_OPTEE_SUPPLICANT_PRIORITY)
|
|
||||||
STACKSIZE = $(CONFIG_OPTEE_SUPPLICANT_STACKSIZE)
|
|
||||||
MODULE = $(CONFIG_OPTEE_SUPPLICANT)
|
|
||||||
MAINSRC = optee_client/tee-supplicant/src/tee_supplicant.c
|
|
||||||
|
|
||||||
LIBTEEC_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBTEEC_VERSION)))
|
|
||||||
OPTEE_SUPPLICANT_VERSION = $(patsubst "%",%,$(strip $(CONFIG_OPTEE_SUPPLICANT_VERSION)))
|
|
||||||
PATCH_FILE = 0001-tee-supplicant-port-to-nuttx.patch
|
|
||||||
OPTEE_SUPPLICANT_ZIP = ../libteec/$(LIBTEEC_VERSION).zip
|
|
||||||
OPTEE_SUPPLICANT_UNPACKNAME = optee_client
|
|
||||||
UNPACK ?= unzip -q -o
|
|
||||||
|
|
||||||
ifeq ($(strip $(OPTEE_SUPPLICANT_VERSION)),$(strip $(LIBTEEC_VERSION)))
|
|
||||||
# Versions match, continue.
|
|
||||||
else
|
|
||||||
$(error \
|
|
||||||
The supplicant patch version ($(OPTEE_SUPPLICANT_VERSION)) does not match LIBTEEC_VERSION ($(LIBTEEC_VERSION)). \
|
|
||||||
Build aborted. Change LIBTEEC_VERSION version to match OPTEE_SUPPLICANT_VERSION. \
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/handle.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/hmac_sha2.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/sha2.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/sd_notify.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/teec_ta_load.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/tee_supp_fs.c
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/rpmb.c
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_GP_SOCKETS),1)
|
|
||||||
CSRCS += optee_client/tee-supplicant/src/tee_socket.c
|
|
||||||
CFLAGS += ${DEFINE_PREFIX}CFG_GP_SOCKETS=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += ${INCDIR_PREFIX}optee_client/tee-supplicant/src
|
|
||||||
CFLAGS += ${DEFINE_PREFIX}TEEC_LOAD_PATH=\"/bin\"
|
|
||||||
CFLAGS += ${DEFINE_PREFIX}TEE_FS_PARENT_PATH=\"/data/tee\"
|
|
||||||
CFLAGS += ${DEFINE_PREFIX}DEBUGLEVEL_$(CONFIG_OPTEE_SUPPLICANT_LOG_LEVEL)
|
|
||||||
|
|
||||||
$(OPTEE_SUPPLICANT_UNPACKNAME): $(OPTEE_SUPPLICANT_ZIP)
|
|
||||||
@echo "Unpacking: $(OPTEE_SUPPLICANT_ZIP) -> $(OPTEE_SUPPLICANT_UNPACKNAME)"
|
|
||||||
$(Q) $(UNPACK) $(OPTEE_SUPPLICANT_ZIP)
|
|
||||||
$(Q) mv $(OPTEE_SUPPLICANT_UNPACKNAME)-$(OPTEE_SUPPLICANT_VERSION) $(OPTEE_SUPPLICANT_UNPACKNAME)
|
|
||||||
$(Q) echo "Patching $(OPTEE_SUPPLICANT_UNPACKNAME)"
|
|
||||||
$(Q) patch -p1 -d $(OPTEE_SUPPLICANT_UNPACKNAME) < $(PATCH_FILE)
|
|
||||||
$(Q) touch $(OPTEE_SUPPLICANT_UNPACKNAME)
|
|
||||||
|
|
||||||
ifeq ($(wildcard $(OPTEE_SUPPLICANT_UNPACKNAME)/.git),)
|
|
||||||
context:: $(OPTEE_SUPPLICANT_UNPACKNAME)
|
|
||||||
|
|
||||||
distclean::
|
|
||||||
$(Q) rm -rf $(OPTEE_SUPPLICANT_UNPACKNAME)
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue