系统信息
uname -a Linux rtos 5.11.0-37-generic #41-Ubuntu SMP Mon Sep 20 16:39:20 UTC 2021 x86_64 x86_64 x86_64 GNU/LinuxGit配置
~/.bashrc中开启git的调试模式
export GIT_TRACE_PACKET=1 export GIT_TRACE=1 export GIT_CURL_VERBOSE=1 git config --global user.email "yourmail@xx.com" git config --global user.name "yourname"编译依赖
sudo apt install automake bc bison build-essential cscope curl device-tree-compiler expect flex autoconf ftp-upload gdisk acpica-tools libattr1-dev libc6:i386 libcap-dev libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev libpixman-1-dev libssl-dev libstdc++6:i386 libtool ninja-build zlib1g:i386 make mtools netcat unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev adb fastboot meson libgnutls28-dev autoconf -f sudo apt install -y python3-pyelftools sudo apt install -y python3-pip sudo apt install -y python3-pwntools python3-pycryptodome python3 -m pip install --user --break-system-packages \ pwntools pycryptodome pycryptodomex下载代码
mkdir tee3.15 cd tee3.15 repo init -u https://github.com/OP-TEE/manifest.git --depth 1 -m qemu_v8.xml --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -b 3.15.0 repo sync -j4 --no-clone-bundle如果没有意外,下载成功截图如下:
获取交叉编译工具
cd build/ make -f toolchain.mk toolchains -j4编译OP-TEE
cd build/ make -f qemu_v8.mk -j4需要做的就是耐心等待编译完成,如图所示给虚拟机分配了4颗CPU,编译过程可以看到CPU占用率比较高。
还可以运行make check测试编译是否成功,会运行xtest用例。
运行
观察soc_term.py源码,可以看到支持端口入参。
可以开启两个shell命令行,分别使用python3 soc_term.py 54320和python3 sco_term.py 54321分别监听Normal World和Secure World两个世界的端口。
然后进入到build目录,运行make run-only即可进入到交互状态,然后按照提示输入c字母,回车确认:
接着Normal World以root用户登录:
并运行xtest进行测试:
如果顺利,你将会看到:
参考资料
OP-TEE Documentation — OP-TEE documentation documentation (optee.readthedocs.io)
FAQ
RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received
sudo apt-get purge git sudo apt-get install gitModuleNotFoundError: No module named 'Cryptodome'
#pycrypto、pycrytodome和crypto是一个东西,crypto在python上面的名字是pycrypto,
pip3 uninstall pycryptodome pip3 install pycryptodomeedk2相关错误
编译edk2 提示莫名奇怪错误,可能是编译过程中没能正常下载相关依赖导致。
进edk2, 执行下载相即可。
git submodule update --init --recursiveedk2 boringssl下载失败
tianocore/edk2.git/CryptoPkg/Library/OpensslLib/openssl/boringssl: fatal: unable to access 'https://hub.fastgit.org/google/boringssl.git/': gnutls_handshake() failed: Error in the pull function. error: Cannot fetch tianocore/edk2.git/CryptoPkg/Library/OpensslLib/openssl/boringssl from https://boringssl.googlesource.com/boringssl Fetching: 100% (1/1), done in 4.610s 解决思路是使用git config --global url.A.insteadOf B 命令将boringssl.googlesource.com替换为谷歌的github镜像库 https://github.com/google/boringssl.git,方法如下: git config --global url."https://github.com/google/boringssl.git".insteadOf "https://boringssl.googlesource.com/boringssl"