This is an automated email from the ASF dual-hosted git repository.
yuanz pushed a commit to branch add-doc
in repository
https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
The following commit(s) were added to refs/heads/add-doc by this push:
new ee459f1 Create building-rust-ca-as-android-elf.md
ee459f1 is described below
commit ee459f1eca6ccc1afc0a22afa58db8fd6ddcc18e
Author: Yuan Zhuang <[email protected]>
AuthorDate: Thu Sep 22 15:18:53 2022 +0800
Create building-rust-ca-as-android-elf.md
---
docs/building-rust-ca-as-android-elf.md | 63 +++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/docs/building-rust-ca-as-android-elf.md
b/docs/building-rust-ca-as-android-elf.md
new file mode 100644
index 0000000..0138de6
--- /dev/null
+++ b/docs/building-rust-ca-as-android-elf.md
@@ -0,0 +1,63 @@
+# Building Rust CA as Android ELF
+
+In Teaclave TrustZone SDK, example CAs are built as ARM64 Linux ELF by default.
+Besides, you can follow these steps to build Rust CAs running on the Android
+platform:
+
+1. Download Android NDK toolchain
+
+```
+$ wget
https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
+$ unzip android-ndk-r21e-linux-x86_64.zip
+```
+
+2. Add the android target
+
+```
+$ rustup target add aarch64-linux-android
+```
+
+3. Set toolchains for the target. Add PATH env:
+
+```
+export
PATH=$PATH:/your/path/to/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/
+```
+
+4. Edit `incubator-teaclave-trustzone-sdk/.cargo/config`, add:
+
+```
+[target.aarch64-linux-android]
+linker = "aarch64-linux-android28-clang"
+ar = "aarch64-linux-android-ar"
+```
+
+5. Copy Android libteec.so to
+`/incubator-teaclave-trustzone-sdk/optee/optee_client/out/export/usr/lib`.
+
+- Note: If you've not built the libteec.so of Android, you can build it using:
+```
+$ cd /path/to/optee/optee_client/
+$ ndk-build APP_BUILD_SCRIPT=./Android.mk NDK_PROJECT_PATH=. NDK_LOG=1
APP_PLATFORM=android-29
+```
+
+6. Modify CA's Makefile:
+
+```
+NAME := hello_world-rs
+TARGET := aarch64-linux-android
+OPTEE_DIR ?= ../../../optee
+OUT_DIR := $(CURDIR)/target/$(TARGET)/release
+
+all: host
+
+host:
+ @cargo build --target $(TARGET) --release --verbose
+clean:
+ @cargo clean
+```
+
+7. build:
+
+```
+$ make -C examples/hello_world-rs/host
+```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]