-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_ta.sh
executable file
·111 lines (94 loc) · 3.17 KB
/
build_ta.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# Author: Zoltan Kuscsik <[email protected]>
#
OPTEE_LOGLEVEL=3
CURRENT_BUILD_PATH=$(dirname $(realpath $0))
NUMBER_OF_CPU_CORES=`grep -c ^processor /proc/cpuinfo`
OPTEE_OS_DIR="optee_os"
set_optee_os_hikey_vars() {
export PLATFORM=hikey
export CROSS_COMPILE=aarch64-linux-gnu-
ARM64_core=y
TA_TARGETS=ta_arm64
OPTEE_OS_DEV_KIT_PATH="out/arm-plat-hikey/export-ta_arm64"
COMPILER_PATH=$CURRENT_BUILD_PATH/gcc-linaro-4.9-2015.05-x86_64_aarch64-linux-gnu/bin
}
set_optee_os_hikey32_vars() {
export PLATFORM=hikey
export CROSS_COMPILE=arm-linux-gnueabi-
TA_TARGETS=ta_arm32
export CFG_TA_FLOAT_SUPPORT=n
export CFG_WITH_VFP=n
export CFG_CRYPTO_SHA256=n
export CFG_CRYPTO_SHA1_ARM32_CE=n
OPTEE_OS_DEV_KIT_PATH="out/arm-plat-hikey/export-ta_arm32"
COMPILER_PATH=$CURRENT_BUILD_PATH/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabi/bin
echo $COMPILER_PATH
}
if [ -z "$ANDROID_BUILD_TOP" ]; then
echo "Error: Before running this script you should call in the main Android directory"
echo
echo " $ source build/envsetup.sh "
echo " $ lunch <whatever> "
exit 1
fi
###########################################################
# Select target platform
###########################################################
if [ "$1" == "hikey" ]; then
set_optee_os_hikey_vars
elif [ "$1" == "hikey32" ]; then
set_optee_os_hikey32_vars
else
echo "#"
echo "# ERROR: Missing platform argument from ./$(basename $0) <platform> <ta_project_list_file>"
echo "#"
echo "# Valid platforms:"
echo "#"
echo "# * hikey "
echo "#"
echo "# Example : "
echo "#"
echo "# $ ./build_ta.sh hikey optee/android_optee_examples.cfg "
echo "#"
exit 1
fi
export PATH=$COMPILER_PATH:$PATH
if [ -z "$2" ]; then
echo "Missing TA list from ./$(basename $0) <platform> <ta_project_list_file> "
exit 1
fi
TA_PROJECT_LIST_SOURCE="$2"
if [ -f $TA_PROJECT_LIST_SOURCE ]; then
source $TA_PROJECT_LIST_SOURCE
else
echo "ERROR: File $TA_PROJECT_LIST_SOURCE does not exists"
exit 1
fi
if [ -z "$ANDROID_OPTEE_PROJECT_LIST" ]; then
echo "TA projects list file must define the ANDROID_OPTEE_PROJECT_LIST variable."
exit 1
fi
##########################################################
# Build OPTEE OS
##########################################################
make -C $CURRENT_BUILD_PATH/$OPTEE_OS_DIR -j$NUMBER_OF_CPU_CORES \
ta-targets=$TA_TARGETS \
CFG_ARM64_core=$ARM64_core \
CFG_TEE_CORE_LOG_LEVEL=$OPTEE_LOGLEVEL \
CFG_LOG_SYSLOG=y
##########################################################
# Build trusted applications
##########################################################
export TA_DEV_KIT_DIR=$CURRENT_BUILD_PATH/$OPTEE_OS_DIR/$OPTEE_OS_DEV_KIT_PATH
for ta_target in $ANDROID_OPTEE_PROJECT_LIST
do
make -C $ANDROID_BUILD_TOP/$ta_target O=$ANDROID_BUILD_TOP/$ta_target CFG_TEE_TA_LOG_LEVEL=$OPTEE_LOGLEVEL V=1 CFG_LOG_SYSLOG=y
android_mk="$ANDROID_BUILD_TOP/$ta_target/Android.mk"
if [ ! -f "$android_mk" ]; then
echo "ERROR: Android.mk does not exists in $ANDROID_BUILD_TOP/$ta_target"
echo " TA is built but it wont be included in the system.img"
exit 1
fi
done