Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions tee/libteec/Makefile

This file was deleted.

File renamed without changes.
58 changes: 51 additions & 7 deletions tee/libteec/CMakeLists.txt → tee/optee_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ if(CONFIG_LIBTEEC)
if(NOT EXISTS ${OPTEE_CLIENT_DIR})
set(OPTEE_CLIENT_URL
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(
optee_client_fetch
URL ${OPTEE_CLIENT_URL}/${OPTEE_CLIENT_VER}.zip SOURCE_DIR
${OPTEE_CLIENT_DIR} BINARY_DIR
${CMAKE_BINARY_DIR}/tee/libteec/optee_client
PATCH_COMMAND patch -p1 -d ${OPTEE_CLIENT_DIR} <
${CMAKE_CURRENT_LIST_DIR}/0001-libteec-NuttX.patch
${CMAKE_BINARY_DIR}/tee/optee_client/optee_client
PATCH_COMMAND
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
TIMEOUT 30)

Expand All @@ -53,8 +56,7 @@ if(CONFIG_LIBTEEC)

target_sources(libteec PRIVATE optee_client/libteec/src/tee_client_api.c
optee_client/libteec/src/teec_trace.c)
target_include_directories(libteec
PRIVATE ${OPTEE_CLIENT_DIR}/libteec/include)
target_include_directories(libteec PUBLIC ${OPTEE_CLIENT_DIR}/libteec/include)
target_compile_definitions(libteec PUBLIC BINARY_PREFIX=\"TEEC\")

if(CONFIG_DEBUG_INFO)
Expand All @@ -68,4 +70,46 @@ if(CONFIG_LIBTEEC)
target_compile_definitions(libteec PUBLIC DEBUGLEVEL=1)
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
35 changes: 33 additions & 2 deletions tee/libteec/Kconfig → tee/optee_client/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# apps/tee/libteec/Kconfig
# apps/tee/optee_client/Kconfig
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down Expand Up @@ -38,8 +38,39 @@ config LIBTEEC

if LIBTEEC

config LIBTEEC_VERSION
config OPTEE_CLIENT_VERSION
string "optee_client version (4.6.0)"
default "4.6.0"

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
11 changes: 3 additions & 8 deletions tee/libteec/Make.defs → tee/optee_client/Make.defs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
############################################################################
# apps/tee/libteec/Make.defs
# apps/tee/optee_client/Make.defs
#
# 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
Expand All @@ -20,9 +18,9 @@
############################################################################

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\""

ifneq ($(CONFIG_DEBUG_INFO),)
Expand All @@ -40,7 +38,4 @@ AFLAGS += $(FLAGS)
CFLAGS += $(FLAGS)
CXXFLAGS += $(FLAGS)

DEPPATH += --dep-path libteec
VPATH += :libteec

endif
88 changes: 88 additions & 0 deletions tee/optee_client/Makefile
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading