-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TA compilation with SPI driver #1461
Comments
Hi @deepakmnvl. Remember TAs operate in userspace while optee_os/core operates in privileged land. The old application / kernel scheme. |
Hi @etienne-lms , My setup is Android REE and OP-TEE . And I have a working SPI driver in Android for my device.
Thanks |
Yes, but implementation is not straightforward.
No. It would look better if your driver lies in the "HAL" red box of the above figure. |
Hi, For static TA, my file's path is optee\optee_os\core\tee\foo.c , optee\optee_os\core\include\tee\foo.h Is it the system call way ? they are defined here : optee\optee_os\core\arch\arm\tee\arch_svc.c Can you help me with any other API which is called from user TA ? Is it possible to call my API in "core\tee\foo.c" directly from user TA ? or should I need to route the call through some library here (optee\optee_os\lib) Thanks |
For an example of pseudo-TA, see for instance https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/pta/interrupt_tests.c. You may call a pseudo-TA directly from a client application (normal world). |
hi @jforissier , I have gone through interrupt_tests.c file before. Thanks. |
hi @deepakmnvl, A (user) TA can call another (user) TA or a pseudo TA using the GP TEE internal API:
These APIs are available to user TAs (in libutee) and already go through syscalls to reach target pseudo-TA in OP-TEE core. |
Hi , libdirs += include/Debug //my libs are here In out/target/product/hikey/optee/ta/external_optee_myprog_ta But , my .ta file size didnt change. Its same to when I didnt include my static libs I gathered above procedure in the forums, Is this correct ? I didnt test it yet, as I am still implementing my normal world bin, wanted to check if my method is correct ? Thanks |
hello @deepakmnvl, |
hi , EDIT: yes , I did clean build and updated fip.bin Any help would be appreaciated. Also , am using uart0 for logs , and did below changes:
This is the only log appearing :
Are there any more changes required ? Thanks |
The uart0 logging part of the question above is answered in https://discuss.96boards.org/t/android-op-tee-compile-error/1422/49. Not sure about the TEEC_ERROR_BAD_FORMAT error but in one of your comments above, you had:
Is the above exactly the same as what you have in your actual makefile? If so, not sure if the |
Hi , |
Hi , Regarding my "TEEC_ERROR_BAD_FORMAT" issue , I modified my calls as Another issue now :
In addition to above , Should I need to copy my static libs on board ? Thanks EDIT : Presently , am facing error in TEEC_OpenSession with "TEEC_ERROR_BAD_FORMAT" error. |
Hello @deepakmnvl, Your libs are statically linked with the TA so they will not appear as separated files in the REE filesystem: You will find only a single xxx.ta file that contains all the binary code/data of your TA. Note that they a no support for shared libraries for the OP-TEE TAs. Each TA is a single binary blob. Regarding the "TEEC_ERROR_BAD_FORMAT", it looks strange. It cannot be due to a dependency issue as such issue would appear a TA build stage. Is there any error or debug trace together with the error status ? |
About TEE_ERROR_BAD_FORMAT: there are several places that set this error during TA loading, but it seems most of them are meant to detect an invalid ELF file, which is quite unlikely (I assume we can trust the toolchain to generate valid binaries).
This won't be the case if you build some file with |
hi, I am getting error from "TEEC_OpenSession" "res" being set to 0xffff0005 @jforissier I checked on your query . But there is one difference , when I call my static lib , ".eh_frame" is appearing
Does this make any difference ?? Mine hikey board is 64bit arch , compiling aosp with arm-linux-androideabi- Below are compiler flags I am using to build my static libs :
Should I add/remove any ? Thanks |
Try removing |
Shouldn't this be aarch64-linux-android-? |
@jforissier I tried removing @vchong yes, its aarch64- . Its copy-paste error, my bad @etienne-lms No debug trace. I got the error code printed in my code. I am linking around 8 static libs with the TA , could it be a memory issue. Thanks |
well , I did a small experiment . So , it really seems memory issue while loading the TA ? I need to link around 14 static libs of total size ~ 4.5mb with my TA. Is that possible ? |
Try to add some traces in the core at all point where |
hi , So , is there any limitation for memory allocated for each TA ? and any way to increase it ? |
hi ,
Infact , I never got any logs like "TEE-CORE:" I am routing all logs to uart0. Is there any other flag for this ? Thanks |
Try adding |
Add it at the top of the file please. |
hey @vchong , device/linaro/hikey/bootloade/uefi-tools/opteed-build.sh Now , I am getting TEE-CORE logs :) well, I had to do this since my TA is not getting loaded, and the logs is like this :
Any help here pls ?? |
Make sure your TA does set |
hi @etienne-lms Also , added TA_FLAG_USER_MODE as you said. Still issue exists. Another thing is , I removed all my static libs which are being linked with the TA , and verified with a small sample lib , and ITS WORKING FINE Is there any way to increase it ? |
Hi @jforissier , Anyways , my crash is as below :
Using aarch64-linux-android-addr2line , I get only proper value for 0x000000003f00b12c which is "optee/optee_os/core/arch/arm/kernel/thread.c:1108" in "tee.elf" Remaining address gives "?" I think 40*** series addresses are virtual ones ?? Thanks |
Hi @deepakmnvl, It looks like you need to cherry-pick more commits, sorry for not mentioning them: 7bbee6e ("core: show user TA architecture on abort") They are required because the symbolize.py script expects a specific format, which was slightly changed by the above commits. Please add them to your optee_os and the script should work. It's not easy to use addr2line by hand because you have to subtract the load address of the TA. Finally, note that the last address in the stack is indeed inside tee.elf, and should normally not be printed as part of the TA call stack (let's call this a minor bug in the user TA stack unwinding code ;-)). |
One more thing: assuming I have decoded esr correctly, it's a write access, unspecified size. Since the address is 0x40d871c6, which can be divided by 2 but not 4 or 8, it must be a 32- or 64-bit write. It should become obvious once you know the line in the source code (hopefully!). |
After applying the above commits also , same problem with symbolize.py. Nothing gets printed after pasting call stack .
|
Hi @jforissier , Am I doing wrong in compilation steps of my library for OPTEE ? Should I add any compiler options ? |
A byte access obviously can't cause an alignment fault, so I suppose the compiler has optimized the loop and generated 32- or 64-bit writes. You could easily see that in the disassembly of your function. |
I already tried Also , SCTLR_A is present twice in the file. For those who faced this problem , my changes are :
Thanks |
Two things:
|
oops , I have no knowledge in asm coding. I took the code from the other thread. Thanks |
I think the correct way of disabling alignment check is by replacing the
|
Many thanks |
@deepakmnvl As you may have seen, I have created a pull request for a cleaner solution: #1586 |
@jforissier Sure , will do it but after 1-2 weeks as I am reaching my deadlines Also , I took your solution above and it is working fine !!! |
I hope the PR will be long merged in 2 weeks ;) but it's OK.
Glad I could help. |
Hi @jforissier ,
|
FYI
In addition to above changes, permissions should be given in "system/sepolicy/"YourAppName".te file , something like this I can also run a program at shell to access my spi device. Hope this info will be useful for somebody :) |
Great! Thanks for sharing! |
@vchong Thanks to you and other members of the community who all replied patiently to my queries. This thread can now be closed |
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] #1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
If the expected number of packets are not received during the transmit+receive cycle, just receive the remaining data after the cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending on the busy (SSPSR_BSY) flag, else we might miss reading some data as indicated in [1]. LINK: [1] OP-TEE#1461 (comment) Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Hi,
My task is to communicate with my SPI device through OP-TEE securely.
For this , as a trial , I am extending hello_world program to included spi_init() and spi loopback test api.
(copy spi_init() from optee_os to hello_world_ta.c)
I am getting many errors during TA compilation as it is not able to find headers, which are in optee_os folders.
( I have solved some by crude way of copying \optee_os\core\include\ folder to my TA folder but other errors appeared )
It would be very helpful if anybody can provide some documentation/usage/how-to tutorial of driver integration in OP-TEE ?
Thanks
The text was updated successfully, but these errors were encountered: