OPTEE + Android 8

Hello ,
Is there working repo for OPTEE on Android 8 ?
Please let me know

Also, if there is working Android 8 (without OPTEE), pls give details of repo.
I see another thread with Android-8 bugs (List of Bugs Android Oreo on HiKey Board)
I wonder, if that repo is in workable condition !!!

Thanks
Deepak

Is there working repo for OPTEE on Android 8 ?

No

Also, if there is working Android 8 (without OPTEE), pls give details of repo.

You should be able to use https://source.android.com/source/devices#620userspace, but just replace master branch manifest with one from Android 8. E.g. repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r17. ‘Workable condition’ is relative as Android 8 is relatively new so expect bugs as you’d seen in the other thread.

Hey Victor,
Is there any plan to support Android 8 + OPTEE on hikey ?

Also , FYI , I flashed latest Images (https://builds.96boards.org/snapshots/hikey/linaro/aosp-master/568/) , Hikey booted successfully and the version it is showing is Android P
Is that really correct ?

Thanks

Hi ,
I am getting strange errors like below :

[18:01:10]viswanath@[~/Downloads/aosp8]$ make -j8
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=8.0.0
TARGET_PRODUCT=hikey
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a15
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-101-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=OPR5.170623.007
OUT_DIR=out
============================================
[38/38] bootstrap out/soong/.minibootstrap/build.ninja.in
[4/4] cp out/soong/.bootstrap/bin/bpglob
[621/622] glob vendor/*/*/Android.bp
[40/40] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
out/build-hikey.ninja is missing, regenerating...
Checking build tools versions...
[354/973] including ./frameworks/av/media/libaaudio/Android.mk ...
frameworks/av/media/libaaudio/examples/input_monitor/static/Android.mk: warning: input_monitor: unusual tags examples
frameworks/av/media/libaaudio/examples/write_sine/static/Android.mk: warning: write_sine: unusual tags examples
[388/973] including ./frameworks/base/Android.mk ...
./frameworks/base/Android.mk:865: warning: FindEmulator: find: `frameworks/opt/telephony/src/java/android/provider': No such file or directory
./frameworks/base/Android.mk:874: warning: FindEmulator: find: `frameworks/opt/telephony/src/java/android/provider': No such file or directory
./frameworks/base/Android.mk:879: warning: FindEmulator: find: `frameworks/opt/telephony/src/java/android/provider': No such file or directory
./frameworks/base/Android.mk:884: warning: FindEmulator: find: `frameworks/opt/telephony/src/java/android/provider': No such file or directory
[410/973] including ./frameworks/native/cmds/surfacereplayer/replayer/Android.mk ...
: No such file or directory
[716/973] including ./system/sepolicy/Android.mk ...
./system/sepolicy/Android.mk:107: warning: BOARD_SEPOLICY_VERS not specified, assuming current platform version
[721/973] including ./system/update_engine/Android.mk ...
build/core/notice_files.mk:114: error: missing separator.
18:01:57 ckati failed with: exit status 1
make: *** [run_soong_ui] Error 1

#### make failed to build some targets (38 seconds) ####

Fixed many errors by running dos2unix on .SH and .BASH files but no idea about these. !!!

FYI … My code base in on linux machine, and compiling it via ssh from another machine

Thanks

Is there any plan to support Android 8 + OPTEE on hikey ?

Nothing firm atm.

I flashed latest Images (https://builds.96boards.org/snapshots/hikey/linaro/aosp-master/568/) , Hikey booted successfully and the version it is showing is Android P
Is that really correct ?

Master branch is currently post-O and pre-P so you’re probably looking at a pre-release P tag. Just think of it as the current master branch.

Fixed many errors by running dos2unix on .SH and .BASH files but no idea about these. !!! FYI … My code base in on linux machine, and compiling it via ssh from another machine

Real or virtual linux on a Windows host? Sounds like Windows might have touched the files for some reason? Can you also check that repo sync completed without errors?

Yes… the P-ness of the AOSP branch is a little confusing (it essentially contains post-O community contributions… but not the secret stuff Google is working on). See:
https://source.android.com/source/faqs#how-is-the-android-software-developed

Hi,

Master branch is currently post-O and pre-P so you’re probably looking at a pre-release P tag. Just think of it as the current master branch.

Yep, got that

Real or virtual linux on a Windows host? Sounds like Windows might have touched the files for some reason? Can you also check that repo sync completed without errors?

I tried on Real Linux machine but same error came up.
Yes, repo sync is completed successfully, no errors seen there

On a fresh stack itself, I am getting this error :
> source ./build/envsetup.sh
> -bash: ./build/envsetup.sh: line 1: syntax error near unexpected token $'{\r'' > 'bash: ./build/envsetup.sh: line 1: function hmm() {

Then , I ran command on my old AOSP7+OPTEE stack, and it worked fine
I wonder what would be the problem :unamused:

Thanks

There are still Windows EOL on your newly downloaded files.
Try vim build/envsetup.sh on both the new envsetup.sh and old (aosp7) envsetup.sh file and see if the EOL is different on both files? You should see lots of ^M on the new file, indicating Windows EOL. If so, you need to find out why your machine is doing that.

Compilation successful
Android Ver: 8.0.0
Security Patch Level : Oct 5, 2017

As I need to toggle between Win and Linux work env, I made git config settings as “autocrlf = true” which is causing trouble. Now , it seems everything is fine :slight_smile:

Thanks

@deepakmnvl Great! And thanks for sharing the solution, which will be helpful to others!

1 Like

Hi Victor,
How about the kernel src code ?
Can I follow the steps in “Building the kernel” section gievn here "https://source.android.com/source/devices#620userspace" ?

Thanks

Can I follow the steps in “Building the kernel” section gievn here “https://source.android.com/source/devices#620userspace” ?

I’ve not tried but should be yes.

ok, seems it is possible , as currently , am able to compile , and Image is created !!!.

My question is - is there any command like we used to compile for OPTEE+AOSP7 stack :
make -j8 TARGET_BUILD_UEFI=true TARGET_BUILD_KERNEL=true TARGET_BOOTIMAGE_USE_FAT=true

Am seeing some pointers at “https://source.android.com/source/building-kernels” but , I want to know if you guys have idea about this before I go digging

Thanks

EDIT:
I didnt understand this step :
Copy output to the hikey kernel directory (/kernel/hikey-linaro):

Copy hi6220-hikey.dtb (arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb) to the hikey-kernel directory as file hi6220-hikey.dtb-4.9.
**Copy the Image file (arch/arm64/boot/Image-dtb) to the hikey-kernel directory as file Image-dtb-4.9.**

What is " hikey-kernel directory" ?? :confused:

ANOTHER EDIT :
I think I got this, seems the dir is “device/linaro/hikey-kernel” , will try and let you know !!!

is there any command like we used to compile for OPTEE+AOSP7 stack?

No, at least not yet, because you’re using a ‘pure’ Google stack, i.e. without Linaro patches to also build the kernel when you build aosp, so you have to build the kernel manually atm.

What is " hikey-kernel directory" ?

device/linaro/hikey-kernel

EDIT: Oh, ok, you found it.

Hi ,
I am facing an error when trying to do insmod from “aosp8\device\linaro\hikey\init.common.rc” like below :
on post-fs
insmod /system/lib/myspidrv.ko
chmod 0666 /dev/myspi
chown system system /dev/myspi

Error am seeing on dmesg :
[ 7.866548] init: finit_module for “/system/lib/myspidrv.ko” failed: Operation not permitted

This approach worked in AOSP7
Now, if I run “insmod myspidrv.ko” from hikey shell, its successful !!!

Any help here is appreciated

Thanks

am able to resolve the error !!!

thanks

Would be nice if you can share the solution for the community as well. Thanks.

Sure,
I made many changes , some of these must have affected the behavior

system/sepolicy/public/domain.te
+# neverallow * ~{ system_file vendor_file rootfs }:system module_load;

system/sepolicy/public/init.te
+allow init self:capability { sys_module };
+allow init system_file:system { module_load };

Thanks

hi ,
I need to verify with “TREBLE” feature enabled on hikey.
So , as suggested in another thread, I did following changes
PRODUCT_FULL_TREBLE_OVERRIDE := true in device/linaro/hikey/hikey.mk

and am getting below errors

[  0% 16/2323] build out/target/product/hikey/obj/FAKE/selinux_policy_intermediates/plat_pub_policy.cil
out/host/linux-x86/bin/checkpolicy:  loading policy configuration from out/target/product/hikey/obj/FAKE/selinux_policy_intermediates/plat_pub_policy.conf
out/host/linux-x86/bin/checkpolicy:  policy configuration loaded
out/host/linux-x86/bin/checkpolicy:  writing CIL to out/target/product/hikey/obj/FAKE/selinux_policy_intermediates/plat_pub_policy.cil.tmp
[  0% 20/2323] Ensuring Jack server is installed and started
Jack server already installed in "/home/viswanath/.jack-server"
Server is already running
[  0% 21/2323] build out/target/product/hikey/obj/ETC/26.0.cil_intermediates/mapping/26.0.cil
Parsing out/target/product/hikey/obj/FAKE/selinux_policy_intermediates/plat_pub_policy.cil
[  0% 23/2323] build out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_policy_raw.cil
out/host/linux-x86/bin/checkpolicy:  loading policy configuration from out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_policy.conf
out/host/linux-x86/bin/checkpolicy:  policy configuration loaded
out/host/linux-x86/bin/checkpolicy:  writing CIL to out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_policy_raw.cil.tmp
[  4% 115/2323] build out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil
out/host/linux-x86/bin/checkpolicy:  loading policy configuration from out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_policy.conf
out/host/linux-x86/bin/checkpolicy:  policy configuration loaded
out/host/linux-x86/bin/checkpolicy:  writing CIL to out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil
[  5% 121/2323] build out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil
Parsing out/target/product/hikey/obj/FAKE/selinux_policy_intermediates/plat_pub_policy.cil
Parsing out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_policy_raw.cil
[ 17% 411/2323] build out/target/product/hikey/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
**FAILED**: out/target/product/hikey/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy 
/bin/bash -c "out/host/linux-x86/bin/secilc -M true -G -c 30 		out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/hikey/obj/ETC/26.0.cil_intermediates/26.0.cil out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/hikey/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy -f /dev/null"
neverallow check failed at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2479
  (neverallow base_typeattr_56_26_0 base_typeattr_57_26_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5784
      (allow hal_bluetooth_hikey hal_bluetooth_hikey_exec (file (read getattr execute entrypoint open)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5793
      (allow hci_attach hci_attach_exec (file (read getattr execute entrypoint open)))
neverallow check failed at out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4425 from system/sepolicy/public/domain.te:672
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5784
      (allow hal_bluetooth_hikey hal_bluetooth_hikey_exec (file (read getattr execute entrypoint open)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5793
      (allow hci_attach hci_attach_exec (file (read getattr execute entrypoint open)))
Failed to generate binary
Failed to build policydb
[ 17% 415/2323] build out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy
FAILED: out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy 
/bin/bash -c "(out/host/linux-x86/bin/secilc -M true -G -c 30 out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/hikey/obj/ETC/26.0.cil_intermediates/26.0.cil out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.tmp -f /dev/null ) && (out/host/linux-x86/bin/sepolicy-analyze out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.tmp permissive > out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ) && (if [ \"userdebug\" = \"user\" -a -s out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ]; then 		echo \"==========\" 1>&2; 		echo \"ERROR: permissive domains not allowed in user builds\" 1>&2; 		echo \"List of invalid domains:\" 1>&2; 		cat out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains 1>&2; 		exit 1; 		fi ) && (mv out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy )"
neverallow check failed at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2479
  (neverallow base_typeattr_56_26_0 base_typeattr_57_26_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5784
      (allow hal_bluetooth_hikey hal_bluetooth_hikey_exec (file (read getattr execute entrypoint open)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5793
      (allow hci_attach hci_attach_exec (file (read getattr execute entrypoint open)))
neverallow check failed at out/target/product/hikey/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4425 from system/sepolicy/public/domain.te:672
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5784
      (allow hal_bluetooth_hikey hal_bluetooth_hikey_exec (file (read getattr execute entrypoint open)))
    <root>
    allow at out/target/product/hikey/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5793
      (allow hci_attach hci_attach_exec (file (read getattr execute entrypoint open)))
Failed to generate binary
Failed to build policydb
[ 18% 438/2323] cc 'out/soong/.intermediates/hardware/interfaces/radio/1...armv8-a_shared_core/obj/android/hardware/radio/1.0/RadioIndicationAll.o'
[ 19% 442/2323] cc 'out/soong/.intermediates/hardware/interfaces/radio/1...4_armv8-a_shared_core/obj/android/hardware/radio/1.0/RadioResponseAll.o'
ninja: build stopped: subcommand failed.
18:26:20 ninja failed with: exit status 1
make: *** [run_soong_ui] Error 1

These errors seem to be related to bluetooth but thats not am working on
Need help in fixing these

Thanks

Did you just add PRODUCT_FULL_TREBLE_OVERRIDE to your existing code without updating (i.e. repo sync) first? I mean the existing code base might not be new enough to support it? It might be good to start from scratch with a new build just to make sure no old build artifacts are affecting the build. Btw, there’s now hikey op-tee android 8 build instruction: https://github.com/linaro-swg/optee_android_manifest/tree/lcr-ref-hikey-o.