| permalink | /trustzone-sdk-docs/emulate-and-dev-in-docker-std.md |
|---|
This guide covers the dev-env with std support that enables developing TA using Rust standard library (std), compared to the regular no-std environment documented in emulate-and-dev-in-docker.md.
The dev-env with std support provides a complete setup for building TAs that can use Rust's standard library features like collections, networking, etc.
📖 Prerequisites: Read the original Docker development guide first. This document focuses only on std-specific differences and capabilities.
The dev-env with std support enables developing TA using Rust std by providing:
- Flexible configuration management - Switch between std/no-std modes and architectures dynamically
- Rust standard library tailored for OP-TEE - Build TAs using collections, networking, serialization capabilities
- Mixed development support - Combine different host and TA architectures, including switching between no-std/std in the same project
# Pull the dev-env with std support for developing TA using Rust std
$ docker pull teaclave/teaclave-trustzone-emulator-std-expand-memory:latest
# Launch the dev-env container
$ docker run -it --rm \
--name teaclave_dev_env \
-v $(pwd):/root/teaclave_sdk_src \
-w /root/teaclave_sdk_src \
teaclave/teaclave-trustzone-emulator-std-expand-memory:latest# Create symbolic link to make it compatiable with existing SDK examples
$ ln -s $RUST_STD_DIR rust📝 Note: This symlink is required for current SDK examples due to hardcoded std dependency paths in Cargo.toml. Your own projects may organize std files differently.
The key difference is the unified configuration system that allows switching between std/no-std modes and different architectures on demand.
And cargo-optee is available as an alternative to the original configuration management tool: switch_config.
# Show current active configuration
$ switch_config --status
# List all supported configurations
$ switch_config --listTA Configurations Available:
std/aarch64,std/arm32- With Rust standard libraryno-std/aarch64,no-std/arm32- Without standard library
Host Configurations Available: aarch64, arm32
Default Configuration: Host=aarch64, TA=std/aarch64
# Switch TA configurations
$ switch_config --ta std/aarch64 # Enable std for 64-bit TA
$ switch_config --ta std/arm32 # Enable std for 32-bit TA
$ switch_config --ta no-std/aarch64 # Disable std, use 64-bit no-std
# Switch host architecture
$ switch_config --host arm32 # Use 32-bit host
# Mixed development example: 32-bit host + 64-bit std TA
$ switch_config --host arm32 && switch_config --ta std/aarch64You can see the cargo-optee configuration system for details.
Follow the original building instructions, but note these important target differences:
| Configuration | TA Target | Build Tool | Host Target |
|---|---|---|---|
std/* |
*-unknown-optee |
cargo -Z build-std |
*-unknown-linux-gnu |
no-std/* |
*-unknown-linux-gnu |
cargo |
*-unknown-linux-gnu |
Example std build output:
TA=ta/target/aarch64-unknown-optee/release/133af0ca-bdab-11eb-9130-43bf7873bf67.ta# Build hello world with std/aarch64 (default configuration)
$ cd examples/hello_world-rs/
$ makeResult: TA built with std enabled, targeting aarch64-unknown-optee:
TA=ta/target/aarch64-unknown-optee/release/133af0ca-bdab-11eb-9130-43bf7873bf67.ta# Switch TA to no-std mode and rebuild
$ switch_config --ta no-std/aarch64
$ make clean && makeResult: TA now targets aarch64-unknown-linux-gnu (no-std):
TA=ta/target/aarch64-unknown-linux-gnu/release/133af0ca-bdab-11eb-9130-43bf7873bf67.taIf you are using cargo-optee, the relevant workflow is already clearly documented in the cargo-optee appendix, so it will not be repeated here.
The emulation process is identical to the no-std environment. Follow sections 3-6 of the original guide for complete emulation setup instructions.