summaryrefslogtreecommitdiff
path: root/swg-mods-common
blob: b7792df9165c7c0c1b0d87f9e12ab9b592b30c06 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash

set -e

. $(dirname $0)/functions

curl_am_optee(){
    local repository=$1
    local patch_id=$2
    local patch_project="$3"
    local user=$4
    local patch_url="https://github.com/${user}/${repository}/commit/${patch_id}.patch"
    curl_am ${patch_url} ${patch_project}
}

PATCHES=0
if [ -n "$1" ]; then
        AOSP="$1"
else
        AOSP="`pwd`"
fi

if ! [ -d "$AOSP" ] && ! [ -d "$AOSP/bionic" ] && [ -d "$AOSP"/build ]; then
        echo "This script must be run from the AOSP source directory"
        echo "or with the AOSP source directory as its first parameter."
        exit 1
fi

#######################################################
## Patches for SWG use cases different than r-lcr #####
#######################################################
if [ X"$MANIFEST_BRANCH" = X"master" ]; then
	## print version_str on not_match
	curl_am_optee system_keymaster 2afb818c88fe7fd0efb41ff89aa73a1904580df2 system/keymaster vchong

	## convert alphabetic version to number
	curl_am_optee system_keymaster d0cdd9ea97cf125ff62fb41d124bca531594fe7e system/keymaster vchong

	## config.mk: do NOT obsolete export
	#curl_am_optee platform_build da608cc3380c5c9a7d2adac0168b0ba05a2345ae build/make vchong
else
	# assume pie

	## 'curl' not allowed in master
	## build/tasks: add makefile to get wifi apk
	## http://android-review.linaro.org/20098
	apply --linaro device/linaro/hikey 20098/12
fi

## used netdomain instead - see below for reference
## https://github.com/vchong/device-linaro-hikey/commit/f00abbb1250d4651d88509874db68e340aa8bc3d
## this is done in hikey-hikey960-optee-common as part of
## "optee: integrate for optee components"
## init.rc: add inet group to console service
## https://android-review.linaro.org/#/c/platform/system/core/+/20241
#apply --linaro system/core 20241/1


# fastboot: mark nvme partition as ext4
# https://android-review.linaro.org/c/device/linaro/bootloader/OpenPlatformPkg/+/20452
apply --linaro device/linaro/bootloader/OpenPlatformPkg 20452/1

## these can be enabled via optee_android_manifest sync scripts
## optee: set dbg log lvl for core and TA
## http://android-review.linaro.org/20096
if [ "${OPTEE_OS_DBG}" = "y" ]; then
	echo "Set dbg log lvl for optee_os core and TA"
	apply --linaro device/linaro/hikey 20096/13
fi

#######################################################
## Patches for hikey960                           #####
#######################################################
if [ X"$TARGET_OUT_DIR" = X"hikey960" ] && { [ X"$LOCAL_MANIFEST_BRANCH" = X"linaro-p-swg" ] || [ X"$LOCAL_MANIFEST_BRANCH" = X"linaro-master-swg" ]; }; then
	#true

	# fastboot: mark nvme partition as ext4
	# https://github.com/vchong/OpenPlatformPkg/commit/162c6ea324fcd39ddf6e628cd4ed09aedbbb1a48
        cd optee/OpenPlatformPkg && \
        git fetch https://github.com/vchong/OpenPlatformPkg refact_960 && \
        git cherry-pick 162c6ea324fcd39ddf6e628cd4ed09aedbbb1a48 && \
        cd -
	# Below uses "curl <url>.patch|git am" (see file named functions) but
	# fails. For details see
	# https://ci.linaro.org/job/android-hikey960-optee-p/255/consoleText
	#curl_am_optee OpenPlatformPkg 162c6ea324fcd39ddf6e628cd4ed09aedbbb1a48 optee/OpenPlatformPkg vchong

	# these can be enabled via optee_android_manifest sync scripts
	# optee: set dbg log lvl for core and TA
	# https://github.com/vchong/uefi-tools/commit/a581c9bbf8118ee5b20b7121e9a2bd24612a6c70
	if [ "${OPTEE_OS_DBG}" = "y" ]; then
		echo "Set dbg log lvl for hikey960 optee_os core and TA"
		curl_am_optee uefi-tools a581c9bbf8118ee5b20b7121e9a2bd24612a6c70 optee/uefi-tools vchong
	fi
fi


## no need to set BUILD_{ATF_TOS}=debug to get debug logs
## uefi-tools: disable debug build for now
#curl_am_optee device-linaro-hikey 060bcd1a959189013c66081cf43d4c97fcbbd888 device/linaro/hikey vchong

#######################################################
## Common patches for SWG KMGK                    #####
#######################################################
## KM mods - keymaster/gatekeeper patches
if [ X"$MANIFEST_BRANCH" = X"master" ]; then
	## http://android-review.linaro.org/20604
	apply --linaro device/linaro/hikey 20604/24
else
	## assume pie
	## http://android-review.linaro.org/21467
	apply --linaro device/linaro/hikey 21467/6
fi

## build default kmgk svc too
#curl_am_optee device-linaro-hikey 29723107072a56a70d48c840037660a3b6693223 device/linaro/hikey vchong

# kmgk: add dbg prints
#curl_am_optee kmgk 36780a94 device/linaro/kmgk vchong

# set log levels to 4
# https://github.com/vchong/optee_client/commit/cf7c607f6bf2f4f637f69eac2764d79011694f7c
if [ "${OPTEE_CLN_DBG}" = "y" ]; then
	echo "Skip setting optee_client log levels to 4 for now"
	#curl_am_optee optee_client cf7c607f6bf2f4f637f69eac2764d79011694f7c external/optee_client vchong
fi

# use /persist/tee as secure storage path
# https://github.com/vchong/optee_client/commit/68e907e6c6a05c2e5c8603079dfae5927fce4430
#curl_am_optee optee_client 68e907e6c6a05c2e5c8603079dfae5927fce4430 external/optee_client vchong

if [ X"$TEE_USE_RPMB" = X"true" ]; then
	# tee-supplicant: disable RPMB emu
	# https://github.com/vchong/optee_client/commit/9cb7a69a969aec887ae1d13f2b2d639785e602fc
	curl_am_optee optee_client 9cb7a69a969aec887ae1d13f2b2d639785e602fc external/optee_client vchong

	# copy files over from buildroot
	# https://github.com/vchong/mmc-utils/commit/b504192fd136a111160a15fb7504d2d856b4a12d
	curl_am_optee mmc-utils b504192fd136a111160a15fb7504d2d856b4a12d external/mmc-utils vchong

	# fix build errors
	# https://github.com/vchong/mmc-utils/commit/92eeb06bf177e8933748764cfbb9a007dde6917a
	curl_am_optee mmc-utils 92eeb06bf177e8933748764cfbb9a007dde6917a external/mmc-utils vchong

	# mk/config.mk: enable RPMB
	# https://github.com/vchong/optee_os/commit/3f40517861a15121870871bd28363c2ec6c430bd
	curl_am_optee optee_os 3f40517861a15121870871bd28363c2ec6c430bd optee/optee_os vchong

	# merge conflict, ignore for now
	# rpmb: print rpmb op result from ioctl
	# https://github.com/vchong/optee_os/commit/ef8ad4886a5c713dc135de01079a772bed1b93af
	#curl_am_optee optee_os ef8ad4886a5c713dc135de01079a772bed1b93af optee/optee_os vchong
fi

cd optee/optee_os
#git fetch https://github.com/vchong/optee_os pull/1/head && git merge --no-edit FETCH_HEAD
# cherry pick instead of merge so that patches stay on top
git fetch https://github.com/vchong/optee_os kmgk_rebase_mbedtls && git cherry-pick a4097612cde65f24cc9ba22048dd5708dfb3ffbc^..d054b7fad46b14e669e6aa3226c85bb89a92e24c
cd -

#######################################################
## Common patches for Widevine                    #####
#######################################################
if [ -d "${AOSP}/external/optee-widevine-ref" ]; then
	# add wv components
	# https://android-review.linaro.org/20212
	apply --linaro device/linaro/hikey 20212/27

	# oemcrypto_test: fix Makefiles
	# https://dev-private-review.linaro.org/4510
	apply --server ssh://git@dev-private-git.linaro.org/ --local vendor/widevine --remote widevine/android 4510/1

	# placeholder for internal wv patches
	#apply --server ssh://git@dev-private-git.linaro.org/ --local external/optee-widevine-ref --remote widevine/optee-widevine-ref 1234/5
fi

##################################################
################ Backport ########################
##################################################
## fix android build errors for Treble
if [ -d "${AOSP}/external/optee_examples" ]; then
    :
fi