aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGyorgy Szing <Gyorgy.Szing@arm.com>2019-11-27 19:25:12 +0100
committerTamas Ban <tamas.ban@arm.com>2019-12-13 08:44:23 +0000
commit28d993c7c483966b7d71ac2dd4c691ee6ba29c5d (patch)
treefaf220c41383ee46015966233603b51af4f7fc63
parentba2346e9ae0953bbb41e97cf30b1a7afe71efd05 (diff)
downloadtrusted-firmware-m-28d993c7c483966b7d71ac2dd4c691ee6ba29c5d.tar.gz
CC312: Fix Windows build
On windows shell tools return POSIX PATHs which is not understood by native executables (make and compiler). This patch converts problematic paths to mixed mode. For details please see comment at line 44 in Makefile.defs. On Windows GCC does not find some include files, because it ignores the ./ include path. (gcc -v returns : ignoring non existent directory "./".) Using . instead solves the problem. Details: Makefile.defs: - Added windows build environment identification. - For Cygwin and MSYS PWD and HOST_PROJ_ROOT is converted to "mixed" path. (See comment in file.) - Working around GCC not finding ./ include path on Windows. Makefile.rules: - Added a new variable to CC312 makefiles to allow passing variables from the command line. This is needed to work around the make behavior where it stops makefiles modifying variables passed on the command line. .../Makefile: - Removed $(shell pwd) calls. BuildCC312.cmake: - Made the build fail on windows only if build has been started off a non POSIX environnement. - Removed CC312_ENV as passing options to ExternalProject_Add() was failing on Windows. - Modified ExternalProject starting the cc312 build to not pass C flags embedded into CC (the compiler command). This resulted in problems when compiler was under Program Files (x86). - Fix configuration step commands. - Disable log file generation on windows to avoid generating command lines longer than 8192 bytes. - Use cmake to generate project specific config file to extend CFLAGS list and add extra folders to CC312's include path. - Some minor clean-up. Change-Id: Ib6fbe9e9a2046ff75cb9e101a02ad594f9e60573 Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com> Signed-off-by: Tamas Ban <tamas.ban@arm.com>
-rw-r--r--lib/ext/cryptocell-312-runtime/host/Makefile.defs51
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/Makefile2
-rwxr-xr-xlib/ext/cryptocell-312-runtime/host/src/cc3x_lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/cmpu/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/dmpu/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/cc3x_sbromlib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/pal/freertos/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/pal/linux/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/pal/no_os/Makefile2
-rwxr-xr-xlib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/cmpu_integration_test/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/dmpu_integration_test/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/runtime_integration_test/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/lib/Makefile2
-rwxr-xr-xlib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/cert_lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/x509cert_lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile2
-rw-r--r--lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile2
-rw-r--r--platform/ext/common/cc312/BuildCC312.cmake79
-rw-r--r--platform/ext/common/cc312/cc312_proj_cfg.mk.in (renamed from platform/ext/common/cc312/cc312_proj_cfg.mk)18
-rw-r--r--platform/ext/musca_b1.cmake3
30 files changed, 135 insertions, 68 deletions
diff --git a/lib/ext/cryptocell-312-runtime/host/Makefile.defs b/lib/ext/cryptocell-312-runtime/host/Makefile.defs
index 554298223f..857f71f93f 100644
--- a/lib/ext/cryptocell-312-runtime/host/Makefile.defs
+++ b/lib/ext/cryptocell-312-runtime/host/Makefile.defs
@@ -15,6 +15,24 @@
# LOGFILE = log file name. Default is makelog.txt in the current dir.
+### Determine host environment
+_UNAME_OS=$(shell uname -o)
+
+ifeq (Cygwin,$(_UNAME_OS))
+ HOST=WINDOWS
+ HOST_OS=CYGWIN
+else ifeq (Msys,$(_UNAME_OS))
+ HOST=WINDOWS
+ HOST_OS=MSYS
+else ifeq (GNU/Linux,$(_UNAME_OS))
+ HOST=LINUX
+ HOST_OS=LINUX
+else
+ HOST=UNKNOWN
+ HOST_OS=UNKNOWN
+endif
+
+
### Build platform commands (Currently assumes Linux/Unix/Cygwin machine)
SHELL = /bin/bash -o pipefail
RM = rm -f
@@ -30,14 +48,35 @@ LOGFILE ?= ./makelog.txt
### Build environment setup ###
-PWD = $(shell pwd)
+#On windows when running from an emulated POSIX environment we have
+#to deal with three different kind of paths. The native windows path
+#i.e. c:\foo\bar, the POSIX path i.e. /c/foo/bar or
+#/cygdrive/c/foo/bar and the mixed path which is the native path but
+#with forward slashes (i.e. c:/foo/bar).
+#Executables compiled in the POSIX environment understand the
+#POSIX and the mixed path. Native windows executables (i.e. compilers
+#understand the native and the mixed path.
+#To avoid path issues the best is to use the mixed path. Use the
+#cygpath tool to do the conversion.
+#Note: the pwd command provided by the shell must not be used in the
+# makefiles!
+
+ifneq (,$(filter ${HOST_OS},CYGWIN MSYS))
+ PWD := $(shell cygpath -am . | tr -d '\r\n')
+else
+ PWD := $(shell readlink -f .)
+endif
ifndef HOST_PROJ_ROOT
$(error HOST_PROJ_ROOT is undefined)
endif
# Host domain root converted to absolut path
-HOST_PROJ_ROOT := $(shell cd $(HOST_PROJ_ROOT); pwd)
+ifneq (,$(filter ${HOST_OS},CYGWIN MSYS))
+ HOST_PROJ_ROOT := $(shell cygpath -am $(HOST_PROJ_ROOT) | tr -d '\r\n')
+else
+ HOST_PROJ_ROOT := $(shell readlink -f $(HOST_PROJ_ROOT))
+endif
HOST_SRCDIR := $(HOST_PROJ_ROOT)/src
SHARED_DIR := $(HOST_PROJ_ROOT)/../shared
SHARED_INCDIR := $(SHARED_DIR)/include
@@ -46,11 +85,13 @@ CODESAFE_DIR := $(HOST_PROJ_ROOT)/../codesafe
CODESAFE_SRCDIR := $(CODESAFE_DIR)/src
UTILS_DIR := $(HOST_PROJ_ROOT)/../utils
UTILS_SRCDIR := $(UTILS_DIR)/src
-INCDIRS = ./ $(INCDIRS_EXTRA)
+#Note: on windows GCC seems to ignore ./ as an include path with:
+# ignoring nonexistent directory. Using . seems to work.
+INCDIRS = . $(INCDIRS_EXTRA)
INCDIRS += $(SHARED_INCDIR) $(SHARED_INCDIR)/proj/$(PROJ_PRD)
# $(SHARED_INCDIR)/pal $(SHARED_INCDIR)/pal/$(TEE_OS) $(SHARED_INCDIR)/pal/$(TEE_OS)/include
INCDIRS += $(HOST_PROJ_ROOT)/include
-LIBDIRS = ./ $(LIBDIRS_EXTRA) $(HOST_PROJ_ROOT)/lib
+LIBDIRS = . $(LIBDIRS_EXTRA) $(HOST_PROJ_ROOT)/lib
HOST_LIBDIR = $(HOST_SRCDIR)/$(HOST_LIBNAME)
@@ -212,7 +253,7 @@ comma := ,
# This complexity is required because of pipe's nature which prevents appending while piping into the log file.
ifeq ($(LOGFILE),-)
exec_logged = $(1)
- #exec_logged_evaled = $(1)
+ exec_logged_evaled = $(1)
else
exec_logged = ( $(ECHO) $(shell date): "$(1)" >> $(LOGFILE) ; ( $(1) ) >>$(LOGFILE) 2>logerr.tmp ; err=$$? ; cat logerr.tmp ; cat logerr.tmp >> $(LOGFILE) ; rm logerr.tmp ; exit $$err)
# nested version is to be $(call)ed from within another $(eval)
diff --git a/lib/ext/cryptocell-312-runtime/host/src/Makefile b/lib/ext/cryptocell-312-runtime/host/src/Makefile
index 923397e8f3..3e7538d506 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/Makefile
@@ -8,7 +8,7 @@
# "Root" Makefile for Host domain
# This makefile invokes the relevant target specific makefile to build it (e.g., cclib)
-HOST_PROJ_ROOT ?= $(shell pwd)/..
+HOST_PROJ_ROOT ?= ../
include $(HOST_PROJ_ROOT)/Makefile.defs
# List of known modules in host and shared domains
diff --git a/lib/ext/cryptocell-312-runtime/host/src/cc3x_lib/Makefile b/lib/ext/cryptocell-312-runtime/host/src/cc3x_lib/Makefile
index 636b09785a..2608f2180c 100755
--- a/lib/ext/cryptocell-312-runtime/host/src/cc3x_lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/cc3x_lib/Makefile
@@ -5,7 +5,7 @@
#
#-------------------------------------------------------------------------------
-HOST_PROJ_ROOT ?= $(shell pwd)/../..
+HOST_PROJ_ROOT ?= ../..
include $(HOST_PROJ_ROOT)/Makefile.defs
API_DIR = $(CODESAFE_SRCDIR)/crypto_api/cc3x_sym/api
diff --git a/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/cmpu/Makefile b/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/cmpu/Makefile
index 6226d735b2..754f1b7fc9 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/cmpu/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/cmpu/Makefile
@@ -6,7 +6,7 @@
#-------------------------------------------------------------------------------
# Makefile for cmpu utility
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
include $(HOST_PROJ_ROOT)/Makefile.defs
#overwriting the OS defined in the config
OS = no_os
diff --git a/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/dmpu/Makefile b/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/dmpu/Makefile
index 046f80e8fc..f51797cf41 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/dmpu/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/cc3x_productionlib/dmpu/Makefile
@@ -6,7 +6,7 @@
#-------------------------------------------------------------------------------
# Makefile for cmpu utility
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
include $(HOST_PROJ_ROOT)/Makefile.defs
#overwriting the OS defined in the config
OS = no_os
diff --git a/lib/ext/cryptocell-312-runtime/host/src/cc3x_sbromlib/Makefile b/lib/ext/cryptocell-312-runtime/host/src/cc3x_sbromlib/Makefile
index b10304fb59..a78269ecc5 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/cc3x_sbromlib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/cc3x_sbromlib/Makefile
@@ -5,7 +5,7 @@
#
#-------------------------------------------------------------------------------
-HOST_PROJ_ROOT ?= $(shell pwd)/../..
+HOST_PROJ_ROOT ?= ../..
include $(HOST_PROJ_ROOT)/Makefile.defs
CFLAGS_EXTRA += -DCC_TEE -DCC_SB_SUPPORT_IOT
diff --git a/lib/ext/cryptocell-312-runtime/host/src/pal/freertos/Makefile b/lib/ext/cryptocell-312-runtime/host/src/pal/freertos/Makefile
index 6c14d470a1..90fee0a226 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/pal/freertos/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/pal/freertos/Makefile
@@ -7,7 +7,7 @@
# Makefile for PAL for freertos
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
include $(HOST_PROJ_ROOT)/Makefile.defs
TARGET_LIBS = pal_freertos
PLAT_OS = freertos
diff --git a/lib/ext/cryptocell-312-runtime/host/src/pal/linux/Makefile b/lib/ext/cryptocell-312-runtime/host/src/pal/linux/Makefile
index be5d26548d..16c573204e 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/pal/linux/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/pal/linux/Makefile
@@ -7,7 +7,7 @@
# Makefile for pal for linux
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
include $(HOST_PROJ_ROOT)/Makefile.defs
TARGET_LIBS = pal_linux
PLAT_OS=linux
diff --git a/lib/ext/cryptocell-312-runtime/host/src/pal/no_os/Makefile b/lib/ext/cryptocell-312-runtime/host/src/pal/no_os/Makefile
index e112a60045..74e7ef61a9 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/pal/no_os/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/pal/no_os/Makefile
@@ -7,7 +7,7 @@
# Makefile for pal for linux
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
include $(HOST_PROJ_ROOT)/Makefile.defs
TARGET_LIBS = pal_no_os
PLAT_OS=no_os
diff --git a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/Makefile b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/Makefile
index 15de5328f2..4829c0cbfe 100755
--- a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/Makefile
@@ -6,7 +6,7 @@
#-------------------------------------------------------------------------------
# Makefile for integration tests
-HOST_PROJ_ROOT ?= $(shell pwd)/../../..
+HOST_PROJ_ROOT ?= ../../..
TEST_AL_PATH = ../TestAL
TEST_AL_GIT =
diff --git a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/cmpu_integration_test/Makefile b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/cmpu_integration_test/Makefile
index 265c905d56..3cd8cc7075 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/cmpu_integration_test/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/cmpu_integration_test/Makefile
@@ -5,7 +5,7 @@
#
#-------------------------------------------------------------------------------
-HOST_PROJ_ROOT ?= $(shell pwd)/../../../..
+HOST_PROJ_ROOT ?= ../../../..
ifneq (,$(findstring gnu,$(CROSS_COMPILE)))
TEE_OS = linux
diff --git a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/dmpu_integration_test/Makefile b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/dmpu_integration_test/Makefile
index 20a062339b..64f2551d5f 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/dmpu_integration_test/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/dmpu_integration_test/Makefile
@@ -5,7 +5,7 @@
#
#-------------------------------------------------------------------------------
-HOST_PROJ_ROOT ?= $(shell pwd)/../../../..
+HOST_PROJ_ROOT ?= ../../../..
ifneq (,$(findstring gnu,$(CROSS_COMPILE)))
TEE_OS = linux
diff --git a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/runtime_integration_test/Makefile b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/runtime_integration_test/Makefile
index edd0c201a1..abb8c7c8b8 100644
--- a/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/runtime_integration_test/Makefile
+++ b/lib/ext/cryptocell-312-runtime/host/src/tests/integration_cc3x/runtime_integration_test/Makefile
@@ -5,7 +5,7 @@
#
#-------------------------------------------------------------------------------
-HOST_PROJ_ROOT ?= $(shell pwd)/../../../..
+HOST_PROJ_ROOT ?= ../../../..
ifneq (,$(findstring gnu,$(CROSS_COMPILE)))
TEE_OS = linux
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/Makefile
index 05f770262c..639e8695f0 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/Makefile
@@ -7,7 +7,7 @@
# Utils top level Makefile
-UTILS_ROOT = $(shell pwd)/..
+UTILS_ROOT = $(PWD)/..
all:
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/Makefile
index 5cda02d14b..a62271a754 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/Makefile
@@ -8,7 +8,7 @@
# Makefile for managing build and installation
# shared library to build
-UTIL_ROOT = $(shell pwd)
+UTIL_ROOT = $(PWD)
UTILS_DIR_ROOT = $(UTIL_ROOT)/../..
HOST_DIR_ROOT = $(UTIL_ROOT)/../host
UTILS_LIB_PATH = ./lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/lib/Makefile
index 72acdcf855..8985104c16 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_asset_prov_rt/lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = libutil_crypto.so
LIB_SRC_O = main.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o
-UTILS_ROOT = $(shell pwd)/../../..
+UTILS_ROOT = $(PWD)/../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOST_DIR = $(UTILS_ROOT)/../host
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/Makefile
index b221ea33e1..e162c89891 100755
--- a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/Makefile
@@ -15,7 +15,7 @@ endif
$(info $$SUB_DIRS_PREFIX is [${SUB_DIRS_PREFIX}])
# shared library to build
-SBU_ROOT = $(shell pwd)
+SBU_ROOT = $(PWD)
UTIL_ROOT = $(SBU_ROOT)/../..
SBU_CRYP_LIB_PATH = $(SUB_DIRS_PREFIX)_lib
SBU_CRYP_LIB_NAME = libsbu_crypto.so
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/cert_lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/cert_lib/Makefile
index 68c7282590..70b128f827 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/cert_lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/cert_lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = libsbu_crypto.so
LIB_SRC_O = main.o common_rsa_keypair.o common_rsa_keypair_util.o common_crypto_sym.o common_util_files.o common_sb_ops.o
-UTILS_ROOT = $(shell pwd)/../../..
+UTILS_ROOT = $(PWD)/../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
UTILS_INC_PATH = $(UTILS_ROOT)/include $(UTILS_ROOT)/src/common $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(SHARED_DIR)/include
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/x509cert_lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/x509cert_lib/Makefile
index dedfc42ae6..17726299e7 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/x509cert_lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cc3x_boot_cert/x509cert_lib/Makefile
@@ -11,7 +11,7 @@ SH_LIB_NAME = libsbu_crypto.so
LIB_SRC_O = main.o common_rsa_keypair.o common_crypto_x509.o
LIB_SRC_O += common_crypto_sym.o common_crypto_asym.o common_util_files.o common_rsa_keypair_util.o
-UTILS_ROOT = $(shell pwd)/../../..
+UTILS_ROOT = $(PWD)/../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOST_DIR = $(UTILS_ROOT)/../host
CODESAFE_DIR = $(UTILS_ROOT)/../codesafe
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/Makefile
index 328074e98f..3b0114ccb1 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/Makefile
@@ -8,7 +8,7 @@
# Makefile for managing build and installation
# shared library to build
-UTIL_ROOT = $(shell pwd)
+UTIL_ROOT = $(PWD)
UTILS_DIR_ROOT = $(UTIL_ROOT)/../..
HOST_DIR_ROOT = $(UTIL_ROOT)/../host
UTILS_LIB_PATH = ./lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/lib/Makefile
index b6ba2bcf10..95fe25fd8f 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/cmpu_asset_pkg_util/lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = lib_cmpuutil_crypto.so
LIB_SRC_O = main.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o
-UTILS_ROOT = $(shell pwd)/../../..
+UTILS_ROOT = $(PWD)/../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOSTSRC_DIR = $(UTILS_ROOT)/../host/src
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile
index cd7cfa39be..d758bb1617 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile
@@ -8,7 +8,7 @@
# Makefile for managing build and installation
# shared library to build
-UTIL_ROOT = $(shell pwd)
+UTIL_ROOT = $(PWD)
UTILS_DIR_ROOT = $(UTIL_ROOT)/../../..
HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host
UTILS_LIB_PATH = ./lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile
index 3384104d68..c81cac1c74 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = lib_icv_key_response.so
LIB_SRC_O = main.o dmpu_common.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o
-UTILS_ROOT = $(shell pwd)/../../../..
+UTILS_ROOT = $(PWD)/../../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOSTSRC_DIR = $(UTILS_ROOT)/../host/src
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile
index a059b63609..5340dd0e54 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile
@@ -8,7 +8,7 @@
# Makefile for managing build and installation
# shared library to build
-UTIL_ROOT = $(shell pwd)
+UTIL_ROOT = $(PWD)
UTILS_DIR_ROOT = $(UTIL_ROOT)/../../..
HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host
UTILS_LIB_PATH = ./lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile
index 529bc362ab..6f1ad5e695 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = lib_oem_asset_pkg.so
LIB_SRC_O = main.o dmpu_common.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o
-UTILS_ROOT = $(shell pwd)/../../../..
+UTILS_ROOT = $(PWD)/../../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOSTSRC_DIR = $(UTILS_ROOT)/../host/src
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile
index 78ec76c772..084dada4a4 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile
@@ -8,7 +8,7 @@
# Makefile for managing build and installation
# shared library to build
-UTIL_ROOT = $(shell pwd)
+UTIL_ROOT = $(PWD)
UTILS_DIR_ROOT = $(UTIL_ROOT)/../../..
HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host
UTILS_LIB_PATH = ./lib
diff --git a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile
index 9faf46e3ce..dd4f9ce208 100644
--- a/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile
+++ b/lib/ext/cryptocell-312-runtime/utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile
@@ -10,7 +10,7 @@ SH_LIB_NAME = lib_oem_key_request.so
LIB_SRC_O = main.o common_sb_ops.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o common_crypto_sym.o #common_crypto_asym.o
-UTILS_ROOT = $(shell pwd)/../../../..
+UTILS_ROOT = $(PWD)/../../../..
SHARED_DIR = $(UTILS_ROOT)/../shared
HOSTSRC_DIR = $(UTILS_ROOT)/../host/src
UTILS_LIB_PATH = $(UTILS_ROOT)/lib
diff --git a/platform/ext/common/cc312/BuildCC312.cmake b/platform/ext/common/cc312/BuildCC312.cmake
index 6107abcc42..83c7c35ac7 100644
--- a/platform/ext/common/cc312/BuildCC312.cmake
+++ b/platform/ext/common/cc312/BuildCC312.cmake
@@ -10,7 +10,29 @@
cmake_minimum_required(VERSION 3.7)
if (CMAKE_HOST_WIN32)
- message(FATAL_ERROR "CC312 build is not supported on windows")
+ #CC312 can only be build from a posix environment (cygwin or msys).
+ #Verify environment.
+ set(_CC312_OK False)
+
+ find_program(CMAKE_UNAME_COMMAND uname)
+ if (CMAKE_UNAME_COMMAND)
+ execute_process(COMMAND ${CMAKE_UNAME_COMMAND} -o
+ OUTPUT_VARIABLE _UNAME_RES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(_UNAME_RES STREQUAL "Msys" OR _UNAME_RES STREQUAL "Cygwin")
+ set(_CC312_OK True)
+ endif()
+ else()
+ set(_CC312_OK False)
+ endif()
+
+ if (NOT _CC312_OK)
+ set(_MSG "The CC312 build system currently only supports POSIX")
+ set(_MSG "${_MSG} build environments. Please start the build from")
+ set(_MSG "${_MSG} Cygwin or Msys (Mingw) shell.")
+ message(FATAL_ERROR ${_MSG})
+ endif()
+ unset(_CC312_OK)
endif()
if (NOT DEFINED CC312_SOURCE_DIR)
@@ -58,9 +80,6 @@ if (CRYPTO_HW_ACCELERATOR)
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/cc312/cc312.c")
string(APPEND MBEDCRYPTO_C_FLAGS " -DUSE_MBEDTLS_CRYPTOCELL")
string(APPEND MBEDCRYPTO_C_FLAGS " -DCRYPTO_HW_ACCELERATOR")
-
- string(APPEND CC312_C_FLAGS " -DUSE_MBEDTLS_CRYPTOCELL")
- string(APPEND CC312_C_FLAGS " -DCRYPTO_HW_ACCELERATOR")
endif()
if (CRYPTO_HW_ACCELERATOR_OTP_STATE STREQUAL "PROVISIONING")
@@ -77,23 +96,23 @@ embedded_include_directories(PATH "${PLATFORM_DIR}/common/cc312/" ABSOLUTE)
embedded_include_directories(PATH "${CC312_INSTALL_DIR}/include")
string(APPEND MBEDCRYPTO_C_FLAGS " -I ${CC312_INSTALL_DIR}/include")
-string(APPEND CC312_C_FLAGS " -I ${CC312_INSTALL_DIR}/include")
+string(APPEND CC312_INC_DIR " ${CC312_INSTALL_DIR}/include")
string(APPEND MBEDCRYPTO_C_FLAGS " -I ${PLATFORM_DIR}/common/cc312")
string(APPEND MBEDCRYPTO_C_FLAGS " -DMBEDTLS_ECDH_LEGACY_CONTEXT")
string(APPEND MBEDCRYPTO_C_FLAGS " -DCC_IOT")
-string(APPEND CC312_C_FLAGS " -DMBEDTLS_CONFIG_FILE=\'\\\\\\\"${MBEDTLS_CONFIG_FILE}\\\\\\\"\'")
-string(APPEND CC312_C_FLAGS " -I ${MBEDTLS_CONFIG_PATH}")
-string(APPEND CC312_C_FLAGS " -I ${PLATFORM_DIR}/common/cc312")
-string(APPEND CC312_C_FLAGS " -DCC_IOT")
+string(APPEND CC312_C_FLAGS " -DMBEDTLS_CONFIG_FILE=\\\"${MBEDTLS_CONFIG_FILE}\\\"")
+string(APPEND CC312_INC_DIR " ${MBEDTLS_CONFIG_PATH}")
+string(APPEND CC312_INC_DIR " ${PLATFORM_DIR}/common/cc312")
+
if (MBEDCRYPTO_DEBUG)
if (${COMPILER} STREQUAL "GNUARM")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/cc312/cc312_log.c")
string(APPEND CC312_C_FLAGS " -DDEBUG -DCC_PAL_MAX_LOG_LEVEL=3")
else()
- # Can't set DEBUG (because of stdout issues)
+ # Can't set DEBUG (because of stdout issues)
message(WARNING "${COMPILER} does not support CC312 debug logging")
endif()
string(APPEND CC312_C_FLAGS " -g -O0")
@@ -109,26 +128,6 @@ else()
message(FATAL_ERROR "Compiler ${COMPILER} is not supported by CC312")
endif()
-# Because a makefile is being called anything defined here will prevent
-# modification in the makefile. Due to this the extra flags are included as part
-# of the compiler directive (which won't be modified, where the actual CFLAGS
-# variable will).
-#
-# Variables split between here and CC312_CFG.mk. Anything that depends on a
-# cmake variable is set here.
-set(CC312_ENV "\
- ARCH=arm\
- CC='${CC312_COMPILER} ${CC312_C_FLAGS}'\
- CROSS_COMPILE=${CC312_CROSSCOMPILE}\
- MBEDCRYPTO_ROOT_DIR=${MBEDCRYPTO_SOURCE_DIR}\
- MBEDCRYPTO_ROOT=${MBEDCRYPTO_SOURCE_DIR}\
- PROJ_CFG_PATH=${PLATFORM_DIR}/common/cc312/cc312_proj_cfg.mk\
- BUILDDIR=${CC312_BUILD_DIR}/\
- RELEASE_LIBDIR=${CC312_INSTALL_DIR}/lib/\
- RELEASE_INCDIR=${CC312_INSTALL_DIR}/include/\
- LOGFILE=${CMAKE_CURRENT_BINARY_DIR}/cc312_makelog.txt\
-")
-
if (TARGET ${CC312_TARGET_NAME})
message(FATAL_ERROR "A target with name ${CC312_TARGET_NAME} is already\
defined. Please set CC312_TARGET_NAME to a unique value.")
@@ -136,7 +135,18 @@ endif()
#Build CC312 as external project.
include(ExternalProject)
-set(_static_lib_command ${CMAKE_C_CREATE_STATIC_LIBRARY})
+
+#On windows the maximum command line length makes compilation with logging fail.
+if (CMAKE_HOST_WIN32)
+ set(LOGFILE "-")
+else()
+ set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/cc312_makelog.txt")
+endif()
+
+configure_file("${PLATFORM_DIR}/common/cc312/cc312_proj_cfg.mk.in"
+ "${CC312_BUILD_DIR}/cc312_proj_cfg.mk"
+ @ONLY)
+
externalproject_add(${CC312_TARGET_NAME}
SOURCE_DIR ${CC312_SOURCE_DIR}/host/src
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CC312_BUILD_TYPE}
@@ -145,7 +155,10 @@ externalproject_add(${CC312_TARGET_NAME}
UPDATE_COMMAND ""
WORKING_DIRECTORY ${CC312_SOURCE_DIR}/host/src
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${CC312_SOURCE_DIR}/mbedtls
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${MBEDCRYPTO_SOURCE_DIR} ${CC312_SOURCE_DIR}/mbedtls
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${MBEDCRYPTO_SOURCE_DIR} ${CC312_SOURCE_DIR}/mbedtls
INSTALL_COMMAND ""
BUILD_ALWAYS TRUE
- BUILD_COMMAND bash -c "make -C ${CC312_SOURCE_DIR}/host/src ${CC312_ENV}")
+ BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} ARCH=arm CROSS_COMPILE=${CC312_CROSSCOMPILE}
+ PROJ_CFG_PATH=${CC312_BUILD_DIR}/cc312_proj_cfg.mk
+ LOGFILE=${LOGFILE}
+)
diff --git a/platform/ext/common/cc312/cc312_proj_cfg.mk b/platform/ext/common/cc312/cc312_proj_cfg.mk.in
index fc5f1710bd..1461e98d35 100644
--- a/platform/ext/common/cc312/cc312_proj_cfg.mk
+++ b/platform/ext/common/cc312/cc312_proj_cfg.mk.in
@@ -30,9 +30,18 @@ CC_CONFIG_SB_CERT_VERSION_MAJOR = 1
CC_CONFIG_SB_CERT_VERSION_MINOR = 0
CC_CONFIG_SB_CC3X = 1
-CFLAGS_EXTRA += -DCRYPTO_HW_ACCELERATOR=1
-CFLAGS_EXTRA += -DHW_ACCELERATOR_CC312=1
-CFLAGS_EXTRA += -DUSE_MBEDTLS_CRYPTOCELL=1
+# Mbed-crypto settings
+MBEDCRYPTO_ROOT=@MBEDCRYPTO_SOURCE_DIR@
+MBEDCRYPTO_ROOT_DIR=@MBEDCRYPTO_SOURCE_DIR@
+
+# Build settings
+BUILDDIR=@CC312_BUILD_DIR@
+RELEASE_LIBDIR=@CC312_INSTALL_DIR@/lib/
+RELEASE_INCDIR=@CC312_INSTALL_DIR@/include/
+
+CFLAGS_EXTRA += -DCRYPTO_HW_ACCELERATOR
+CFLAGS_EXTRA += -DHW_ACCELERATOR_CC312
+CFLAGS_EXTRA += -DUSE_MBEDTLS_CRYPTOCELL
CFLAGS_EXTRA += -DCC_CONFIG_TRNG_MODE=0
CFLAGS_EXTRA += -DCC_CONFIG_SUPPORT_SRP=1
@@ -51,6 +60,9 @@ CFLAGS_EXTRA += -fshort-wchar
CFLAGS_EXTRA += -funsigned-char
CFLAGS_EXTRA += -ffunction-sections
CFLAGS_EXTRA += -fdata-sections
+CFLAGS_EXTRA += @CC312_C_FLAGS@
+
+INCDIRS_EXTRA += @CC312_INC_DIR@
TEST_PRODUCT = cc3x
PROJ_TARGETS += cc3x_lib pal cc3x_productionlib
diff --git a/platform/ext/musca_b1.cmake b/platform/ext/musca_b1.cmake
index dc385f166e..69ed2ae1e6 100644
--- a/platform/ext/musca_b1.cmake
+++ b/platform/ext/musca_b1.cmake
@@ -231,6 +231,7 @@ if (CRYPTO_HW_ACCELERATOR_OTP_STATE STREQUAL "PROVISIONING")
add_definitions("-DCRYPTO_HW_ACCELERATOR_OTP_PROVISIONING")
add_definitions("-DCC_IOT")
+ string(APPEND CC312_INC_DIR " ${CC312_SOURCE_DIR}/shared/hw/include/musca_b1")
embedded_include_directories(PATH "${CC312_SOURCE_DIR}/shared/hw/include/musca_b1" ABSOLUTE)
embedded_include_directories(PATH "${CMAKE_CURRENT_BINARY_DIR}/services/crypto/cryptocell/install/include" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/common/cc312/" ABSOLUTE)
@@ -256,7 +257,7 @@ if (CRYPTO_HW_ACCELERATOR)
#The CC312 uses GNU make as a build system so does not use the cmake flag
#system. As such any flags that need to be set for both CC312 and TF-M
#require setting multiple times.
- string(APPEND CC312_C_FLAGS " -I ${CC312_SOURCE_DIR}/shared/hw/include/musca_b1")
+ string(APPEND CC312_INC_DIR " ${CC312_SOURCE_DIR}/shared/hw/include/musca_b1")
embedded_include_directories(PATH "${CC312_SOURCE_DIR}/shared/hw/include/musca_b1" ABSOLUTE)
embedded_include_directories(PATH "${CMAKE_CURRENT_BINARY_DIR}/services/crypto/cryptocell/install/include" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/common/cc312/" ABSOLUTE)