下載並構建

Trusty 存儲庫在 Android 開源項目 (AOSP) 中可用。

使用這些鏈接在 AOSP 中查找適當的 Trusty 內核分支:

安裝回購

要下載 Trusty,首先下載並安裝 Repo

成功安裝 Repo 後,您可以克隆 Android Trusty 存儲庫。

mkdir trusty
cd trusty
repo init -u https://android.googlesource.com/trusty/manifest -b master
repo sync -j32

建造

使用以下內容為 Trusty 構建通用 arm64 映像。

./trusty/vendor/google/aosp/scripts/build.py generic-arm64

構建結果將在build-root/build-generic-arm64/.查找 lk.bin,它是一個 TEE 映像,所有應用程序都編譯在:

ls build-root/build-generic-arm64/lk.bin

安裝

您可以將 lk.bin 組裝成固件映像並將其閃存到設備中。生成固件映像取決於所使用的板。請聯繫您的電路板製造商以獲取說明。

對 QEMU 的信任

如果您還沒有在主機上安裝所需的軟件包:

sudo apt install libpixman-1-dev libstdc++-8-dev pkg-config libglib2.0-dev libusb-1.0-0-dev

構建(使用構建服務器腳本)trusty 和 qemu 鏡像:

trusty/vendor/google/aosp/scripts/build.py qemu-generic-arm64-test-debug

這還將運行為此目標配置的所有測試。

手動運行測試運行器測試(端口激活)(com.android.ipc-unittest.ctrl):

build-root/build-qemu-generic-arm64-test-debug/run --headless --boot-test "com.android.ipc-unittest.ctrl"

要在啟動時使用內核調試輸出運行測試運行程序測試 (com.android.ipc-unittest.ctrl):

build-root/build-qemu-generic-arm64-test-debug/run-qemu --boot-test "com.android.ipc-unittest.ctrl" --headless --verbose

ATF 在返回測試運行器之前禁用控制台。要在本地禁用此功能,請註釋掉 external/arm-trusted-firmware/plat/common/aarch64/plat_common.c 中 bl31_plat_runtime_setup 中的所有代碼。

要從 Android shell 運行測試,

build-root/build-qemu-generic-arm64-test-debug/run-qemu --shell-command "/data/nativetest64/tipc-test/tipc-test -t ta2ta-ipc" --headless

引導到交互式 shell(從簽入的預構建)

build-root/build-qemu-generic-arm64-test-debug/run

此命令還具有各種其他可用的覆蓋 - 檢查 --help 了解更多信息。

如果運行qmeu.pyadb devices -l失敗,則係統上運行的 adb 服務器版本可能是錯誤的版本。

adb kill-server

要啟動您在本地擁有的 Android 版本,

build-root/build-qemu-generic-arm64-test-debug/run --android path/to/your/android/source/dir

要為 Trusty 構建 Android,

mkdir android
cd android
repo init -u https://android.googlesource.com/platform/manifest -b master
repo sync -j32
source build/envsetup.sh
lunch qemu_trusty_arm64-userdebug
m