基于qemu_v8+optee 4.00 平台构建 ca/ta

发布时间:2026/7/20 19:25:50
基于qemu_v8+optee 4.00 平台构建 ca/ta 整体工程目录test0923test0923-PC:~/workspace/optee400$ tree -L 1 . ├── build ├── buildroot ├── hafnium ├── linux ├── mbedtls ├── optee_benchmark ├── optee_client ├── optee_examples - ../optee_examples_AG519M/ ├── optee_examples.bak ├── optee_os ├── optee_rust ├── optee_test ├── out ├── out-br ├── qemu ├── toolchains ├── trusted-firmware-a └── u-boot 18 directories, 0 files test0923test0923-PC:~/workspace/optee400$构建 export-ca_arm64test0923test0923-PC:~/workspace/optee400/optee_client/build$ cmake -DCMAKE_C_COMPILER/home/test0923/workspace/optee400/toolchains/aarch64/bin/aarch64-linux-gnu-gcc -DCMAKE_INSTALL_PREFIX/home/test0923/workspace/optee400/optee_client/export-ca_arm64/ .. -- The C compiler identification is GNU 11.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /home/test0923/workspace/optee400/toolchains/aarch64/bin/aarch64-linux-gnu-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found PkgConfig: /usr/bin/pkg-config (found version 0.29.2) -- Checking for module uuid -- Found uuid, version 2.37.2 -- Configuring done -- Generating done -- Build files have been written to: /home/test0923/workspace/optee400/optee_client/build test0923test0923-PC:~/workspace/optee400/optee_client/build$ make [ 3%] Building C object libteec/CMakeFiles/teec.dir/src/tee_client_api.c.o [ 7%] Building C object libteec/CMakeFiles/teec.dir/src/teec_trace.c.o [ 10%] Linking C static library libteec.a [ 10%] Built target teec [ 14%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/handle.c.o [ 17%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/hmac_sha2.c.o [ 21%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/rpmb.c.o [ 25%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/sha2.c.o [ 28%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/tee_supp_fs.c.o [ 32%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/tee_supplicant.c.o [ 35%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/teec_ta_load.c.o [ 39%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/tee_socket.c.o [ 42%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/prof.c.o [ 46%] Building C object tee-supplicant/CMakeFiles/tee-supplicant.dir/src/plugin.c.o [ 50%] Linking C executable tee-supplicant [ 50%] Built target tee-supplicant [ 53%] Building C object libckteec/CMakeFiles/ckteec.dir/src/pkcs11_api.c.o [ 57%] Building C object libckteec/CMakeFiles/ckteec.dir/src/ck_debug.c.o [ 60%] Building C object libckteec/CMakeFiles/ckteec.dir/src/ck_helpers.c.o [ 64%] Building C object libckteec/CMakeFiles/ckteec.dir/src/invoke_ta.c.o [ 67%] Building C object libckteec/CMakeFiles/ckteec.dir/src/pkcs11_processing.c.o [ 71%] Building C object libckteec/CMakeFiles/ckteec.dir/src/pkcs11_token.c.o [ 75%] Building C object libckteec/CMakeFiles/ckteec.dir/src/serializer.c.o [ 78%] Building C object libckteec/CMakeFiles/ckteec.dir/src/serialize_ck.c.o [ 82%] Linking C static library libckteec.a [ 82%] Built target ckteec [ 85%] Building C object libteeacl/CMakeFiles/teeacl.dir/src/group.c.o [ 89%] Building C object libteeacl/CMakeFiles/teeacl.dir/src/tee_uuid.c.o [ 92%] Linking C static library libteeacl.a [ 92%] Built target teeacl [ 96%] Building C object libseteec/CMakeFiles/seteec.dir/src/se.c.o [100%] Linking C static library libseteec.a [100%] Built target seteec test0923test0923-PC:~/workspace/optee400/optee_client/build$ make install Consolidate compiler generated dependencies of target teec [ 10%] Built target teec Consolidate compiler generated dependencies of target tee-supplicant [ 50%] Built target tee-supplicant Consolidate compiler generated dependencies of target ckteec [ 82%] Built target ckteec Consolidate compiler generated dependencies of target teeacl [ 92%] Built target teeacl Consolidate compiler generated dependencies of target seteec [100%] Built target seteec Install the project... -- Install configuration: -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib/libteec.a -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/teec_trace.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/tee_plugin_method.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/tee_client_api.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/tee_bench.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/tee_client_api_extensions.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib/pkgconfig/libteec.pc -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/sbin/tee-supplicant -- Set runtime path of /home/test0923/workspace/optee400/optee_client/export-ca_arm64/sbin/tee-supplicant to /usr/lib/tee-supplicant/plugins/ -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib/libckteec.a -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/ck_debug.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/pkcs11.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/pkcs11_ta.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib/libteeacl.a -- Up-to-date: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/teeacl.h -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib/libseteec.a -- Installing: /home/test0923/workspace/optee400/optee_client/export-ca_arm64/include/se_tee.h test0923test0923-PC:~/workspace/optee400/optee_client/build$ test0923test0923-PC:~/workspace/optee400/optee_client/build$ test0923test0923-PC:~/workspace/optee400/optee_client/build$ cd .. test0923test0923-PC:~/workspace/optee400/optee_client$ ls android_flags.mk ci config.mk libckteec libteec README.md typedefs.checkpatch Android.mk CMakeLists.txt export-ca_arm64 libseteec LICENSE scripts build CMakeToolchain.txt flags.mk libteeacl Makefile tee-supplicant test0923test0923-PC:~/workspace/optee400/optee_client$ test0923test0923-PC:~/workspace/optee400/optee_client$ test0923test0923-PC:~/workspace/optee400/optee_client$ test0923test0923-PC:~/workspace/optee400/optee_client$ cd build/ test0923test0923-PC:~/workspace/optee400/optee_client/build$ ls CMakeCache.txt cmake_install.cmake libckteec libteeacl Makefile CMakeFiles install_manifest.txt libseteec libteec tee-supplicant test0923test0923-PC:~/workspace/optee400/optee_client/build$ cd .. test0923test0923-PC:~/workspace/optee400/optee_client$ ls android_flags.mk ci config.mk libckteec libteec README.md typedefs.checkpatch Android.mk CMakeLists.txt export-ca_arm64 libseteec LICENSE scripts build CMakeToolchain.txt flags.mk libteeacl Makefile tee-supplicant test0923test0923-PC:~/workspace/optee400/optee_client$ cd libckteec/ test0923test0923-PC:~/workspace/optee400/optee_client/libckteec$ ls CMakeLists.txt include Makefile src test0923test0923-PC:~/workspace/optee400/optee_client/libckteec$ cd .. test0923test0923-PC:~/workspace/optee400/optee_client$ ls android_flags.mk ci config.mk libckteec libteec README.md typedefs.checkpatch Android.mk CMakeLists.txt export-ca_arm64 libseteec LICENSE scripts build CMakeToolchain.txt flags.mk libteeacl Makefile tee-supplicant test0923test0923-PC:~/workspace/optee400/optee_client$ cd export-ca_arm64/ test0923test0923-PC:~/workspace/optee400/optee_client/export-ca_arm64$ ls include lib sbin test0923test0923-PC:~/workspace/optee400/optee_client/export-ca_arm64$在optee_examples顶层CMakeLists.txt增加 export-ca_arm64 引用add include_directories()add link_directories()cmake_minimum_required (VERSION 3.2) project (optee_examples C) # https://cmake.org/Wiki/CMake_Useful_Variables set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt) include_directories(/home/test0923/workspace/optee400/optee_client/export-ca_arm64/include) link_directories(/home/test0923/workspace/optee400/optee_client/export-ca_arm64/lib) include(GNUInstallDirs) add_compile_options (-Wall)构建 catest0923test0923-PC:~/workspace/optee400/optee_examples$ cd build/ test0923test0923-PC:~/workspace/optee400/optee_examples/build$ cmake -DCMAKE_C_COMPILER/home/test0923/workspace/optee400/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc .. -- The C compiler identification is GNU 11.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /home/test0923/workspace/optee400/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/test0923/workspace/optee400/optee_examples/build test0923test0923-PC:~/workspace/optee400/optee_examples/build$ # 32bit test0923test0923-PC:~/workspace/optee400/optee_examples/build$ cmake -DCMAKE_C_COMPILER/home/test0923/workspace/optee400/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc .. -- The C compiler identification is GNU 11.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /home/test0923/workspace/optee400/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/test0923/workspace/optee400/optee_examples/build # or 64bit test0923test0923-PC:~/workspace/optee400/optee_examples/build$ cmake -DCMAKE_C_COMPILER/home/test0923/workspace/optee400/toolchains/aarch64/bin/aarch64-linux-gnu-gcc .. -- The C compiler identification is GNU 11.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /home/test0923/workspace/optee400/toolchains/aarch64/bin/aarch64-linux-gnu-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/test0923/workspace/optee400/optee_examples/build test0923test0923-PC:~/workspace/optee400/optee_examples/build$ make [ 5%] Building C object acipher/CMakeFiles/optee_example_acipher.dir/host/main.c.o [ 11%] Linking C executable optee_example_acipher [ 11%] Built target optee_example_acipher [ 16%] Building C object aes/CMakeFiles/optee_example_aes.dir/host/main.c.o [ 22%] Linking C executable optee_example_aes [ 22%] Built target optee_example_aes [ 27%] Building C object hello_world/CMakeFiles/optee_example_hello_world.dir/host/main.c.o [ 33%] Linking C executable optee_example_hello_world [ 33%] Built target optee_example_hello_world [ 38%] Building C object hotp/CMakeFiles/optee_example_hotp.dir/host/main.c.o [ 44%] Linking C executable optee_example_hotp [ 44%] Built target optee_example_hotp [ 50%] Building C object plugins/CMakeFiles/optee_example_plugins.dir/host/main.c.o [ 55%] Linking C executable optee_example_plugins [ 55%] Built target optee_example_plugins [ 61%] Building C object plugins/syslog/CMakeFiles/96bcf744-4f72-4866-bf1d-8634fd9c65e5.plugin.dir/syslog_plugin.c.o [ 66%] Linking C shared library 96bcf744-4f72-4866-bf1d-8634fd9c65e5.plugin.so [ 66%] Built target 96bcf744-4f72-4866-bf1d-8634fd9c65e5.plugin [ 72%] Building C object random/CMakeFiles/optee_example_random.dir/host/main.c.o [ 77%] Linking C executable optee_example_random [ 77%] Built target optee_example_random [ 83%] Building C object secure_storage/CMakeFiles/optee_example_secure_storage.dir/host/main.c.o [ 88%] Linking C executable optee_example_secure_storage [ 88%] Built target optee_example_secure_storage [ 94%] Building C object tbox_keystore/CMakeFiles/optee_example_tbox_keystore.dir/host/keystore_client.c.o [100%] Linking C executable optee_example_tbox_keystore [100%] Built target optee_example_tbox_keystore构建 tatest0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ export ARCHarm test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ export PATH/home/test0923/workspace/optee400/toolchains/aarch64/bin:$PATH test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ export CROSS_COMPILEaarch64-linux-gnu- test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ export PLATFORMvexpress-qemu_virt test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ export TA_DEV_KIT_DIR/home/test0923/workspace/optee400/optee_os/out/arm/export-ta_arm64 test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ make CC entry.o CC pin_mgr.o ... cc1: note: unrecognized command-line option ‘-Wno-c2x-extensions’ may have been intended to silence earlier diagnostics CC user_ta_header.o CPP ta.lds GEN dyn_list UPD dyn_list LD f8e9209a-3c7d-4d6b-a15e-7f328b11c049.elf OBJDUMP f8e9209a-3c7d-4d6b-a15e-7f328b11c049.dmp OBJCOPY f8e9209a-3c7d-4d6b-a15e-7f328b11c049.stripped.elf SIGN f8e9209a-3c7d-4d6b-a15e-7f328b11c049.ta test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ ls acl.c entry.c f8e9209a-3c7d-4d6b-a15e-7f328b11c049.ta pin_mgr.o acl.o entry.o include sub.mk Android.mk f8e9209a-3c7d-4d6b-a15e-7f328b11c049.dmp keystore.c ta.lds crypto_ops.c f8e9209a-3c7d-4d6b-a15e-7f328b11c049.elf keystore.o user_ta_header_defines.h crypto_ops.o f8e9209a-3c7d-4d6b-a15e-7f328b11c049.map Makefile user_ta_header.o dyn_list f8e9209a-3c7d-4d6b-a15e-7f328b11c049.stripped.elf pin_mgr.c test0923test0923-PC:~/workspace/optee400/optee_examples/tbox_keystore/ta$ file f8e9209a-3c7d-4d6b-a15e-7f328b11c049.elf f8e9209a-3c7d-4d6b-a15e-7f328b11c049.elf: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), static-pie linked, with debug_info, not stripped运行 qemutest0923test0923-PC:~/workspace/optee400/build$ make -f qemu_v8.mk all -j4 ... rootdir/home/test0923/workspace/optee400/out-br/build/buildroot-fs/tar/target table/home/test0923/workspace/optee400/out-br/build/buildroot-fs/full_devices_table.txt rootdir/home/test0923/workspace/optee400/out-br/build/buildroot-fs/cpio/target table/home/test0923/workspace/optee400/out-br/build/buildroot-fs/full_devices_table.txt PATH/home/test0923/workspace/optee400/out-br/host/bin:/home/test0923/workspace/optee400/out-br/host/sbin:/home/test0923/.nvm/versions/node/v22.23.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin gzip -9 -c -n /home/test0923/workspace/optee400/out-br/images/rootfs.cpio /home/test0923/workspace/optee400/out-br/images/rootfs.cpio.gz make[1]: Leaving directory /home/test0923/workspace/optee400/out-br ln -sf /home/test0923/workspace/optee400/build/../out-br/images/rootfs.cpio.gz /home/test0923/workspace/optee400/build/../out/bin /home/test0923/workspace/optee400/build/../u-boot/tools/mkimage -A arm64 \ -T ramdisk \ -C gzip \ -a 0x45000000 \ -e 0x45000000 \ -n Root file system \ -d /home/test0923/workspace/optee400/build/../out/bin/rootfs.cpio.gz /home/test0923/workspace/optee400/build/../out/bin/rootfs.cpio.uboot Image Name: Root file system Created: Sun Jul 19 21:16:53 2026 Image Type: AArch64 Linux RAMDisk Image (gzip compressed) Data Size: 8968470 Bytes 8758.27 KiB 8.55 MiB Load Address: 45000000 Entry Point: 45000000 CALL scripts/checksyscalls.sh make[1]: Leaving directory /home/test0923/workspace/optee400/linux mkdir -p /home/test0923/workspace/optee400/build/../out/bin ln -sf /home/test0923/workspace/optee400/build/../linux/arch/arm64/boot/Image /home/test0923/workspace/optee400/build/../out/bin /home/test0923/workspace/optee400/build/../toolchains/aarch64/bin/aarch64-linux-gnu-objcopy -O binary \ -R .note \ -R .comment \ -S /home/test0923/workspace/optee400/build/../linux/vmlinux \ /home/test0923/workspace/optee400/build/../out/bin/linux.bin /home/test0923/workspace/optee400/build/../u-boot/tools/mkimage -A arm64 \ -O linux \ -T kernel \ -C none \ -a 0x42200000 \ -e 0x42200000 \ -n Linux kernel \ -d /home/test0923/workspace/optee400/build/../out/bin/linux.bin /home/test0923/workspace/optee400/build/../out/bin/uImage Image Name: Linux kernel Created: Sun Jul 19 21:17:13 2026 Image Type: AArch64 Linux Kernel Image (uncompressed) Data Size: 38783488 Bytes 37874.50 KiB 36.99 MiB Load Address: 42200000 Entry Point: 42200000 test0923test0923-PC:~/workspace/optee400/build$ test0923test0923-PC:~/workspace/optee400/build$ make -f qemu_v8.mk run-only ln -sf /home/test0923/workspace/optee400/build/../out-br/images/rootfs.cpio.gz /home/test0923/workspace/optee400/build/../out/bin/ * QEMU is now waiting to start the execution * Start execution with either a c followed by enter in the QEMU console or * attach a debugger and continue from there. * * To run OP-TEE tests, use the xtest command in the Normal World terminal * Enter xtest -h for help. cd /home/test0923/workspace/optee400/build/../out/bin /home/test0923/workspace/optee400/build/../qemu/build/aarch64-softmmu/qemu-system-aarch64 \ -nographic \ -serial tcp:127.0.0.1:54320 -serial tcp:127.0.0.1:54321 \ -smp 2 \ -s -S -machine virt,acpioff,secureon,mteoff,gic-version3,virtualizationfalse \ -cpu max,smeon,pauth-impdefon \ -d unimp -semihosting-config enableon,targetnative \ -m 1057 \ -bios bl1.bin \ -initrd rootfs.cpio.gz \ -kernel Image \ -append consolettyAMA0,38400 keep_bootcon root/dev/vda2 \ \ -object rng-random,filename/dev/urandom,idrng0 -device virtio-rng-pci,rngrng0,max-bytes1024,period1000 -netdev user,idvmnic -device virtio-net-device,netdevvmnic QEMU 8.0.0 monitor - type help for more information (qemu) c (qemu) q test0923test0923-PC:~/workspace/optee400/build$ test0923test0923-PC:~/workspace/optee400/build$ test0923test0923-PC:~/workspace/optee400/build$Normal Worldbuildroot login: root # # cd /usr/bin/ # ./optee_example_ optee_example_acipher optee_example_plugins optee_example_aes optee_example_random optee_example_hello_world optee_example_secure_storage optee_example_hotp optee_example_tbox_keystore # ./optee_example_tbox_keystore --init-pin a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 PIN initialized. #