AOSP+OPTEE: How to build optee_example host only


Hi there,

I boot up my hikey960 with AOSP+OPTEE as the instructions here: Now I’m trying to rewrite some host code in external/optee_examples while I’m wondering how can I build the host without building the whole system?

Thank you.


Answered in:


Hello, I want to build AOSP+OPTEE,but the instructions is a little brief for me. And I want to know whether I should build a AOSP according to Could you give me a more detail instruction? Thank you in advance.


Which instructions are brief? The build according to is the standard/generic hikey 620/960 build, but it doesn’t support OP-TEE. The OP-TEE build [1] builds upon the one in, with additions to support OP-TEE. It also, among other things, wraps the instructions in into build scripts so you don’t have to run them again manually. Just run the build scripts.

[1] Suggest you use the 3.4.0 stable build:

[EDIT] Please use 3.4.1 build instead:


Thank you a lot! I will try it. By the way ,It seems that the instruction does not distinguish the 4G ram and 3GRam board of hikey960. What configurations should I change or add if I want to build for the 4g RAM hikey960 board?


Hello ,I am not sure whether it is right that satisfy the 4G hikey960 board by adding options when run the build command just like the hikey620 do:

# for HiKey620
./ #or `./ -v p -4g` for a 4GB board!

and can I use the binary files and images directly instead of finishing the whole steps and build the files?
Thank you very much!


The ‘-4g’ switch for the hikey620 build is for the eMMC storage size, not ram, because it comes with 4 or 8 g storage. It has no effect on the hikey960 build. The hikey960 only comes with 32g of storage. Afaik, there’s no AOSP specific option for different amount of ram. This applies to both the hikey620 and hikey960.

can I use the binary files and images directly instead of finishing the whole steps and build the files?

You mean using prebuilt images? Click on the ‘Download’ link on


Hello! Thank you very much! I have downloaded these binary files, and flashed them. cuz I don’t have the dictionary tree, so I just run the last handful lines of command one by one in “”.

fastboot flash ptable “${INSTALLER_DIR}”/prm_ptable.img
fastboot flash xloader “${INSTALLER_DIR}”/hisi-sec_xloader.img
fastboot flash fastboot “${INSTALLER_DIR}”/l-loader.bin
fastboot flash fip “${INSTALLER_DIR}”/fip.bin
#fastboot flash nvme “${INSTALLER_DIR}”/hisi-nvme.img
fastboot flash boot “${ANDROID_PRODUCT_OUT}”/boot.img
fastboot flash cache “${ANDROID_PRODUCT_OUT}”/cache.img
fastboot flash system “${ANDROID_PRODUCT_OUT}”/system.img
fastboot flash userdata “${ANDROID_PRODUCT_OUT}”/userdata.img
fastboot flash vendor “${ANDROID_PRODUCT_OUT}”/vendor.img

and the downloaded files are not boot.img, cache.img, ramdisk.img, but boot.img.xz, cache.img.xz ramdisk.img.xz and so on. so I use the .xz files to flash.
after these steps, I power up the board but these error occured:

remove-symbol-file /home/victor.chong/work/swg/aosp/tst/optee/edk2/Build/HiKey90
Image Return Status = Success
[Bds]Booting Boot from SD
[Bds]Booting Grub
[Bds]Booting Android Boot
add-symbol-file /home/victor.chong/work/swg/aosp/tst/optee/edk2/Build/HiKey960/0
Loading driver at 0x000B9B1E000 EntryPoint=0x000B9B1F000 AndroidBootApp.efi
Failed to get Abootimg Size: Invalid Parameter
Failed to load boot image from boot partition: Invalid Parameter
Failed to boot from partition: Invalid Parameter
Error: Image at 000B9B1E000 start failed: Invalid Parameter
remove-symbol-file /home/victor.chong/work/swg/aosp/tst/optee/edk2/Build/HiKey90
Image Return Status = Invalid Parameter
[Bds]Booting Android Fastboot
add-symbol-file /home/victor.chong/work/swg/aosp/tst/optee/edk2/Build/HiKey960/0
Loading driver at 0x000B9B1B000 EntryPoint=0x000B9B1C000 AndroidFastbootApp.efi
Android Fastboot mode - version 0.7.
Press RETURN or SPACE key to quit.

What mistake I have made, and what to do to sovel these problems? does these flashed files include optee_os? Is boot.img optee_os? or what version of optee should I use. I am so confused!

I want to follow these instruction to build my optee_AOSP
but I have always met the time-out and fetch errors when sync it :

0curl: (7) Failed to connect to port 443:
0curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.

But I can successfully sync the AOSP repo according to

Are there any other way to solve the sync error?
Thank you for your kindly reply!


unxz *.img.xz to extract the files from .img.xz to .img before running

optee_os is in fip.bin, version 3.4.0

not sure about the sync error, it should be the same command in the script, nothing fancy about it


Thank you so much! now it seems works, and I can also build my own optee-asop build. I am so lucky to get your help. BTW, it seems a bug or incompatibility in HDMI display, The screen always flickers and display disorder. I am not sure it is a known issue or not.


You’re welcome! Glad you got it to work. For the display, try running wm size 1280x720 on the board and reboot. If that also fails then sorry, no more ideas. Perhaps others can comment.


Dear vchong
I set the resolution of the screen, and it still disorder. but it doesn’t matter!
In the Android system, I can run the xtest without any error from the console, but I can find the location of the xtest and its .ta files. xtest dosen’t appear in /bin or /system/bin or some other folders which seem include binary files. Did I miss something or make some mistakes? If I find the folder that locate xtest and the corresponding .ta files respectively, It seems that I can build an example program and push the “host” files and .ta files to the folder respectively using adb instead of build them in the filesystem, and run the program. Is that right?
I want to build a simple android app with optee, and I have refered to your reply in this link
and the tutorials you mentioned in the link above. It is quite clear for me after that.