How to view log for OPTEE

I have setup a branch for AOSP + OPTEE for the hikey 960 board.
My TA code has several IMSG() calls. When I invoke my TA I don’t see them in the log.

I am viewing the log by attaching a UART to USB device https://www.seeedstudio.com/96Boards-UART-p-2525.html, and viewing them from a Linux machine using the screen command (the log is coming over UART 6 on the low speed header).

Which file should I change in OPTEE so I can see its log along with the normal world log over UART6 on the low speed header ?

device/linaro/hikey/

diff --git a/optee-packages.mk b/optee-packages.mk
index b748bc6d..de90e263 100644
--- a/optee-packages.mk
+++ b/optee-packages.mk
@@ -3,6 +3,7 @@ OPTEE_PLATFORM_FLAVOR ?= $(TARGET_DEVICE)
 OPTEE_CFG_ARM64_CORE ?= y
 OPTEE_TA_TARGETS ?= ta_arm64
 OPTEE_OS_DIR ?= optee/optee_os
+OPTEE_EXTRA_FLAGS ?= CFG_TEE_CORE_LOG_LEVEL=3 CFG_TEE_TA_LOG_LEVEL=3 DEBUG=1
 BUILD_OPTEE_MK := $(OPTEE_OS_DIR)/mk/aosp_optee.mk
 
 # OP TEE client library and service

Will the above edits put TEE logs on UART 3 or UART 6 ?

Neither. The above edits just allows you to see debug logs. They don’t control which UART the logs go to. That’s done by optee_os. For hikey960, UART 6 is used by default for console logs. UART 3 is used for hikey620.

The compilation worked for the hikey 960 branch.

Will the same changes also work if the compilation is done for the hikey 620 board ?

I have a separate branch for hikey 620 compilation. When I added the following line in optee-packages.mk, the compilation fails as shown after. The branch was downloaded on Sept 8.

OPTEE_EXTRA_FLAGS ?= CFG_TEE_CORE_LOG_LEVEL=3 CFG_TEE_TA_LOG_LEVEL=3 DEBUG=1

optee_android_manifest/out/target/product/hikey/optee/arm-plat-hikey/core/arch/arm/kernel/thread_a64.o: In function `el0_fiq_a32’:
optee_android_manifest/optee/optee_os/core/arch/arm/kernel/thread_a64.S:314:(.text.thread_excp_vect+0x724): additional relocation overflows omitted from the output
core/arch/arm/kernel/link.mk:35: recipe for target ‘optee_android_manifest/out/target/product/hikey/optee/arm-plat-hikey/core/all_objs.o’ failed
make: *** [optee_android_manifest/out/target/product/hikey/optee/arm-plat-hikey/core/all_objs.o] Error 1
make: Leaving directory ‘optee_android_manifest/optee/optee_os’
[ 1% 2/147] build android_kernel

It should work for the 620 as well. Try deleting out/target/product/hikey/optee/arm-plat-hikey and build again.

The build error remains even if I clear out the directory out/target/product/hikey/optee/arm-plat-hikey.

@vchong Is there any other way to resolve this build error ? Or is there a different way to enable logs for the hikey 620 branch ?

@a2t2 I can reproduce the error and am debugging.

@vchong Any solution for the build error ? Thanks.

@a2t2 Sorry not yet. Our build server was down last week. Will post an update when available.

@a2t2 Please remove DEBUG=1 from optee-packages.mk. The compiler used in the tree is too old (4.9) and doesn’t seem to play nice with the DEBUG flag. Note that this will not affect your ability to view the debug logs.

The build succeeds. I will let you know if there is any issue with logs. Thanks.

@vchong Using Hikey 620, when I use DMSG() inside the core code, it doesn’t show in the log with the entry:

OPTEE_EXTRA_FLAGS ?= CFG_TEE_CORE_LOG_LEVEL=3 CFG_TEE_TA_LOG_LEVEL=3

I can see logs from TA code.

@vchong For Hikey 620, if one has to add logs in tee supplicant code, then does the configuration in optee-packages.mk cover it ? I added some DMSG() logs and I didn’t see them in the console log.

@a2t2 No, optee-packages.mk is only for optee_os and TAs. For optee_client tee supplicant, change it here: https://github.com/OP-TEE/optee_client/blob/master/config.mk#L19. However, please note that supplicant logs to a file, not console, at /data/vendor/tee/teec.log.

What about DMSG() inside core code? Still can’t see them? Does optee_os/out/arm-plat-hikey/conf.mk show CFG_TEE_CORE_LOG_LEVEL=3? Does out/dist/fip.bin have a newer date than optee_os/out/arm-plat-hikey/core/tee.bin? Just trying to make sure optee_os is rebuilt with the new config and fip.bin is rebuilt with the new optee_os (tee.bin) and flashed.