HiKey960 AOSP+OP-TEE sync and build error

Hi, I am having a problem with building AOSP and OP-TEE for HiKey960 following the steps from the documentation from here: https:// readthedocs org/projects/optee/downloads/pdf/latest/

After cloning the repository like so: git clone https://github.com/linaro-swg/optee_android_manifest and running the sync script: ./sync-p-hikey960.sh
I am having a problem with a patch:

=== AM Applying patch http://git.ti.com/android/platform-system-core/commit/949450945115165cf76f47c69b3f107a4db022f1?format=patch ===
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 316 100 316 0 0 387 0 --:–:-- --:–:-- --:–:-- 387
Patch is empty.
When you have resolved this problem, run “git am --continue”.
If you prefer to skip this patch, run “git am --skip” instead.
To restore the original branch and stop patching, run “git am --abort”.
Failed to apply patch http://git.ti.com/android/platform-system-core/commit/949450945115165cf76f47c69b3f107a4db022f1?format=patch for project

I aborted and forced sync with --force-sync, this time getting no errors.
Unfortunately, after running ./build-p-hikey960.sh, the problems with libdrm occur:

FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -o out/soong/build.ninja Android.bp
error: external/libdrm/Android.bp:51:23: unrecognized property “recovery_available”
error: external/libdrm/data/Android.bp:1:1: unrecognized module type “prebuilt_etc”
ninja: build stopped: subcommand failed.
09:58:46 soong bootstrap failed with: exit status 1

real 0m6.643s
user 0m41.060s
sys 0m4.623s
Build done!
Please make sure there are no errors before flashing!

Any ideas on how I can fix this?

I got the same error when trying the sync script. Source tree patching
fails. The patch script function curl_am is piping output of the curl
command to a “git am” command. However, the referred URL returns HTML
web redirect (301 Moved permanently) and that is then piped to “git am”
causing the “Patch is empty” message.

Using “curl -L” could follow the redirect but also that document is an
HTML document! I assume that the git web front-end does not support
“?format=patch”. Maybe TI has changed the front-end since this sync
script has been created.

Linaro has copied a couple of TI patches to their own server. I cloned
android-patches repository and modified a couple of patches in a file
P_RLCR-PATCHSET replacing curl_am function calls with these apply calls:

ueventd: Add dynamic kernel module loading:
apply --linaro system/core 21063/1

revert change of “Make libdrm recovery_available” from master branch:
apply --linaro --local hardware/interfaces --remote platform/hardware/interfaces 21064/1

I also had a problem with a patch in a file swg-mods-common (refspec kmgk_rebase
was not found).

I was able to build images and flash them but boot hanged with the same error that
is reported earlier here: