OP-TEE / optee_os

Trusted side of the TEE
Other
1.58k stars 1.07k forks source link

Hikey 960-AOSP no interface #4087

Closed mofanv closed 4 years ago

mofanv commented 4 years ago

Hi Team,

I have built AOSP - OPTEE on my Hikey 960 (4GB). Then I connect the board to HDMI monitor and boot, but the booting stuck at the Android logo (following picture).

IMG_6490

However, I found that I can still access it via console, for example running optee_example, as follows.

[   13.022703] [drm] Config : lane_clock = 864000000
[   13.027420] [drm] PHY clock_lane and data_lane config : 
[   13.027420] rg_vrefsel_vcm=85
[   13.027420] clk_pre_delay=0
[   13.027420] clk_post_delay=41
[   13.027420] clk_t_hs_prepare=10
[   13.027420] clk_t_lpx=13
[   13.027420] clk_t_hs_zero=27
[   13.027420] clk_t_hs_trial=10
[   13.027420] data_pre_delay=61
[   13.027420] data_post_delay=0
[   13.027420] data_t_hs_prepare=9
[   13.027420] data_t_lpx=13
[   13.027420] data_t_hs_zero=12
[   13.027420] data_t_hs_trial=12
[   13.027420] data_t_ta_go=4
[   13.027420] data_t_ta_get=5
[   13.076032] [drm] clk_lane_lp2hs_time=63
[   13.076032] clk_lane_hs2lp_time=58
[   13.076032] data_lane_lp2hs_time=104
[   13.076032] data_lane_hs2lp_time=19
[   13.076032] phy_stop_wait_time=53
[   13.093951] [drm] hsa_time=33, hbp_time=111, hline_time=1650
[   13.099623] [drm] lane_byte_clk=108000000, pixel_clk=144000000
[   13.105464] [drm] dsi_mipi_init ok
[   19.870475] random: crng init done
[   19.873907] random: 3 urandom warning(s) missed due to ratelimiting

console:/ $ su
console:/ # optee_example_hello_world
D/TC:? 0 tee_ta_init_pseudo_ta_session:280 Lookup pseudo TA 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TC:? 0 load_ldelf:704 ldelf load address 0x40006000
D/LD:  ldelf:134 Loading TA 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TC:? 0 tee_ta_init_session_with_context:573 Re-open TA 3a2f8978-5dc0-11e8-9c2d-fa7ae01bbebc
D/TC:? 0 system_open_ta_binary:250 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (early TA)
D/TC:? 0 system_open_ta_binary:253 res=0xffff0008
D/TC:? 0 system_open_ta_binary:250 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (Secure Storage TA)
D/TC:? 0 system_open_ta_binary:253 res=0xffff0008
D/TC:? 0 system_open_ta_binary:250 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (REE)
D/TC:? 0 system_open_ta_binary:253 res=0x0
D/LD:  ldelf:169 ELF (8aaaf200-2450-11e4-abe2-0002a5d5c51b) at 0x40050000
D/TC:? 0 tee_ta_close_session:499 csess 0x3f09f740 id 1
D/TC:? 0 tee_ta_close_session:518 Destroy session
D/TA:  TA_CreateEntryPoint:39 has been called
D/TA:  TA_OpenSessionEntryPoint:68 has been called
I/TA: Hello World!
Invoking TA to increment 42
D/TA:  inc_value:105 has been called
I/TA: Got value: 42 from NW
I/TA: Increase value to: 43
TA incremented value to 43
D/TC:? 0 tee_ta_close_session:499 csess 0x3f0a0430 id 3
D/TC:? 0 tee_ta_close_session:518 Destroy session
I/TA: Goodbye!
D/TA:  TA_DestroyEntryPoint:50 has been called
D/TC:? 0 destroy_context:298 Destroy TA ctx (0x3f09fc00)

I wonder AOSP should be able to provide interface even with OPTEE right? Could you please let me know is this as expected or normal? What might be wrong here. Thank you in advance! Best, Fan

jbech-linaro commented 4 years ago

I wonder AOSP should be able to provide interface even with OPTEE right? Could you please let me know is this as expected or normal? What might be wrong here.

AOSP is a huge project with hundreds of gits. What we've been trying to do is to ensure that with a normal AOSP provided by Google, you should be able to run OP-TEE. In you case, OP-TEE seems to work perfectly fine. So, the display related problem is elsewhere, where other people are subject matter experts. You could try 96Boards forum alternatively try to reach out to Google / AOSP people. @vchong , anything you'd like to add?

vchong commented 4 years ago

@mofanv How did you build? Did you try the build with another monitor? Did you try the monitor with a regular build, i..e with no OP-TEE? The hikey* boards have issues with some monitors so let's rule the monitor out first.

mofanv commented 4 years ago

Hi @jbech-linaro @vchong , thank you for your reply.

I followed AOSP page https://optee.readthedocs.io/en/latest/building/aosp/aosp.html using master branch, and I'm using Ubuntu 14 on Intel NUC. Because of its limited computational resources and hard disc, I chose to first try AOSP-OPTEE directly. And there is no errors during sync and build. So I didn't try the regular repo from Android website.

I just tested another monitor and it is still the same (stuck at the android logo). Do you have other insights? Seems I might need to first test the board on the regular repo in official page, or ask in AOSP or hikey forum...

vchong commented 4 years ago

@mofanv Np. Thanks for the info. Don't quite remember if there were (non-OP-TEE related ;)) display issue but the master branch is actually a bit behind on maintenance due to other priorities. Can you please try this branch, with sync-master-hikey960.sh and build-master-hikey960.sh instead? It's more updated but patches aren't cleaned up yet - the reason it hasn't made it to the master branch. You can try the prebuilts here first before building. Since this isn't a regular release, please report back any issues so that we may try to help resolve them as well.

mwerensteijn commented 4 years ago

I can confirm that I had problems with some AOSP-OPTEE branches when trying to run it on my Hikey 620. I got mine working with the same repo as @vchong has listed. I am using tag 3.8.3 without any issues, xtest runs without any failed tests and the display works fine.

I suggest to test it out: git clone https://github.com/linaro-swg/optee_android_manifest -b 3.8.3

And follow the listed build steps: link

mofanv commented 4 years ago

@vchong @mwerensteijn Thank a lot! However, during flashing with prebuilts in https://people.linaro.org/~victor.chong/prebuilt/master/390-dirty/hikey960/, I'm facing another problem when flashing system.img as follows.

target reported max download size of 134217728 bytes
Invalid sparse file format at header magi
error: write_sparse_skip_chunk: don't care size 256472560 is not a multiple of the block size 4096
error: write_sparse_skip_chunk: don't care size 122258928 is not a multiple of the block size 4096
fastboot: ../libsparse/sparse.c:144: write_all_blocks: Assertion `pad >= 0' failed.
./flash-all.sh: line 41:  6197 Aborted                 (core dumped) fastboot flash system "${OUT_IMGDIR}"/system.img
target reported max download size of 134217728 bytes

Do you know how to fix this? The error is saying size is not a multiple of the block size 4096.

I will try the branch 3.8.3, thanks for the suggestions. But before that, I wonder is there prebuilt of this branch? I know there are some prebuilt in http://snapshots.linaro.org/android/android-lcr-reference-hikey960-q/, but I do see the version w.r.t. branch. Syncing and building from the source is really time-consuming.. if I could try the prebuilt first and then build from the source, that will be really nice. thank you!

mwerensteijn commented 4 years ago

By browsing through his prebuilt website I found the following folder: https://people.linaro.org/~victor.chong/prebuilt/pie/382/ From the URL I suspect it is version 3.8.2, maybe you can try that one

mofanv commented 4 years ago

Finally it works. Sorry that I made a stupid mistake, did not unzip system.img.xz to system.img properly...

To summarize, The 390 branch works without display problem (i.e. with inferface). However, 383 branch here still has the display problem, hanging on the Android logo.

Thank a lot for your help.