linaro-swg / optee_examples

OP-TEE Sample Applications
Other
163 stars 140 forks source link

how to enable logging within TA #82

Closed sammyne closed 2 years ago

sammyne commented 3 years ago

https://github.com/linaro-swg/optee_examples/blob/0607ed40746afe4cb8993149a6f275df648f7bad/hello_world/ta/hello_world_ta.c#L132

Hey~ Really appreciate if someone could help me in switching on logging macros like IMSG within TA~

jforissier commented 3 years ago

Hi,

You need to make sure CFG_TEE_TA_LOG_LEVEL is not 0 when building optee_os (as this would disable any TA logging) and is 2 or higher when building the TA (2 is TRACE_INFO). In practice just set it to 2 or 3 and rebuild both optee_os and the TA.

Note, for optee_os you can check the actual value that was used during the build in the generated conf.mk in the optee_os output directory.

sammyne commented 3 years ago

Great thanks 😄

Is it possible for me just override CFG_TEE_TA_LOG_LEVEL in the hello_world example

https://github.com/linaro-swg/optee_examples/blob/0607ed40746afe4cb8993149a6f275df648f7bad/hello_world/ta/Makefile#L1

to something like

CFG_TEE_TA_LOG_LEVEL := 4

and then rebuild TA to make it effective?

I tried it without rebuilding optee_os and failed~ So I just wondering if bringing this update of logging level into effect must rebuild the optee_os?

@jforissier

sammyne commented 3 years ago

Besides, setting CFG_TEE_TA_LOG_LEVEL=3 in optee_os/mk/config.mk and rebuilding optee_os and optee_examples doesn't help either = =

jforissier commented 3 years ago

Hi @sammyne ,

Do you see the Hello World! message when you run optee_example_hello_world with unmodified source code (both optee_os and optee_examples unmodified). You should.

sammyne commented 3 years ago

Hi @sammyne ,

  • CFG_TEE_TA_LOG_LEVEL ?= 4 and CFG_TEE_TA_LOG_LEVEL := 4 in optee_examples have the same effect assuming you don't set this value somewhere else. We normally do not set CFG_ values using := because doing so introduces different behaviors with environment variables and command line arguments (CFG_XYZ=y make vs. make CFG_XYZ=y).
  • As long as CFG_TEE_TA_LOG_LEVEL is 1 or higher in optee_os/mk/config.mk, you should see the TA traces. This value is used when building libutils.a so if you change it you also need to relink the TA.

Do you see the Hello World! message when you run optee_example_hello_world with unmodified source code (both optee_os and optee_examples unmodified). You should.

I should, but it still failed me= =

Having pulled the project from fresh and building with make CFG_TEE_TA_LOG_LEVEL=3 -j2 still produces no log like Hello World! for optee_example_hello_world.

My building goes

  1. build the whole project in a powerful machine
  2. copy the artifacts built into a prepared ubuntu 20.04.1 VM
  3. change to the build dir
  4. run make run-only
  5. run the optee_example_hello_world in the secure world terminal

final output goes as

Welcome to Buildroot, type root or test to login
buildroot login: root
# /usr/bin/optee_example_hello_world 
Invoking TA to increment 42
TA incremented value to 43
jbech-linaro commented 3 years ago

4. run make run-only

This doesn't rebuild anything at all ... try make run and it'll rebuild before running.

sammyne commented 3 years ago
  1. run make run-only

This doesn't rebuild anything at all ... try make run and it'll rebuild before running.

In my case, everything is built remotely and then pulled back to a ubuntu 20.04.1 VM in my desktop. Therefore, run make run-only should be enough. @jbech-linaro

github-actions[bot] commented 2 years ago

This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.