Trouble building example “Hello World” on the Jetson Orin Nano

Hello together,

I am encountering issues while trying to build the hello_world example on my host machine for deployment on my Jetson Orin Nano.

By following the section “How to Cross Compile a Trusted Application and Run it on Jetson Devices” in the offical OP-TEE documentation, I was able to compile the hwkey-agent sample that comes with the BSP source package and get it running successfully with an encrypted eks_t234.img.

After getting the hwkey-agent running, I wanted to try another example. I chose the example hello_world from the official OP-TEE sample repository.

To build the hello_world example, I copied the entire hello_world folder into the /optee/samples/ directory, where other examples (such as hwkey-agent) are located. I then ran a simple make -C host command in the /optee/samples/hello_world directory to build the host (the make -C ta worked perfectly already). Unfortunately, this resulted in the following error:

nik71841@lap-morphis:~/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/samples/hello_world$ make -C host CROSS_COMPILE=${CROSS_COMPILE_AARCH64} TEEC_EXPORT=${TEEC_EXPORT}
make: Verzeichnis „/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/samples/hello_world/host“ wird betreten
cc -Wall -I../ta/include -I/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/rootfs/usr/include -I./include -c main.c -o main.o
In file included from main.c:29:
/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/rootfs/usr/include/stdio.h:205:27: error: ‘L_tmpnam’ undeclared here (not in a function)
  205 | extern char *tmpnam (char[L_tmpnam]) __THROW __wur;
      |                           ^~~~
/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/rootfs/usr/include/stdio.h:210:33: error: ‘L_tmpnam’ undeclared here (not in a function); did you mean ‘tmpnam’?
  210 | extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur;
      |                                 ^~~~
      |                                 tmpnam
make: * [Makefile:28: main.o] Fehler 1
make: Verzeichnis „/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/samples/hello_world/host“ wird verlassen

The following environment variables are set, and these worked correctly with the hwkey-agent example:

export TA_DEV_KIT_DIR=/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/build/t234/export-ta_arm64
export CROSS_COMPILE_AARCH64=/home/nik71841/jetpack/jp62/toolchain/bin/aarch64-buildroot-linux-gnu-
export TEEC_EXPORT=/home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/install/t234/usr

I might be oversimplifying things, but I don’t know how to get the example to work. The OP-TEE documentation for a Trusted Application didn’t help me, as the make process is not described there.

I was able to build the host application by adding CC=${HOST_CROSS_COMPILE}gcc to the make command. Looks like it did not find the compiler correctly. The whole command looks like this now:

sudo make -C host CROSS_COMPILE=${HOST_CROSS_COMPILE} TEEC_EXPORT=${TEEC_EXPORT} CC=${HOST_CROSS_COMPILE}gcc

But after copying and executing the optee_example_hello_world on my jetson, I get the following error:

optee_example_hello_world: TEEC_InitializeContext failed with code 0xffff0008

Fixed it with sudo infront.

One question though, where can I see the IMSG-debug prints like

IMSG("Hello World!\n");

What is printed when I run the example is following:

Invoking TA to increment 42
TA incremented value to 43