Android + OP-TEE compile error

hey @vchong ,
above solution also didnt work.

I am getting a lot of garbage like below :
▒▒▒▒▒▒▒i{▒▒▒l▒▒▒▒▒▒▒E▒▒▒▒▒▒==▒▒▒▒333333▒▒▒▒9=▒▒▒▒▒▒▒▒333333▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒i{▒▒▒H▒▒▒▒▒▒▒E▒▒▒▒▒▒▒▒-#-▒▒▒▒333333▒▒▒▒▒▒▒▒▒▒▒▒▒▒333333▒▒▒▒▒=

Am connecting pins 2,3,4 only , from hikey board to PC ( via convertor )
I dont know if there are any voltage differences ( 1.8 , 3.3 etc )
Do you have any idea of this ?

Otherwise , for using uart3, I will try to tap out wires from LS connector by soldering.
Can you tell me which pins should I use ?

Thanks

Did you try swapping tx and rx? Also verify 115200 8N1 and no flow control for your settings? What kind of cable are you using? It has to be 1.8v!

In any case, please refer to http://wiki.lemaker.org/HiKey(LeMaker_version):UART for pin numbers and other details. Note the warning to NOT connect J801-01 to VCC, or else you might damage the board!

Same result with uart3 too.

Am getting garbage , but a thing to note → when I connect uart out , it seems the booting is halted.
Android logo UI is not appearing and I am not getting adb shell

And it seems , even uart3 requires 1.8V connector. and seems my connector is not.
Is there any workaround for this ?

Can we get all these logs on logcat itself ?

PS: Meanwhile, I will scout for a compatible cable in the market

when I connect uart out , it seems the booting is halted.
Android logo UI is not appearing and I am not getting adb shell

Not sure here. If it boots fine without the uart, then sounds like a bad connection somewhere.

Afaik all uarts are 1.8v. The usb adapter board (http://www.96boards.org/product/debug/) level shifts this to 3.3v so you can use a regular usb cable, but yes, it does block other connections so maybe tapping out is not a bad idea.

The effort to get these onto logcat was abandoned. You can refer to https://github.com/OP-TEE/optee_os/pull/810 for more details. At least one other user wants to try it.

You can check out the cable on https://github.com/OP-TEE/optee_os/pull/810 as well.

HI @vchong
I already tried this ( https://github.com/OP-TEE/optee_os/pull/810 )
But , it didnt work.

So , regarding logs from uart , my HW team is looking into it to get a working cable.

My another query :
I am trying to access gpio pins of my spi board from OPTEE. Seems there is some differences in pin numbers between REE and TEE.
I am refering https://github.com/OP-TEE/optee_os/issues/944.

You gave addresses like this :
#define GPIO2_BASE 0xF8013000 //16-23

Can you share the date sheet containing these kinds of memory mapping info for lemaker hikey board ?

Thanks

I already tried this ( https://github.com/OP-TEE/optee_os/pull/810)
But , it didnt work.

The patch is old and abandoned so it might require effort to get it to work again.

Can you share the date sheet containing these kinds of memory mapping info for lemaker hikey board ?

The data sheet is here: https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/HardwareDocs/Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf. Section 5.1.2. The register addresses are here too: https://github.com/OP-TEE/optee_os/issues/944#issuecomment-238070973.

Hello @vchong

I am facing one compilation issue in latest optee code (followed steps mentioned in https://github.com/linaro-swg/optee_android_manifest/tree/hikey-n-4.9 link and applied patches).

Please find below error.

[ 3% 1587/47715] build out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy
FAILED: /bin/bash -c “(out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/hikey/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/hikey/obj/ETC/sepolicy_intermediates/policy.conf ) && (out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/hikey/obj/ETC/sepolicy_intermediates//sepolicy.dontaudit out/target/product/hikey/obj/ETC/sepolicy_intermediates/policy.conf.dontaudit ) && (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 )”
device/linaro/hikey/sepolicy/hal_bluetooth_hikey.te:5:ERROR ‘syntax error’ at token ‘hal_server_domain’ on line 20715:

hal_server_domain(hal_bluetooth_hikey, hal_bluetooth)
checkpolicy: error(s) encountered while parsing configuration
out/host/linux-x86/bin/checkpolicy: loading policy configuration from out/target/product/hikey/obj/ETC/sepolicy_intermediates/policy.conf
[ 3% 1587/47715] host Java: doclava (out/host/common/obj/JAVA_LIBRARIES/doclava_intermediates/classes)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 3% 1587/47715] target Java: core-all (out/target/common/obj/JAVA_LIBRARIES/core-all_intermediates/classes)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 3% 1587/47715] target Export Resources: framework-res (out/target/common/obj/APPS/framework-res_intermediates/package-export.apk)
warning: string ‘candidates_style’ has no default translation.
warning: string ‘gsm_alphabet_default_charset’ has no default translation.
warning: string ‘wfcSpnFormat’ has no default translation.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1

as i see while applying patches 4th patch(./android-patchsets/swg-mods) in the order is not applying correctly.

does it matter ?

Please help me for this compilation issue.

Thanks,
Raj.

Fixed. Please repo sync, reapply patches and try building again.

still same error even after i do sync.

can you please support.

Sorry, I forgot to mention, you also have to cd to .repo/local_manifests and run git pull. So

cd .repo/local_manifests
git pull
cd ../../
repo sync
# apply patches

If you’re still getting errors, it might help to delete the out folder before rebuilding.

Hello @vchong

Thanks for immediate update…my code compilation is ok now.

I have flashed the images on hikey board as mentioned in http://www.96boards.org/documentation/ConsumerEdition/HiKey/Installation/LinuxFastboot.md/ link.

After flashing these images i was unable to see my device with adb devices command(this is neither cable nor any other hardware problem because on same hardware i have tested with @deepakmnvl images and it is fine with those images).

It might be images problem which i was understood after cross checking @deepakmnvl images (boot_fat.uefi image is may be problem in my images).

can you please help me for this.

Thanks,
Raj.

Not sure. Maybe adb is on tcp. Can you connect from you pc using command below?

adb tcpip 5555 adb connect <hikey's ip address>:5555

You can try setting it back to usb from the hikey serial console using command below.
adb usb

hi @vchong,
I got the cable now ( 1.8v supported ) , and now I can see the OPTEE logs .
But , seems , not all logs are not appearing

I did below changes as per your previous suggestion

1. In device/linaro/hikey/uefi-tools/platforms.config, under the [hikey] node, uncomment the 3 lines required to use UART0. Then rebuild fip.bin.
2. In device/linaro/hikey/bootloader/EFI/BOOT/grub.cfg, line 6, change both ttyFIQ0 to ttyAMA0 and rebuild the image.
and 3. My build command has CFG_CONSOLE_UART=0

This is the only log appearing from boot :

debug EMMC boot: print init OK
debug EMMC boot: send RST_N .
debug EMMC boot: start eMMC boot......
load fastboot1!
NOTICE: acpu_dvfs_set_freq: set acpu freq success!NOTICE: BL2: v1.1(release):36aa82d
NOTICE: BL2: Built : 18:02:35, May 9 2017
NOTICE: BL3-1: v1.1(release):36aa82d
NOTICE: BL3-1: Built : 18:02:35, May 9 20INFO: TEE-CORE: Initializing (2.3.0-dev #46 Tue May 9 12:32:25 UTC 2017 aarch64)
INFO: TEE-CORE: Initialized
UEFI firmware (version Alpha built at 10:33:12 on Apr 4 2017)
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable, no randomness supplied
EFI stub: Using DTB from configuration table
Failed to handle fs_proto
EFI stub: ERROR: Failed initrd from command line!
EFI stub: Exiting boot services and installing virtual address map...

Is this right ?

an update regarding logs :
When I build with TARGET_BOOTIMAGE_USE_FAT=true and flash boot_fat.uefi.img , I get some more logs .

Still , it seems I am not able to see all kernel logs , as seen in some posts in optee_os github :rolling_eyes:

EDIT :
Also , after boot-up , I am direclty getting the hikey promp with below msg.

[ 22.393142] healthd: battery l=100 v=0 t=42.4 h=2 st=2 chg=a
[ 22.900320] init: write_file: Unable to open ‘/proc/sys/vm/extra_free_kbytes’: No such file or directory
[ 24.123564] acc_open
[ 24.126026] acc_release
[ 28.517927] init: Service ‘bootanim’ (pid 1919) exited with status 0
[ 37.113208] EXT4-fs (mmcblk0p9): re-mounted. Opts: (null)
[ 84.640223] ttyAMA ttyAMA0: 1 input overrun(s)

hikey:/ $

Is this fine ?

After making the code changes and rebuilding android images, you did also rebuild and reflash fip.bin as well, right? fip.bin has to built and flashed separately of the regular build images.

INFO: TEE-CORE: Initialized means OP-TEE is loaded and initialized so it should be ok. Probably this is not a debug build so there are not many logs. Regarding kernel logs, have you tried comparing logs from a normal boot to see what’s missing? Not sure why there’s an overrun either. As mentioned before, I’ve not tried this and can only give suggestions, so maybe try:

  1. In device/linaro/hikey/bootloader/EFI/BOOT/grub.cfg, copy line 11 to line 6, change both ttyFIQ0 to ttyAMA0, and change 0xf7113000 to 0xf8015000.

  2. For the overrun, perhaps you can try this: http://www.linuxquestions.org/questions/linux-kernel-70/tty-usb-input-overruns-4175512707/

hi @vchong ,
I am trying to create a fresh AOSP stack.

When I am applying 1st patch , I am getting below error :

[10:06:28]svaddi@[~/Downloads/deepak/aosp2]$ ./android-patchsets/hikey-n-workarounds
=== Applying 17707/1 ===
From git://android-review.linaro.org/device/linaro/hikey

  • branch refs/changes/07/17707/1 → FETCH_HEAD
    error: could not apply 6e4ca3f… init rc files: enabled adb over tcpip by default
    hint: after resolving the conflicts, mark the corrected paths
    hint: with 'git add ’ or 'git rm ’
    hint: and commit the result with ‘git commit’
    17707/1 failed to apply, please fix
    HEAD is now at 1b597d4 hikey: remove redundant CONFIG_DRIVER_NL80211 :=y

Can you pls have a look at it ? and also other patchsets too ?

Thanks

Which branch are you using? Did you repo sync first? Anyway, in case you’re not aware, https://github.com/linaro-swg/optee_android_manifest/tree/hikey-n-4.9 is now obsolete. We’ve moved to an OP-TEE 2.4.0 build so please use https://github.com/linaro-swg/optee_android_manifest/tree/hikey-n-4.9-240. The 2.3.0 build has been ‘archived’ at https://github.com/linaro-swg/optee_android_manifest/tree/hikey-n-4.9-230 with slightly different build instructions, but I haven’t really tested it.

oohoo… didnt know about that.
Thanks for info

Hello vchong,

I have tried to compile hello world ta using above links with not including whole source code of AOSP.

I have maintained build,device,kernal,optee_os,out and prebuilt folders and in extrenal folder just optee_hello_world and optee_client only and tried to compile but got below errors.

main.c:28:17: fatal error: err.h: No such file or directory
#include <err.h>

even if i comment err.h in main.c to check it is giving same for stdio.h and string.h.

so could please let me know how these files are getting included in complete AOSP stack and how we can avoid that while building for specific helloworld ta.

PS : i have used below toolchains in AOSP stack.

prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

Thanks,
Raj

I’m not sure since I’ve not tried building like this.
Searching through my source tree I see stdio.h in below additional directories that you didn’t maintain, so maybe try adding them.

bionic
ndk
development