Greetings Experts
I am trying to compile the TEE sample with DS-5. I downloaded the latest version of DS-5, and created a C project. I was able to put in the main_secure.c file and build ok. I then tried to add monitor.s file to the project by adding another source file. I get the following errors:
Would someone please compile the project, and advise in high level what sort of project I need to create and how to import the source files into my project please?
Sean
This assembly file is "ARM style" not "GCC style".
Are you sure you're using ARM compiler not GCC?
Hi David
Yes. I downloaded DS-5, which is arm's IDE; the README document which comes with the software specifically stated armasm. I also have a stronger proof of it running arm syntax; the C file goes in fine. One of the C source files in the project goes in the IDE without generating any errors; in that file there are assembly calls which are written in arm syntax.
My goal is to get the executable one way other the other. So, if there is a compiler you would recommend, I can download it and use it.
Given DS-5 is an arm associated product, would you be able to download it, and compile the project?
Looking at the README file that comes with the project, seems there are two different executable files which need to be created? Is that right? I need the high level steps of which files to compile together and how to link them to get the final executable that I need. i.e. *if* the steps are different for whichever compiler you may recommend.
What I am trying to say is I am open to any compiler as long as I get some instructions as to how to go about compiling it.
I really appreciate your expert help.
Hi Seanans,
Just to confirm, you're using sample code "EB_TrustZone_Example.zip", right?
Let's assume you're using it.
I had downloaded it and found the same content in "monitor.S" with the picture you showed.
I passed compiling stage of all soure files (including monitor.S).
You mentioned that:
One of the C source files in the project goes in the IDE without generating any errors; in that file there are assembly calls which are written in arm syntax.
For the "assembly calls":
Did you mean your C code called a function which is implemented in assembly file? Or an inline assembly code in C function?
BTW, can you attach your compiler setting?
You can find it by "right click your project" -> Properties ->C/C++ Build->Settings->Tool Settings
Thank you for the message. I believe the assembly call I was referring to was an inline assembly code in C function. Enclosed, please find updated pics of my project. It has a capture of the settings as well as the error I see at this point:
At this point, I have added all the files in the source directory of EB_TrustZone_Example.zip file. I am not sure what the files call scatter_normal.txt and scatter_secure.txt do. I have not added them to my project yet. I created this project by first following the Hello World tutorial of DS_5 for creating a project; instead of adding the hello world code I added the first C file. I then added the rest by adding source files to the project. If there is a more effective way of creating this project such as importing a zip file, please do let me know.
btw, my original error was resolved by restarting eclipse; I am sure you noticed that.
Regards-
Hi Sean,
It's a good news that you solved the compiling error.
I noticed that you were using Ubuntu in VM. So I may assume that your primary OS is Windows.
Actually, this example can be built simply by executing "build.bat" (in the example root) in windows command line.
If you want to do this on Windows:
1 Install DS-5 (need compiler in it) on Windows
2 File compiler path in DS-5, by default it's in "C:\Program Files\DS-5 v5.21.1\sw\ARMCompiler5.05u1\bin"
3 Click Windows "Environment Variables ... " as following picture, in "System variables", find "Variable" "Path", add compiler path to it. Note, paths are seperated by semi-colon.
4 Now command line knows where your compiler is, so execute "build.bat" in example folder
To learn how this project built, you can read "build.bat".
Basically, it produces 2 images: one for normal world, one for secure world.
The secure world image needs normal world image, so normal image is built firstly.
Build normal image:
1 source files:
./src/main_normal.c, ./src/retarget_normal.c, ./src/startup_normal.s, ./src/v7.s
2 scatter file (for ARM tool chain, scatter file is like "linker script in GCC". It tells linker what the layout of output image is. You may refer to the manual of ARM linker - armlink):
scatter_normal.txt
Build secure image:
./src/main_secure.c, ./src/retarget_secure.c, ./src/startup_secure.s, ./src/monitor.s, ./src/v7.s
2 scatter file:
scatter_secure.txt
3 Binary file:
normal.bin
You may notice that, startup_secure.s uses an instruction "INCBIN normal.bin". That caused one of your current error.
It's because secure image need include normal image named "normal.bin" in it. So you have to produce normal.bin firstly by the instructions above.
For more information of "INCBIN", please refer to: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/Caccaghf.html
If you want to build it with DS-5 project, I have some suggestions for you:
1 You need create 2 projects: one for normal, one for secure
2 Add relative source files and scater files to these 2 projects (please refer to the details above to check which files need be added to which project)
3 Build normal images firstly
3 When get normal image - "normal.bin", build secure image
For detailed build paramter, you can refer to "build.bat".
If you just want to use DS-5 for debugging (because use "build.bat" is a very easy way to build), then you can just create a debug session and load axf file from the example path.
It's another topic about debugging.
David
Thank you so much for the reply. I may have missed something. I do not quite make the connection between build.bat and having to create projects for normal image and secure image. I tried the build.bat after I installed and configured DS-5, but I got some errors and I shared them below. I installed DS5 on Windows, and created a 30 day evaluation license. I then created a C project called normal image and added the files ./src/main_normal.c, ./src/retarget_normal.c, ./src/startup_normal.s, ./src/v7.s to the project. I then added the scatter file as a scatter file. I do get some errors as follows:
I also tried to run build.bat after adding the ds-5 to my path and get the following errors even though I generated a 30 day license. I tried to look to see if I can modify something in the build.bat to point to my install, but I do not recognize the path of license desired by the compiler. :
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>del .\obj\*.o
Could Not Find C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example\obj\*.o
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armcc -c --debug --cpu=Cortex-A9.no_neon.no_vfp -O1 -o ./obj/main_normal.o ./src/main_normal.c
Error: C9555E: License checkout for feature compiler5 with version 5.0201503 has been denied by Flex back-end. Error code: -1
Cannot find license file.
The license files (or license server system network addresses) attempted are
listed below. Use LM_LICENSE_FILE to use a different license file,
or contact your software provider for a license file.
Feature: compiler5
Filename: c:\program files\arm\licenses\license.dat
License path: c:\program files\arm\licenses\license.dat;
FlexNet Licensing error:-1,359. System Error: 2 "No such file or directory"
For further information, refer to the FlexNet Licensing documentation,
available at "www.flexerasoftware.com".
Product: DS-5 Professional 5.22.0 [5220021]
Component: ARM Compiler 5.05 update 2 (build 169)
Tool: armcc [4d0f38]
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armcc -c --debug --cpu=Cortex-A9.no_neon.no_vfp -O1 -o ./obj/retarget_normal.o ./src/retarget_normal.c
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armasm --debug --cpu=Cortex-A9.no_neon.no_vfp -o ./obj/startup_normal.o ./src/startup_normal.s
Error: A9555E: License checkout for feature compiler5 with version 5.0201503 has been denied by Flex back-end. Error code: -1
Tool: armasm [4d0f2f]
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armasm --debug --cpu=Cortex-A9.no_neon.no_vfp -o ./obj/v7.o ./src/v7.s
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armlink --scatter=scatter_normal.txt --entry=normalStart -o normal.axf ./obj/main_normal.o ./obj/retarget_normal.o ./obj/startup_normal.o .
Error: L9555E: License checkout for feature compiler5 with version 5.0201503 has been denied by Flex back-end. Error code: -1
Tool: armlink [4d0f33]
Finished: 1 information, 0 warning and 1 error messages.
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>fromelf --bin -o normal.bin normal.axf
Error: Q9555E: License checkout for feature compiler5 with version 5.0201503 has been denied by Flex back-end. Error code: -1
Tool: fromelf [4d0f2f]
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armcc -c --debug --cpu=Cortex-A9.no_neon.no_vfp -O1 -o ./obj/main_secure.o ./src/main_secure.c
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armcc -c --debug --cpu=Cortex-A9.no_neon.no_vfp -O1 -o ./obj/retarget_secure.o ./src/retarget_secure.c
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armasm --debug --cpu=Cortex-A9.no_neon.no_vfp -o ./obj/startup_secure.o ./src/startup_secure.s
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armasm --debug --cpu=Cortex-A9.no_neon.no_vfp --diag_suppress=A1786W -o ./obj/monitor.o ./src/monitor.s
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>armlink --scatter=scatter_secure.txt -o EB_TrustZone_Example.axf --entry=secureStart --keep=startup_secure.o(NORMAL_IMAGE) ./obj/main_secur
C:\Users\sansari\Downloads\EB_TrustZone_Example\EB_TrustZone_Example>
For your project build errors:
Seems that object file of v7.S didn't join the linking process, because all missing symbols are defined in v7.S.
I have made a project for normal project, it works well.
Share you some key settings:
1 Project files
2 C compiler setting
3 Assembler setting
4 Linker setting
5 post-build setting (make binary file from axf file)
Then you should pass the build of this project.
Secure project setting is similar.
For the build.bat issue, it seems that you have license issue. I'm using licensed version, so I don't know why it happened in evaluation version.
Hi David,
Thank you so much. I was able to successfully compile the TZ_Normal. And put in the files for TZ_Secure. Please have a look at the updated pics. I have used a red circle around the items which need your attention.
Your configuration is correct.
Now your problem is: cannot find normal.bin.
Please refer to: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/Caccaghf.html
"By default the assembler searches the current place for included files. See GET or INCLUDE directive for information on the current place. Use the -i assembler command-line option to add directories to the search path. File names and directory names must not contain spaces."
Then you should pass.
Thanks. The compile was successful. I am now trying to run it on my target platform, which is Qualcomm Snapdragon msm8974. I tried this tutorial procedures, but I got stuck on step 3 since there is not configuration for my platform. I tried to do an update of the DS-5, and selected all. But I still do not have an option for my target platform. Do you know if I am able to push the executable to my target platform from the IDE? I am looking at some other ways also; I put the file on the /sdcard and tried to run it but it does not run.
Given this device is rooted, if there is a directory you think the executable should run from please advise. I'll remount the partition and put the executable on it
For debugging, that depends on your platform.
I can show you some key points:
The other issue I seem to be running into is there is a gap between the tools, which Qualcomm provides for debugging, and DS-5 tools. What I mean is Qualcomm has a debugger for Snapdragon but it needs Eclipse Juno SR1 package. I successfully installed the debugger on this instance. But this instance, as far as I know, can not compile and run the Hello TZ program. On the other hand DS-5 need OpenCL version 8.2 and above, while Qualcomm debugger only works with OpenCL LLDB Eclipse plugin 2.2.2.201.408200918 and CDT version 4.1.0 - 4.1.2. Please have a look at the enclosed diagram...
I get this error when I try to install the debugger even though CDT should be installed on the DS-5 instance that I have. I have tried to look for a version of DS-5 with Juno version of Eclipse but I have not been successful. If it does exist, and you can help me find it, please let me know. I also tried to see if I can add DS-5 functionality an the right patches to the Juno instance of Eclipse on my machine, but I have not seen anything that indicate such install is possible. Please direct me to it if it does.
I like to thank you so much for your continued support. I did place the secure.bin file on my phone, and tried to run the two files in it. I had to change permissions of the files. Here is what I get:
127|root@hltespr:/storage/emulated/legacy/secure.bin # ./SECURE_EXE
./SECURE_EXE
./SECURE_EXE[1]: ▬☻±É╨ƒσ╙≡!πî╨ƒσ►☼◄ε♦└π☺: not found
./SECURE_EXE[5]: syntax error: '┐x┴√╪R' unexpected
127|root@hltespr:/storage/emulated/legacy/secure.bin # ./NORMAL_IMAGE
./NORMAL_IMAGE
./NORMAL_IMAGE[1]: ⌡♥δPπ÷♥←▀≡!πê╨ƒσ►☼◄ε♦└π☺: not found
./NORMAL_IMAGE[14]: syntax error: '(' unexpected
1|root@hltespr:/storage/emulated/legacy/secure.bin #
Re: The content on Debug Hardware, I did go to DS-5 help documents (DS-5 IDE-> help -> help contents): ARM DS-5 Documentation > ARM DS-5 Debug Hardware > Using the Debug Hardware Configuration Utilities > Creating debug hardware target configurations. But the content does not seem to be very relevant to what I am trying to do. All I have at my disposal is an Android phone model SM-N900P Samsung Note 3 with a USB cable which connects to the laptop. It sounds like ARM DS-5 Debug hardware instructions are for RVI and DSTREAM, which I do not have. I did try to run debug hardware configuration utility, but it does not find any hardware. Did I perhaps miss something?
I think DS-5 can only debug the board when connected with debug interface like: JTAG, SWD.
Please refer to: ARM DS-5 Documentation > ARM DS-5 Debug Hardware > ARM DSTREAM System and Interface Design Reference Guide
I agree. I did review the content, and that is the impression I have. Thank you so much for your help.