We can see a similar artical
https://blog.csdn.net/shuaifengyun/article/details/71499619
I follow the steps but cannot make it work. Later I find if I roll back code to 5/31/2017, it can be run successfully.
The reason is that github update code everyday, let ARMv8 work, but forget let ARMv7 can work.
Here it is not the important. Here record down how to make OP-TEE work on ARMv8. (github update date:06/23/2018)
Step1: prepare set up environment.
$ sudo apt-get install android-tools-fastboot autoconf bison cscope curl \
flex gdisk libc6:i386 libfdt-dev libglib2.0-dev \
libpixman-1-dev libstdc++6:i386 libz1:i386 netcat \
python-crypto python-serial uuid-dev xz-utils zlib1g-dev Step1: prepare setup environment.
Step2: Download code
$ mkdir opentee.v8 //mkdir
$ cd opentee.v8
$ repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml --repo-url=git://codeaurora.org/tools/repo.git
$ sed -i "s/\.git//g" .repo/manifest.xml //solve repo sync error ,remove .git inside file manifest.xml
$repo sync -j22 //sync the code
Step3: Let it download toolchain
$ cd build
$ make -f toolchain.mk toolchains
Step4: compile the code
$ cd build
$ make -f qemu_v8.mk all
Step5, run it!! It will start 2 terminals, 1 is for OP-TEE, port number is 54321.Another is for system console, port number is 54320.
$cd build
$make -f qemu_v8.mk run-only //start qemu v8 and run OP-TEE
console on qemu
opentee.v8/build$ make -f qemu_v8.mk run-only
* QEMU is now waiting to start the execution
................
cd /data/kernel/opentee.v8/build/../arm-trusted-firmware/build/qemu/release && \
/data/kernel/opentee.v8/build/../qemu/aarch64-softmmu/qemu-system-aarch64 \
-nographic \
-serial tcp:localhost:54320 -serial tcp:localhost:54321 \
-smp 1 \
-machine virt,secure=on -cpu cortex-a57 -m 1057 -bios /data/kernel/opentee.v8/build/../arm-trusted-firmware/build/qemu/release/bl1.bin \
-s -S -semihosting-config enable,target=native -d unimp \
-initrd /data/kernel/opentee.v8/build/../out-br/images/rootfs.cpio.gz \
-kernel /data/kernel/opentee.v8/build/../linux/arch/arm64/boot/Image -no-acpi \
-append 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2' \
QEMU 2.12.0 monitor - type 'help' for more information
(qemu)
console on port 54320
listening on port 54320
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
console on port 54321
listening on port 54321
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
Step6, let optee continue
Press "c" (lower case) on qemu console.
54321 port output below contents. (remove some part)
D/TC:0 add_phys_mem:521 TEE_SHMEM_START type NSEC_SHM 0x42000000 size 0x00200000
D/TC:0 add_phys_mem:521 TA_RAM_START type TA_RAM 0x0e400000 size 0x00c00000
D/TC:0 add_phys_mem:521 VCORE_UNPG_RW_PA type TEE_RAM_RW 0x0e149000 size 0x001b7000
...............
D/TC:0 tee_ta_register_ta_store:534 Registering TA store: 'REE' (priority 10)
D/TC:0 tee_ta_register_ta_store:534 Registering TA store: 'Secure Storage TA' (priority 9)
D/TC:0 mobj_mapped_shm_init:559 Shared memory address range: f000000, 11000000
I/TC: Initialized
D/TC:0 init_primary_helper:917 Primary CPU switching to normal world boot
I/TC: Dynamic shared memory is enabled
54320 port output below contents. (remove some part)
listening on port 54320
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
mmap:
VA:0 PA:0x0 size:0x4000 attr:0x2 granularity:0x40000000
...............
[ 1.864859] ALSA device list:
[ 1.865094] No soundcards found.
[ 1.867994] uart-pl011 9000000.pl011: no DMA platform data
[ 1.949458] Freeing unused kernel memory: 1088K
Starting logging: OK
Initializing random number generator... [ 2.638346] random: dd: uninitialized urandom read (512 bytes read)
done.
Starting tee-supplicant...
Starting network: OK
Welcome to Buildroot, type root to login
buildroot login:
Step8: input user name root and run hellow_world
54320 port output below contents.
buildroot login: root
# hello_world
Invoking TA to increment 42
TA incremented value to 43
54321 port output below contents.
D/TC:0 core_mmu_entry_to_finer_grained:631 xlat tables used 4 / 5
D/TC:0 tee_ta_init_pseudo_ta_session:274 Lookup pseudo TA 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TC:0 load_elf:842 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (Secure Storage TA)
D/TC:0 load_elf:842 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (REE)
D/TC:0 load_elf_from_store:810 ELF load address 0x40005000
D/TC:0 tee_ta_init_user_ta_session:1019 Processing relocations in 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TA: TA_CreateEntryPoint:39 has been called
D/TA: TA_OpenSessionEntryPoint:68 has been called
I/TA: Hello World!
D/TA: inc_value:105 has been called
I/TA: Got value: 42 from NW
I/TA: Increase value to: 43
D/TC:0 tee_ta_close_session:380 tee_ta_close_session(0xe169c70)
D/TC:0 tee_ta_close_session:399 Destroy session
I/TA: Goodbye!
D/TA: TA_DestroyEntryPoint:50 has been called
D/TC:0 tee_ta_close_session:425 Destroy TA ctx
pictures
Here we nearly finish all steps. Next we can add CA and TA by ourselves.
Method can download code for reference
git clone https://github.com/shuaifengyun/optee_my_test.git
The way to rollback code to 5/31/2017 and let armv7 qemu run on optee.
Download a file inside
https://download.csdn.net/download/dddddttttt/10496488
Here record down commit id of code database, in case code don't workl when github update code.
/data/kernel/opentee.v8/.repo$ cat manifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="github" fetch="https://github.com" />
<default remote="github" revision="master" />
<!-- OP-TEE gits -->
<project path="optee_client" name="OP-TEE/optee_client" />
<project path="optee_os" name="OP-TEE/optee_os" />
<project path="optee_test" name="OP-TEE/optee_test" />
<project path="build" name="OP-TEE/build">
<linkfile src="qemu_v8.mk" dest="build/Makefile" />
<linkfile src="../toolchains/aarch64/bin/aarch64-linux-gnu-gdb" dest="build/gdb" />
</project>
<!-- linaro-swg gits -->
<project path="linux" name="linaro-swg/linux" revision="6e954e2f2cbd412f7bc874bb9145f69713194e52" />
<project path="optee_benchmark" name="linaro-swg/optee_benchmark"/>
<project path="optee_examples" name="linaro-swg/optee_examples" />
<project path="soc_term" name="linaro-swg/soc_term" revision="5493a6e7c264536f5ca63fe7511e5eed991e4f20" />
<!-- Misc gits -->
<project path="arm-trusted-firmware" name="ARM-software/arm-trusted-firmware" revision="refs/tags/v1.5-rc2" clone-depth="1" />
<project path="edk2" name="tianocore/edk2" revision="1ea08a3dcdd61c7481ec78ad8b8037ee6ca45402" />
<project path="qemu" name="qemu/qemu" revision="refs/tags/v2.12.0" clone-depth="1" />
<project path="buildroot" name="buildroot/buildroot" revision="62dca337fe72085d98b7603cfcff1279c48ba7d9" />
</manifest>