Hikey Lemaker OPTEE kernel working source code

Afair files didn’t disappear after rebooting on 230. Lemme see if I can find a copy of the old 230 build to try.

Hey @vchong,
Am on 2.4 , and struggling to get my board boot-up.
Waiting for your feedback .

Thanks

@deepakmnvl’s issue is being tracked here [1] for those interested in following the thread.

[1] https://github.com/OP-TEE/optee_os/issues/1461

Hi @vchong,

In OP-TEE with AOSP environment from a TA I was trying to write data to a file using “TEE_WriteObjectData”.
I was writing 1KB of data at a time, but after writing around 1.9 MB of data the “TEE_WriteObjectData” panicked showing the below mentioned message.

[ta log] TEE_WriteObjectData SUCCESS written 1913888 bytes
[ta log] TEE_WriteObjectData SUCCESS written 1914912 bytes
[ta log] TEE_WriteObjectData SUCCESS written 1915936 bytes
ERROR: TEE-CORE: request memory size 888 failed
ERROR: USER-TA: Panic 0xffff000c
ERROR: TEE-CORE: TA panicked with code 0xffff000c usr_sp 0x400057b0 usr_lr 0x0
tee_helloworld: TEEC_InvokeCommand failed with code 0xffff3024 origin 0x3

So is there any way to write a large file (say 10MB or so) from the TA ?

Thanks,
Rabi

In your TA’s user_ta_header_defines.h file, try setting TA_STACK_SIZE or TA_DATA_SIZE to (10 * 1024 * 1024).

I have already tried this but that does not solve the problem.

Gone through https://wiki.linaro.org/WorkingGroups/Security/OP-TEE and looks to me need to modify TA’s MMU L1 table to support more memory for the TA as by default it has 1 MB of memory mapped.

Could you please suggest the steps to modify the TA’s MMU L1 Table.

Thanks,
Rabi

The change to the mmu l1 table is not required anymore. I’ve updated the wiki.

Can you try rebuilding with CFG_CORE_UNWIND=y to get a call stack?

Also try adding CFG_CORE_HEAP_SIZE ?= 131072 to plat-hikey/conf.mk.

Note that 10MB is really quite a lot.

Hi @vchong,

After adding CFG_CORE_HEAP_SIZE ?= 131072 to core/arch/arm/plat-hikey/conf.mk the build failed. Also try clean build and that also failed. But if remove the added parameter the build again successful.

Build Failed logs after adding CFG_CORE_HEAP_SIZE ?= 131072

Finished building optee_os…
[ 55% 149/267] target C: xtest <= external/optee_test/host/xtest/regression_1000.c
FAILED: /bin/bash -c "(PWD=/proc/self/cwd prebuilts/misc/linux-x86/ccache/ccache prebuilts/clang/host/linux-x86/clang-2690385/bin/clang -I external/optee_test/host/xtest -I external/optee_test/host/xtest/adbg/include -I external/optee_test/host/xtest/xml/include -I out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include -I external/optee_test/ta/concurrent/include -I external/optee_test/ta/concurrent_large/include -I external/optee_test/ta/create_fail_test/include -I external/optee_test/ta/crypt/include -I external/optee_test/ta/enc_fs/include -I external/optee_test/ta/os_test/include -I external/optee_test/ta/rpc_test/include -I external/optee_test/ta/sims/include -I external/optee_test/ta/storage/include -I external/optee_test/ta/storage_benchmark/include -I external/optee_test/ta/sha_perf/include -I external/optee_test/ta/aes_perf/include -I external/optee_test/ta/socket/include -I external/optee_test/ta/sdp_basic/include -I external/optee_test -I out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates -I out/target/product/hikey/gen/EXECUTABLES/xtest_intermediates -I libnativehelper/include/nativehelper $(cat out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/import_includes) -isystem system/core/include -isystem system/media/audio/include -isystem hardware/libhardware/include -isystem hardware/libhardware_legacy/include -isystem hardware/ril/include -isystem libnativehelper/include -isystem frameworks/native/include -isystem frameworks/native/opengl/include -isystem frameworks/av/include -isystem frameworks/base/include -isystem out/target/product/hikey/obj/include -isystem bionic/libc/arch-arm64/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/common -isystem bionic/libc/kernel/uapi/asm-arm64 -isystem bionic/libm/include -isystem bionic/libm/include/arm64 -c -fno-exceptions -Wno-multichar -fno-strict-aliasing -fstack-protector-strong -ffunction-sections -fdata-sections -funwind-tables -Wa,–noexecstack -Werror=format-security -D_FORTIFY_SOURCE=2 -fno-short-enums -no-canonical-prefixes -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast -Werror=implicit-function-declaration -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time -DNDEBUG -O2 -g -Wstrict-aliasing=2 -DNDEBUG -UDEBUG -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -nostdlibinc -target aarch64-linux-android -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin -std=gnu99 -include conf.h -pthread -g3 -fpie -D_USING_LIBCXX -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=null-dereference -Werror=return-type -MD -MF out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.d -o out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.o external/optee_test/host/xtest/regression_1000.c ) && (cp out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.d out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.P; sed -e 's/#.//’ -e 's/^[^:]: //’ -e 's/ \\$//’ -e ‘/^$/ d’ -e ‘s/$/ :/’ < out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.d >> out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.P; rm -f out/target/product/hikey/obj/EXECUTABLES/xtest_intermediates/host/xtest/regression_1000.d )"
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:34:
In file included from bionic/libc/include/sched.h:31:
bionic/libc/include/bits/timespec.h:41:3: error: unknown type name ‘time_t’; did you mean ‘size_t’?
time_t tv_sec;
^
prebuilts/clang/host/linux-x86/clang-2690385/bin/…/lib64/clang/3.8.256229/include/stddef.h:62:23: note: ‘size_t’ declared here
typedef SIZE_TYPE size_t;
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:34:
bionic/libc/include/sched.h:35:1: error: unknown type name ‘__BEGIN_DECLS’
__BEGIN_DECLS
^
bionic/libc/include/sched.h:40:1: error: expected identifier or ‘(’
struct sched_param {
^
bionic/libc/include/sched.h:44:38: error: expected identifier
extern int sched_setscheduler(pid_t, int, const struct sched_param
);
^
bionic/libc/include/sched.h:45:31: error: a parameter list without types is only allowed in a function definition
extern int sched_getscheduler(pid_t);
^
bionic/libc/include/sched.h:49:34: error: expected identifier
extern int sched_setparam(pid_t, const struct sched_param
);
^
bionic/libc/include/sched.h:50:34: error: expected identifier
extern int sched_getparam(pid_t, struct sched_param*);
^
bionic/libc/include/sched.h:51:41: error: expected identifier
extern int sched_rr_get_interval(pid_t, struct timespec*);
^
bionic/libc/include/sched.h:149:1: error: unknown type name ‘__END_DECLS’
__END_DECLS
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:37:
out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include/time.h:35:1: error: expected identifier or ‘(’
typedef long int time_t;
^
out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include/time.h:40:5: error: unknown type name ‘time_t’; did you mean ‘size_t’?
time_t tv_sec; /* Seconds. /
^
prebuilts/clang/host/linux-x86/clang-2690385/bin/…/lib64/clang/3.8.256229/include/stddef.h:62:23: note: ‘size_t’ declared here
typedef SIZE_TYPE size_t;
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:37:
out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include/time.h:41:5: error: unknown type name ‘time_t’; did you mean ‘size_t’?
time_t tv_usec; /
Microseconds. /
^
prebuilts/clang/host/linux-x86/clang-2690385/bin/…/lib64/clang/3.8.256229/include/stddef.h:62:23: note: ‘size_t’ declared here
typedef SIZE_TYPE size_t;
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:37:
out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include/time.h:54:1: error: unknown type name ‘time_t’; did you mean ‘size_t’?
time_t time (time_t t);
^
prebuilts/clang/host/linux-x86/clang-2690385/bin/…/lib64/clang/3.8.256229/include/stddef.h:62:23: note: ‘size_t’ declared here
typedef SIZE_TYPE size_t;
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
In file included from bionic/libc/include/pthread.h:37:
out/target/product/hikey/optee/arm-plat-hikey/export-ta_arm64/host_include/time.h:54:14: error: unknown type name ‘time_t’; did you mean ‘size_t’?
time_t time (time_t t);
^
prebuilts/clang/host/linux-x86/clang-2690385/bin/…/lib64/clang/3.8.256229/include/stddef.h:62:23: note: ‘size_t’ declared here
typedef SIZE_TYPE size_t;
^
In file included from external/optee_test/host/xtest/regression_1000.c:15:
bionic/libc/include/pthread.h:134:1: error: unknown type name ‘__BEGIN_DECLS’
__BEGIN_DECLS
^
bionic/libc/include/pthread.h:136:1: error: expected identifier or ‘(’
int pthread_atfork(void (
)(void), void (
)(void), void(
)(void));
^
bionic/libc/include/pthread.h:138:43: error: expected function body after function declarator
int pthread_attr_destroy(pthread_attr_t*) __nonnull((1));
^
bionic/libc/include/pthread.h:139:62: error: expected function body after function declarator
int pthread_attr_getdetachstate(const pthread_attr_t*, int*) __nonnull((1, 2));
^
bionic/libc/include/pthread.h:140:63: error: expected function body after function declarator
int pthread_attr_getguardsize(const pthread_attr_t*, size_t*) __nonnull((1, 2));
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1

make failed to build some targets (09:29 (mm:ss))

Thanks,
Rabi

I don’t see how adding CFG_CORE_HEAP_SIZE can generate this kind of error. It’s totally unrelated. CFG_CORE_HEAP_SIZE is already defined in optee_os/mk/config.mk in the first place, and you’re just redefining it with a bigger value. Something else must have happened to or changed in the code, with bionic being the prime suspect.

Lemme try a build to see if I can reproduce.

No issue with the build here.

Hi @vchong,

Thanks for the update. For the time being we are OK with the default settings of CFG_CORE_HEAP_SIZE.

Is there any openssl support in the OP-TEE.

We are basically trying to port libcurl with ssl support in OP-TEE. In order to achieve that we need openssl in OP-TEE.

Thanks,
Rabi

openssl is not supported. There were some discussions on how to do it yourself on github.

Do you want it in op-tee core itself, i.e. optee_os, or in the TAs?

For core, there was a proof of concept done a long time ago, but has not been updated since. https://github.com/OP-TEE/optee_os/tree/poc/openssl_cryptolib, https://github.com/OP-TEE/optee_os/issues/340.

For TA, see https://github.com/OP-TEE/optee_os/issues/1303.

@vchong

I would like to increase the OP-TEE dedicated DDR RAM size which is currently 32 MB. Is it possible and if yes how I can increase that.

Basically I would like to use a 2GB HiKey board instead of 1GB. In 2GB board I would like OP-TEE to use more than 32MB of RAM so that I can execute larger TA on OP-TEE.

@rabindranath-derebac Not sure if this will work, but try changing TDRAM_SIZE in https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/plat-hikey/platform_config.h#L136 from 16 to some appropriate number of MB sufficient for your use. If it doesn’t work, then, although I’m not a memory expert, it seems like it would touch too many areas of code across different repos to shift the memory mapping around in order to find a larger region to try to make it work, i.e. a huge undertaking that will require lots of effort.

Hi @vchong,

Does HiKey 620 support Hardware decoding?
If yes then which branch of OP-TEE with AOSP we can use for the build.

Thanks,
Rabi

Does HiKey 620 support Hardware decoding?
If yes then which branch of OP-TEE with AOSP we can use for the build.

No, I don’t think hardware decode was ever implemented on the 620.

@vchong
Where can I find the sources for wifi? I’m using the optee_build lemaker with kernel 4.12.0.
lsmod shows the following modules are loaded:
wlcore_sdio 16384 0
wl18xx 139264 0
wlcore 233472 1 wl18xx
mac80211 692224 2 wl18xx,wlcore
cfg80211 614400 3 wl18xx,wlcore,mac80211
rfkill 32768 1 cfg80211
8021q 32768 0
garp 16384 1 8021q
stp 16384 1 garp
mrp 20480 1 8021q
llc 16384 2 garp,stp
adv7511 20480 0
kirin_drm 24576 0
dw_drm_dsi 20480 0
drm_kms_helper 176128 3 adv7511,kirin_drm
drm 417792 5 dw_drm_dsi,adv7511,kirin_drm,drm_kms_helper
ipv6 413696 30

I got the latest firmware from: here
But when i use “ifup wlan0” → Cannot find device “wlan0”

With my hikey960 and the optee_build I dont need to do this, I just activate wl18x and wlcore in my defconfig and modify the buildroot cfg a little bit and is working like a charm, where is the concrete difference with the lemaker?