ubuntu20.04安装OPTEE
基本概念
| 組件 | 版本 |
| Ubuntu | 20.04 |
| qemu | 2.9.50 |
| Python(虛擬環(huán)境) 我的普通用戶權(quán)限默認(rèn)是這個(gè)環(huán)境 | 2.7 |
| Python(apt) | 2.7 |
python的虛擬環(huán)境和虛擬機(jī)(vmware/virtual box)不是一個(gè)概念,不要搞混了。
?
基本概念
| 名詞 | 解釋/舉例 |
| CA | Client Application |
| TA | Trust Appliaction |
| Normal world OS | Linux Android |
| Secure world OS | OP-TEE Trusty QSEE SierraTEE |
| QEMU | 一種模擬器 |
| OP-TEE | 一種操作系統(tǒng) |
| repo | 和git一樣管理 代碼用的的競(jìng)品 |
?
你想啊,你如果想要在電腦端玩安卓手機(jī)中的游戲咋辦?
你需要一個(gè)模擬器對(duì)吧?
所以上述表格中的模擬器也是類似的道理。
?
最終目標(biāo)
實(shí)驗(yàn)的目標(biāo)是在QEMU終端的支持下,
Normal系統(tǒng)(Linux)中的CA能與Secure系統(tǒng)(OP-TEE)中的TA進(jìn)行通信。
以TA輸出"Hello World"作為成功的標(biāo)志
?
安裝依賴
apt-get install git python android-tools-adb android-tools-fastboot autoconf \automake bc bison build-essential cscope curl device-tree-compiler \expect flex ftp-upload gdisk iasl 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 libz1:i386 make \mtools netcat python-crypto unzip uuid-dev \xdg-utils xterm xz-utils zlib1g-dev下面這兩個(gè)先不安裝,因?yàn)閜ython2.x中不存在這兩個(gè)包,暫時(shí)沒發(fā)現(xiàn)有啥問題
python-serial python-wand?
注意,本實(shí)驗(yàn)一律python2.x,凡是python3.x的安裝包李銳 python3-serial這種是無(wú)效的。
python3和python2是不可能混用的。
?
安裝REPO
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo chmod +x repo?
同步OP-TEE所需的各種Repository
./repo init -u https://github.com/OP-TEE/manifest.git -m default_stable.xml --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -b 2.6.0./.repo/manifests/default_stable.xml修改如下
<?xml version="1.0" encoding="utf-8"?> <manifest><!-- <remote fetch="git://busybox.net" name="busybox"/> --> <!-- <remote fetch="https://github.com/linaro-swg" name="linaro-swg"/><remote fetch="https://github.com/OP-TEE" name="optee"/><remote fetch="https://github.com/qemu" name="qemu"/>--><!-- 下面的name隨便寫,就是定義一個(gè)變量啊的意思,讓后面的remote可以使用 --><remote name="yuchi" fetch="https://gitee.com/fastsource" /><remote name="optee" fetch="https://gitee.com/fastsource" /><remote name="qemu" fetch="https://gitee.com/fastsource" /><remote name="linaro-swg" fetch="https://gitee.com/KaminDeng" /><remote name="build" fetch="https://gitee.com/fastsource" /><remote name="busybox" fetch="https://gitee.com/fastsource" /><default remote="optee" revision="master" clone-depth="1"/><project name="bios_qemu_tz_arm.git" path="bios_qemu_tz_arm" remote="yuchi" revision="0271acbfa81d93e64c2fdd6ae8b0be14a8c45719" clone-depth="1"/><project name="build.git" path="build" remote="build" revision="refs/tags/2.6.0" clone-depth="1"><linkfile dest="build/Makefile" src="qemu.mk"/></project><project name="busybox.git" path="busybox" remote="busybox" revision="dbf5a6da6a4295ce26edd1ce34fde567d19afa02" clone-depth="1"/><project name="dtc.git" path="qemu/dtc" remote="qemu" revision="c1e55a5513e9bca41dc78a0f20245cc928596a3a" clone-depth="1"/><project name="gen_rootfs.git" path="gen_rootfs" remote="yuchi" revision="fe617d470e45778c909038bf3e7ca15174a4f893" clone-depth="1"/><project name="torvalds-linux.git" path="linux" remote="linaro-swg" clone-depth="1"/><project name="optee_benchmark.git" path="optee_benchmark" remote="yuchi" revision="refs/tags/2.6.0" clone-depth="1"/><project name="optee_client.git" path="optee_client" revision="refs/tags/2.6.0" clone-depth="1"/><project name="optee_examples.git" path="optee_examples" remote="yuchi" revision="refs/tags/2.6.0" clone-depth="1"/><project name="optee_os.git" path="optee_os" revision="refs/tags/2.6.0" clone-depth="1"/><project name="optee_test.git" path="optee_test" revision="refs/tags/2.6.0" clone-depth="1"/><project name="qemu.git" path="qemu" remote="qemu" revision="199e19ee538eb61fd08b1c1ee5aa838ebdcc968e" clone-depth="1"/><project name="soc_term.git" path="soc_term" remote="yuchi" revision="5493a6e7c264536f5ca63fe7511e5eed991e4f20" clone-depth="1"/> </manifest>上面修改的原理是:
所有的github鏈接全部改成gitee鏈接。
關(guān)于repo命令的上述xml文件的修改知識(shí)點(diǎn):
| 一些設(shè)置 | 相關(guān)解釋 |
| clone-depth=“1” | 這個(gè)意思是說, github中有很多commit 我們只要最近一次的 |
| name | 隨便定義即可 這個(gè)name后面的定義是給下面的remote來使用的 |
?
然后我們開始同步(其實(shí)就是下載上述.xml中的各種軟件庫(kù))
time ./repo sync順利同步后,會(huì)在頂層文件夾下面生成build文件夾
?
獲取toolchains
(下面兩步是很多教程里面的,我們不執(zhí)行,使用其他步驟)
cd build
make -f toolchain.mk toolchains
很明顯是toolchain.mk中的這些鏈接導(dǎo)致上述命令的運(yùn)行速度超級(jí)慢的。
參考[7][8]
用迅雷下載下面三個(gè)
https://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/aarch64-linux-gnu/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu.tar.xz
https://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/arm-linux-gnueabihf/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
https://releases.linaro.org/archive/14.08/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.9-2014.08_linux.tar.xz(這個(gè)據(jù)說不弄也可以,但是保險(xiǎn)起見還是弄下吧)
編譯qemu
| 需要修改的文件 | 原來的 | 改為 |
| qemu/util/memfd.c | #ifdef CONFIG_MEMFD #include <sys/memfd.h> #elif defined CONFIG_LINUX | #if defined CONFIG_LINUX && !defined CONFIG_MEMFD |
| qemu/configure | #include <sys/memfd.h> | #include <sys/mman.h> |
real?? ?3m43.667s
user?? ?3m13.859s
sys?? ?0m23.519s
大概編譯了不到4分鐘
這一步一定要仔細(xì)檢查log中是否有error與fail
如果有的話,不要往下操作。
啟動(dòng)qemu
build //切換到build目錄 make -f qemu.mk run-only然后會(huì)出來Normal和Secure兩個(gè)終端,
此時(shí)總共有qemu、Normal、Secure共3個(gè)終端
在qemu輸入c
圖中右側(cè)的gtk error是因?yàn)閡buntu的gtk版本太新導(dǎo)致的,和qemu沒有任何關(guān)系,只會(huì)影響顯示效果(例如像素顯示失效或者顯示不太好看之類的)放心使用即可
?
然后Normal終端會(huì)自動(dòng)出來一個(gè)命令行提示,
在這個(gè)命令行提示中輸入optee_hello_world
之后會(huì)在Secure終端出現(xiàn)"hello world",即標(biāo)志安裝配置成功
Reference
[1]https://mirror.tuna.tsinghua.edu.cn/help/git-repo/
[2]0.使用Qemu運(yùn)行OP-TEE
[3]OP-TEE的安裝
[4]Git Repo 鏡像使用幫助
[5]OPTEE技術(shù)詳解演示(完)
[6]3.OP-TEE+qemu的編譯--工程編譯target依賴關(guān)系
[7]【OP-TEE 3.8.0學(xué)習(xí)】001_運(yùn)行環(huán)境的搭建及編譯
[8]OP-TEE 環(huán)境搭建
總結(jié)
以上是生活随笔為你收集整理的ubuntu20.04安装OPTEE的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 记录apt安装时间
- 下一篇: ubuntu每日构建版