2024-05-23 09:35 PM
Hello,
I am currently engaged in a project that involves using TrustZone to securely display an image on the STM32MP135F-DK. I'm facing several challenges, especially in configuring the framebuffer for secure display purposes:
1. Running the 'hello_world' Example: I am experiencing issues with running the TrustZone 'hello_world' example from OP-TEE on the board. I tried to get the OP-TEE version that supports STM32MP1, compile OP-TEE, and copy the output OP-TEE trustzone's hello_world binary to the board. But it cannot be directly executed on the board.
2. Triggering TrustZone: After installing the SDK for STM32MP135F-DK and recompiling the kernel and drivers as per the instructions from the wiki, I am unsure of how to proceed with testing the OP-TEE 'helloworld' example. Should I compile it within the SDK and then transfer the binary to the board?
3. Secure Framebuffer Configuration: I noticed that the dts file for STM32MP135F-DK already defines a secure framebuffer. Does it provide interfaces to write to the framebuffer, or should I consider writing a driver myself?
I would greatly appreciate any advice you could provide on these issues. Thank you for your time!
2024-05-24 06:03 AM - edited 2024-05-24 06:12 AM
Hi @hema123,
1. I'am not sure to get the point, so here are several questions to help me to understand your problem:
Could you please share the link of the 'hello_world' Example ?
Did you enable TUI ?
# Enable Trusted User Interface
-CFG_WITH_TUI ?= n
+CFG_WITH_TUI ?= y
When you say "But it cannot be directly executed on the board" : could you please elaborate a bit more (command lines, logs....)
2. Yes.
3. The interface to write into secure framebuffer is available in optee-os/lib/libutee/tui/tui_private.h : it will be usefull to write our own TA.
BR,
Christophe
2024-05-26 12:02 PM
Thanks for your kind help. I am new to STM32 and OP-TEE and I have some follow-up and basic questions about how to write a frame buffer in STM32MP135
(1) How to include <tui_private.h>? I start with the hello_world example provided by OP-TEE, and tried to include the header in the hello_world_ta.c file. However, I encounter “tui_private.h: No such file or directory”.
Should I also update Makefile or something to make it work?
(2)Then I tried some maybe external APIs, and I include <tee_tui_api.h> in the hello_world_ta.c file. No more other changes to other files. Then I tried to play with function call such as TEE_TUIGetScreenInfo() defined in tee_tui_api. The code part doesn't have any specific error. However, during make procedure, I got error like arm-ostl-linux-gnueabi-ld.bfd:/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/ta/hello_world_ta.c:126: undefined reference to `TEE_TUICheckTextFormat'. Should I modify the host side or makefile to make it work?
Sorry for these basic questions and any help or ideas will be very helpful.
2024-05-28 07:39 PM
Hi, the error I got is
arm-ostl-linux-gnueabi-ld.bfd: ./hello_world_ta.o: in function `test_TEE_TUIDisplayScreen_1':
/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/ta/hello_world_ta.c:121: undefined reference to `TEE_TUIGetScreenInfo'
I also recompile the Kernel and it looks like CFG_WITH_TUI is enabled by default after adopting the patches using the command suggested by the official website?
"
$ tar xf ../fonts.tar.gz
$ for p in `ls -1 ../*.patch`; do git am $p; done
"
Thanks for your help and insights.
2024-05-29 07:59 AM
Hello @hema123,
TUI is enabled by default for MP13 in OP-TEE since Ecosystem-v5.0.0.
tui_private.h is an internal header file from OP-TEE, and it is not exposed in the SDK, that's why the compilation fails when you want to include it.
You need to use the TUI API which is available through SDK:
#include "tee_tui_api.h"
Regarding the error "undefined reference to `TEE_TUIGetScreenInfo'", I need more time and I will come back to you later.
BR,
Christophe
2024-05-31 02:33 AM
Hello @hema123,
The link error "undefined reference to `TEE_TUIGetScreenInfo'" is due to libutee.a which is compiled for MP15 in the SDK, so TUI methods are not compiled in this library : I raised a ticket internally to fix the problem.
Waiting a correction, I would recommand to build OP-TEE by yourself (wiki link) for MP13, and compile your TA based on hello_world by using new built libutee.a instead of the one from SDK.
BR,
Christophe
2024-05-31 01:41 PM - edited 2024-05-31 01:45 PM
Thank you so much for your help. I followed your advise and rebuild OP-TEE myself. It generated a new libutee.a, which is larger than the libutee.a from the sdk (the sdk one is 1.5MB and the new one is 2.4MB). Then I replace the libutee.a in the SDK folder with the new compiled one (inside export-usr_ta/lib/), and recompile my TA inside SDK.
I got some new errors:
make
make -C host CROSS_COMPILE="arm-ostl-linux-gnueabi-" --no-builtin-variables
make[1]: Entering directory '/home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/host'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/host'
make -C ta CROSS_COMPILE="arm-ostl-linux-gnueabi-" LDFLAGS=""
make[1]: Entering directory '/home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/ta'
LD 8aaaf200-2450-11e4-abe2-0002a5d5c51b.elf
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/include/optee/export-user_ta/lib/libutee.a(image_png.o): in function `read_cb':
/home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:41: undefined reference to `png_get_io_ptr'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:47: undefined reference to `png_error'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/include/optee/export-user_ta/lib/libutee.a(image_png.o): in function `error_cb':
/home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:27: undefined reference to `png_get_error_ptr'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/include/optee/export-user_ta/lib/libutee.a(image_png.o): in function `image_set_png':
/home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:71: undefined reference to `png_sig_cmp'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:74: undefined reference to `png_create_read_struct'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:79: undefined reference to `png_create_info_struct'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:81: undefined reference to `png_destroy_read_struct'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:88: undefined reference to `png_set_read_fn'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:89: undefined reference to `png_read_info'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:91: undefined reference to `png_get_image_width'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:92: undefined reference to `png_get_image_height'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:93: undefined reference to `png_get_color_type'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:94: undefined reference to `png_get_bit_depth'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:105: undefined reference to `png_set_strip_16'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:114: undefined reference to `png_get_valid'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:115: undefined reference to `png_set_tRNS_to_alpha'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:121: undefined reference to `png_set_filler'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:108: undefined reference to `png_set_palette_to_rgb'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:112: undefined reference to `png_set_expand_gray_1_2_4_to_8'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:127: undefined reference to `png_read_update_info'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:139: undefined reference to `png_destroy_read_struct'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:121: undefined reference to `png_set_filler'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:125: undefined reference to `png_set_gray_to_rgb'
arm-ostl-linux-gnueabi-ld.bfd: /home/yizhi/STM32MPU_workspace/tmp/en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.19.0-stm32mp-r1-r0/optee-os-stm32mp-3.19.0-stm32mp-r1/lib/libutee/tui/image_png.c:135: undefined reference to `png_read_image'
make[1]: *** [/home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/include/optee/export-user_ta/mk/link.mk:120: 8aaaf200-2450-11e4-abe2-0002a5d5c51b.elf] Error 1
make[1]: Leaving directory '/home/yizhi/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Developer-Package/stm32mp1-openstlinux-23.06.21/sources/optee_examples/hello_world/ta'
make: *** [Makefile:10: all] Error 2
I dont know whether I am doing this in a right way? Are there any other files I need to update in the SDK? I also replaced the libpng.a in the SDK with the new compiled libpng.a. But it didnt change anything/ouput.
Thanks in advance.
2024-05-31 02:00 PM
OK. The problem turns to be the Makefile wont include libpng during compilation.
I updated the ta_dev_kit.mk in the SDK to include png and zlib anyway and there is no more compilation error.
libnames += png
libdeps += $(ta-dev-kit-dir$(sm))/lib/libpng.a
libnames += zlib
libdeps += $(ta-dev-kit-dir$(sm))/lib/libzlib.a
ifeq ($(CFG_WITH_TUI),y)
libnames += zlib
libdeps += $(ta-dev-kit-dir$(sm))/lib/libzlib.a
libnames += png
libdeps += $(ta-dev-kit-dir$(sm))/lib/libpng.a
endif
However I am curious why the CFG_WITH_TUI is a false statement and how can I change it to y. I am not familiar with the configuration procedure. Any ideas I can change it to y?
2024-06-07 12:57 AM
Thank you so much for your reply. The library and compilation can work well now without any problem.
However, I tried to add the following code in TA and get a return of 0xffff000a
TEE_Result ret = TEE_TUIGetScreenInfo(TEE_TUI_PORTRAIT, 2, &myScreenInfo);
if (ret != TEE_SUCCESS) {
result = ret;
}
It looks like this error code indicate the function is not supported. I cannot display anything neither using TEE_TUIDisplayScreen()
I am worrying that my code is wrong somewhere. May I ask if there is any code sample (even a blank screen) I can test/play with TUI so I can start there ensuring everything is correct.
My board is STM32MP135F-DK.
Thanks!
2024-06-07 01:19 AM
Hi @hema123,
I would recommand you to have a look into TEE_TUIGetScreenInfo() function and check the reason why it could return an error:
if (screenOrientation != TEE_TUI_LANDSCAPE)
res = TEE_ERROR_NOT_SUPPORTED;
BR,
Christophe